Rubics

No Deck Found Crazyflie Bitcraze

Feb 15th, 2022 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import logging
  2. import sys
  3. import time
  4. from threading import Event
  5.  
  6. import cflib.crtp
  7. from cflib.crazyflie import Crazyflie
  8. from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
  9. from cflib.positioning.motion_commander import MotionCommander
  10. from cflib.utils import uri_helper
  11.  
  12. URI = uri_helper.uri_from_env(default='radio://0/80/2M/E7E7E7E7E7')
  13.  
  14. DEFAULT_HEIGHT = 0.5
  15.  
  16. deck_attached_event = Event()
  17.  
  18. logging.basicConfig(level=logging.ERROR)
  19.  
  20. def take_off_simple(scf):
  21.     with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc:
  22.         time.sleep(3)
  23.         mc.stop()
  24.  
  25.  
  26. def param_deck_flow(name, value_str):
  27.     ...
  28.  
  29. if __name__ == '__main__':
  30.     cflib.crtp.init_drivers()
  31.  
  32.     with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
  33.  
  34.         scf.cf.param.add_update_callback(group='deck', name='bcDWM1000',cb=param_deck_flow)
  35.         time.sleep(1)
  36.  
  37.         if not deck_attached_event.wait(timeout=5):
  38.            print('No flow deck detected!')
  39.            sys.exit(1)
  40.  
  41.         #take_off_simple(scf)
  42.  
  43.  
Add Comment
Please, Sign In to add comment