Created
November 3, 2017 13:35
-
-
Save anonymous/774298d1169c60741946eba5fccfda06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import time | |
import pygame, sys | |
from pygame.locals import * | |
# import cflib.crtp | |
# from cflib.crazyflie.syncCrazyflie import SyncCrazyflie | |
# URI = 'radio://0/80/250K' | |
# | |
# # Only output errors from the logging framework | |
# logging.basicConfig(level=logging.ERROR) | |
running = True | |
pygame.init() | |
thrustupdown=0 | |
forwardback=0 | |
leftright=0 | |
yawrightleft=0 | |
# | |
# if __name__ == '__main__': | |
# # Initialize the low-level drivers (don't list the debug drivers) | |
# cflib.crtp.init_drivers(enable_debug_driver=False) | |
# | |
# with SyncCrazyflie(URI) as scf: | |
# cf = scf.cf | |
# | |
# cf.param.set_value('kalman.resetEstimation', '1') | |
# time.sleep(0.1) | |
# cf.param.set_value('kalman.resetEstimation', '0') | |
# time.sleep(2) | |
while running: | |
for event in pygame.event.get(): | |
if event.type==QUIT: | |
pygame.quit() | |
sys.exit() | |
##------------thrust-------------------(*_*)-------------------------------- | |
if event.type == KEYDOWN: | |
if (event.key == K_w): | |
thrustupdown-=0.1 | |
print (thrustupdown,"thrustup") | |
elif (event.key == K_s): | |
thrustupdown+=0.1 | |
print (thrustupdown,"thrustdown") | |
##------------pitch-------------------(*_*)-------------------------------- | |
if (event.key == K_UP): | |
forwardback=0.4 | |
print (forwardback,"forward") | |
elif (event.key == K_DOWN): | |
forwardback=-0.4 | |
print (forwardback,"back") | |
##-----------roll--------------------(*_*)-------------------------------- | |
if (event.key == K_LEFT): | |
leftright=0.4 | |
print (leftright,"left") | |
elif (event.key == K_RIGHT): | |
leftright=-0.4 | |
print (leftright,"right") | |
##-----------yaw--------------------(*_*)-------------------------------- | |
if (event.key == K_a): | |
yawrightleft=-0.4 | |
print (yawrightleft,"yawleft") | |
elif (event.key == K_d): | |
yawrightleft=0.4 | |
print (yawrightleft,"yawright") | |
thrustupdown=0 | |
forwardback=0 | |
leftright=0 | |
yawrightleft=0 | |
if (event.key == K_i): | |
print ("") | |
print ("yawrightleft") | |
print (yawrightleft) | |
print ("leftright") | |
print (leftright) | |
print ("forwardback") | |
print (forwardback) | |
print ("thrustupdown") | |
print (thrustupdown) | |
# cf.commander.send_stop_setpoint() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment