Monday, September 3, 2018

Pixhawk first connection

  • Connect to usb
  • Understand LED's
  • Write some dronekit code read heartbeat
  • Read GPS data with dronekit

Connect to USB

  • dmsg
[768651.390811] usb 3-2: Product: PX4 FMU v2.x [768651.390814] usb 3-2: Manufacturer: 3D Robotics [768651.390816] usb 3-2: SerialNumber: 0 [768651.391528] cdc_acm 3-2:1.0: ttyACM0: USB ACM device

LED's

  • Flashing blue: Disarmed, no GPS lock found
  • Flashing green: Disarmed (ready to arm), GPS lock acquired.
  • Full list: http://ardupilot.org/plane/docs/common-leds-pixhawk.html

Connect GPS and Compass

  • LED go to blinking green
  • my GPS led blink with green led's

Dronekit hello

#!/usr/bin/env python from dronekit import connect, VehicleMode connection_string = "/dev/ttyACM0" # Connect to the Vehicle. print("Connecting to vehicle on: %s" % (connection_string,)) vehicle = connect(connection_string, wait_ready=True) # Get some vehicle attributes (state) print "Get some vehicle attribute values:" print " GPS: %s" % vehicle.gps_0 print " Battery: %s" % vehicle.battery print " Last Heartbeat: %s" % vehicle.last_heartbeat print " Is Armable?: %s" % vehicle.is_armable print " System status: %s" % vehicle.system_status.state print " Mode: %s" % vehicle.mode.name # settable # Close vehicle object before exiting script vehicle.close()

Read GPS data

#!/usr/bin/env python from dronekit import connect, VehicleMode import time connection_string = "/dev/ttyACM0" def log_gps(self, name, msg): print msg # Connect to the Vehicle. print("Connecting to vehicle on: %s" % (connection_string,)) vehicle = connect(connection_string, wait_ready=True) #vehicle.add_message_listener('GLOBAL_POSITION_INT', log_gps) vehicle.add_message_listener('GPS_RAW_INT', log_gps) time.sleep(5) vehicle.close()

Result

  • GPS_RAW_INT: The global position, as returned by the Global Positioning System (GPS). This is NOT the global position estimate of the sytem, but rather a RAW sensor value. See message GLOBAL_POSITION for the global position estimate. Coordinate frame is right-handed, Z-axis up (GPS frame)
GPS_RAW_INT {time_usec : 4246687000, fix_type : 4, lat : 324283000, lon : 350107200, alt : 45700, eph : 98, epv : 171, vel : 14, cog : 23071, satellites_visible : 8}
  • GLOBAL_POSITION_INT: fused GPS and accelerometers). The position is in GPS-frame (right-handed, Z-up)
GLOBAL_POSITION_INT {time_boot_ms : 2848710, lat : 324284000, lon : 350107830, alt : 99400, relative_alt : 8000, vx : -17, vy : 9, vz : 8, hdg : 4893}

Reference

No comments: