def run(self): global RUNNING values = { 'roll': INITIAL_ROLL, 'pitch': INITIAL_PITCH, 'yaw': INITIAL_YAW, 'throttle': INITIAL_THROTTLE } board = MultiWii(SERIAL, PRINT=False) last_command = time.time() armed = False try: while RUNNING: command = None try: command = QUEUE.get_nowait() QUEUE.task_done() # we don't retry commands except Empty: if (time.time() - last_command) > 2: #fail safe - if no commands stop the drone board.disarm() armed = False continue if armed: data = [values['roll'], values['pitch'], values['yaw'], values['throttle']] board.sendCMD(8,MultiWii.SET_RAW_RC,data) time.sleep(0.05) continue last_command = time.time() if not command or not 'action' in command: continue print "got command: %s" % command if command['action'] == 'arm': board.arm() armed = True elif command['action'] == 'disarm': board.disarm() armed = False elif command['action'] == 'update': try: values.update(command['data']) except: logging.exception('error update values') else: logging.debug('invalid command %s' % command) except: logging.exception("Error") board.disarm()
#!/usr/bin/env python """test-send.py: Test script to send RC commands to a MultiWii Board.""" __author__ = "Aldo Vargas" __copyright__ = "Copyright 2014 Aldux.net" __license__ = "GPL" __version__ = "1" __maintainer__ = "Aldo Vargas" __email__ = "*****@*****.**" __status__ = "Development" from pyMultiwii import MultiWii import time if __name__ == "__main__": #board = MultiWii("/dev/ttyUSB0") board = MultiWii("/dev/tty.SLAB_USBtoUART") try: board.arm() print "Board is armed now!" print "In 3 seconds it will disarm..." time.sleep(3) board.disarm() print "Disarmed." time.sleep(3) except Exception,error: print "Error on Main: "+str(error)
#!/usr/bin/env python3 """test-send.py: Test script to send RC commands to a MultiWii Board.""" __author__ = "Aldo Vargas" __copyright__ = "Copyright 2016 Altax.net" __license__ = "GPL" __version__ = "1" __maintainer__ = "Aldo Vargas" __email__ = "*****@*****.**" __status__ = "Development" from pyMultiwii import MultiWii import time if __name__ == "__main__": #board = MultiWii("/dev/tty.usbserial-AM016WP4") board = MultiWii("/dev/tty.SLAB_USBtoUART") try: board.arm() print "Board is armed now!" print "In 3 seconds it will disarm..." time.sleep(3) board.disarm() print "Disarmed." time.sleep(3) except Exception, error: print "Error on Main: " + str(error)