def __init__(self, root, canvas): self.root = root self.canvas = canvas self.fmuport = serial.Serial(FMUPORT, 115200) # MSPPG self.parser = msppg.MSP_Parser() self.parser.set_ATTITUDE_Handler(self._attitude_message_handler) self.request = msppg.serialize_ATTITUDE_Request() self.yaw, self.pitch, self.roll = 0, 0, 0 thread = threading.Thread(target = self._read_fmu) thread.daemon = True thread.start() self._send_request()
def __init__(self, root, canvas): self.root = root self.canvas = canvas self.fmuport = serial.Serial(FMUPORT, 115200) # MSPPG self.parser = msppg.MSP_Parser() self.parser.set_ATTITUDE_Handler(self._attitude_message_handler) self.request = msppg.serialize_ATTITUDE_Request() self.yaw, self.pitch, self.roll = 0, 0, 0 thread = threading.Thread(target=self._read_fmu) thread.daemon = True thread.start() self._send_request()
def __init__(self, root, canvas): self.root = root self.canvas = canvas self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM ) self.sock.connect((BT_ADDR, BT_PORT)) # MSPPG self.parser = msppg.MSP_Parser() self.parser.set_ATTITUDE_Handler(self._attitude_message_handler) self.request = msppg.serialize_ATTITUDE_Request() self.yaw, self.pitch, self.roll = 0, 0, 0 thread = threading.Thread(target = self._read_fmu) thread.daemon = True thread.start() self._send_request()
def __init__(self, root, canvas): self.root = root self.canvas = canvas #self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM ) self.sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) self.sock.connect((BT_ADDR, BT_PORT)) # MSPPG self.parser = msppg.MSP_Parser() self.parser.set_ATTITUDE_Handler(self._attitude_message_handler) self.request = msppg.serialize_ATTITUDE_Request() self.yaw, self.pitch, self.roll = 0, 0, 0 thread = threading.Thread(target = self._read_fmu) thread.daemon = True thread.start() self._send_request()
self.altitude = altitude def attitudeHandler(self, pitch, roll, yaw): self.heading = yaw if __name__ == '__main__': # Create an MSP parser and messages for telemetry requests parser = MyParser() parser.set_ATTITUDE_Handler(parser.attitudeHandler) parser.set_ALTITUDE_Handler(parser.altitudeHandler) # Serialize the telemetry message requests that we'll send to the "firwmare" attitude_request = serialize_ATTITUDE_Request() altitude_request = serialize_ALTITUDE_Request() # More than two command-line arguments means simulation mode. First arg is camera-client port, # second is MSP port, third is input image file name, fourth is outpt image file name. if len(sys.argv) > 2: from socket_server import serve_socket # Serve a socket for camera synching, and a socket for comms camera_client = serve_socket(int(sys.argv[1])) comms_to_client = serve_socket(int(sys.argv[2])) comms_from_client = serve_socket(int(sys.argv[3])) image_from_sim_name = sys.argv[4] image_to_sim_name = sys.argv[5]
BAUD = 115200 from msppg import MSP_Parser as Parser, serialize_ATTITUDE_Request import serial from sys import argv if len(argv) < 2: print('Usage: python3 %s PORT' % argv[0]) print('Example: python3 %s /dev/ttyUSB0' % argv[0]) exit(1) parser = Parser() request = serialize_ATTITUDE_Request() port = serial.Serial(argv[1], BAUD) def handler(pitch, roll, yaw): print(pitch, roll, yaw) port.write(request) parser.set_ATTITUDE_Handler(handler) port.write(request) while True: try:
BAUD = 115200 from msppg import MSP_Parser as Parser, serialize_ATTITUDE_Request import serial from sys import argv if len(argv) < 2: print('Usage: python3 %s PORT' % argv[0]) print('Example: python3 %s /dev/ttyUSB0' % argv[0]) exit(1) parser = Parser() request = serialize_ATTITUDE_Request() port = serial.Serial(argv[1], BAUD) def handler(pitch, roll, yaw): print(pitch, roll, yaw) port.write(request) parser.set_ATTITUDE_Handler(handler) port.write(request) while True: