Retrieving sonar data through pymavlink

Hi @Alstrup,

Our Ping Sonar does not communicate using I2C, so this won’t work. You’ll need to either connect it using one of the serial ports, or connect it to the Raspberry Pi using a serial to USB adaptor (like our BLUART).

Which data are you after?

  • If you only want the distance estimates (and don’t care about changing settings or using Ping Viewer) then you should be able to use a direct serial connection with some appropriate parameters set in the firmware
    • In this case the distances may be accessible via either DISTANCE_SENSOR or NAMED_VALUE_FLOAT messages
    • This approach connects the sonar directly to the autopilot firmware, and BlueOS will not know about it
  • If you want more direct control over the sonar’s settings and/or want to use Ping Viewer then you’ll need to either allow it to pass through from the serial port or connect it via USB
    • This can still allow distance measurements to be provided over MAVLink by turning on the “MAVLink Distances” option on the Ping Sonar Devices page
      • This requires BlueOS 1.1, which currently only has beta releases available, so updating to it needs Pirate Mode to be enabled
    • If you want ping profiles or settings access from your code then you’ll need to use our Ping Python library to talk to the sonar, rather than using pymavlink