Skip to content

Instantly share code, notes, and snippets.

Created November 3, 2017 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/774298d1169c60741946eba5fccfda06 to your computer and use it in GitHub Desktop.
Save anonymous/774298d1169c60741946eba5fccfda06 to your computer and use it in GitHub Desktop.
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