Example Software
Two simple examples of how you can use dronekit to analyze data from the pixhawk on the raspberry pi. First you have to make sure that dronekit is installed.
sudo pip install dronekit
Vehicle Status Information
# Basic test how to get some data from Pixhawk # using the DRONEKIT python api # Stefan Hager 2023 from dronekit import connect # Connect to the Vehicle (in this case via UART = serial0) vehicle = connect('/dev/serial0', wait_ready=True, baud = 921600 ) # retrieve some information about the connected device and status print("Ardupilot Version: " , vehicle.version) print("Battery status: ", vehicle.battery) print("Attitude: " , vehicle.attitude) print("Velocity: " , vehicle.velocity) print("Current Mode: ", vehicle.mode.name) print("Armed? : " , vehicle.armed )
Vehicle Attitude Information
# Basic test how to get attitude data from Pixhawk # using the DRONEKIT python api # Stefan Hager 2023 from dronekit import connect import time # Connect to the Vehicle (in this case via UART = serial0) vehicle = connect('/dev/serial0', wait_ready=True, baud = 921600 ) # mode the vehicle or just the Pixhawk controller to see the attitude changes while True: print("Attitude: ", vehicle.attitude) print("Velocity: