from __future__ import print_function from dronekit import connect, Vehicle from my_vehicle import MyVehicle import time # Connect to the Vehicle. print("\nConnecting to vehicle") vehicle = connect('/dev/ttyAMA0', wait_ready=True, baud = 57600) vehicle.wait_ready('autopilot_version') # Set up option parsing to get connection string import argparse parser = argparse.ArgumentParser(description='Creates a CherryPy based web application that displays a mapbox map to let you view the current vehicle position and send the vehicle commands to fly to a particular latitude and longitude. Will start and connect to SITL if no connection string specified.') parser.add_argument('--connect', help="vehicle connection target string. If not specified, SITL is automatically started and used.") args = parser.parse_args() connection_string = args.connect # Add observer for the custom attribute def scaled_imu2_callback(self, attr_name, value): # attr_name == 'scaled_imu2' # value == vehicle.scaled_imu2 print(value) vehicle.add_attribute_listener('scaled_imu2', scaled_imu2_callback) time.sleep(5)