Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- import sys
- import time
- from threading import Event
- import cflib.crtp
- from cflib.crazyflie import Crazyflie
- from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
- from cflib.positioning.motion_commander import MotionCommander
- from cflib.utils import uri_helper
- URI = uri_helper.uri_from_env(default='radio://0/80/2M/E7E7E7E7E7')
- DEFAULT_HEIGHT = 1.0
- deck_attached_event = Event()
- logging.basicConfig(level=logging.ERROR)
- def take_off_simple(scf):
- with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc:
- time.sleep(1)
- mc.stop()
- def param_deck_flow(_, value_str):
- value = int(value_str)
- print(value)
- if value:
- deck_attached_event.set()
- print('Deck is attached!')
- else:
- print('Deck is NOT attached!')
- if __name__ == '__main__':
- cflib.crtp.init_drivers()
- with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
- scf.cf.param.add_update_callback(group='deck', name='bcDWM1000',cb=param_deck_flow)
- scf.cf.param.request_param_update('deck.bcDWM1000')
- if not deck_attached_event.wait(timeout=5):
- print('No flow deck detected!')
- sys.exit(1)
- take_off_simple(scf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement