Skip to content

Latest commit

 

History

History
144 lines (102 loc) · 5.33 KB

File metadata and controls

144 lines (102 loc) · 5.33 KB

{% include "../archive-notice.html" %}

Pymavlink

ArduSub communicates with a protocol called MAVLink. Pymavlink is a python implementation of the MAVLink protocol. With pymavlink, it is possible to create a python script to read sensor data and send commands to an ArduSub vehicle.

Please reference the pymavlink documentation, repository and chat for further information.

Safety

The autopilot employs a some failsafe mechanisms to keep you and your equipement safe, as well as to prevent your ROV from running away from you during experiments.

All system components that communicate via MAVLink are expected to send a HEARTBEAT message at a constant rate of at least 1 Hz. If the autopilot does not receive a heartbeat from your application after this interval, it will trigger a failsafe.

When the autopilot is being commanded to move via RC_CHANNELS_RAW or MANUAL_CONTROL messages, the messages must be sent at a constant rate like the HEARTBEAT message. Otherwise, the autopilot will execute a failsafe if it has not received an updated command after a timeout period.

Installation

Ubuntu 20.04

# Update list of available packages
sudo apt update
sudo apt -y upgrade

# Install some dependencies
sudo apt install -y python3-pip

# Install mavproxy module and everything else needed
pip3 install mavproxy

Mac/Windows

With Python and pip installed, run pip install wheel mavproxy.

Test installation

You can test your installation with python interactive shell.

python
import pymavlink
print(pymavlink.__doc__)

Output:

Python MAVLink library - see http://www.qgroundcontrol.org/mavlink/mavproxy_startpage

Note that pymavlink.__doc__ will show some information about the package. This is a record of this example running in python interactive shell:

asciicast

Examples

Pymavlink has 3 types of messages:

  • command_long_send: To create a raw package
  • <message_name>_send: To send simple mavlink messages
  • mavutil: Functions to abstract some MAVLink messages

Connect

There are 3 types of udp connections for mavlink_connection:

  • udpout: Outputs data to a specified address:port (client).
  • udpbcast: Broadcasts and locks to the first client to respond (does not handle multiple clients properly)
    • Using the IP 192.168.1.255 all devices from 192.168.1.1 to 192.168.1.255 will receive the data.
  • udpin: Binds to a specific port in address:port (server), it's necessary to receive data from clients (udpout) before starting to send any data.
  • udp: Exists for legacy reasons, works as udpin.

Shortcut Links

  1. Autopilot connected to the computer via serial
  2. Run pyMavlink on the surface computer
  3. Run pyMavlink on the companion computer
  4. Send Message to QGroundControl
  5. Arm/Disarm the vehicle
  6. Change flight mode
  7. Send RC (Joystick)
  8. Send Manual Control
  9. Read all parameters
  10. Read and write parameters
  11. Receive data and filter by message type
  12. Request message interval
  13. Control Camera Gimbal
  14. Set Servo PWM
  15. Advanced Servo/Gripper Example
  16. Set Target Depth/Attitude
  17. Send GPS position
  18. Send rangefinder/computer vision distance measurement to the autopilot

Autopilot (E.g: Pixhawk) connected to the computer via serial

include

Run pyMavlink on the surface computer

include

Run pyMavlink on the companion computer

include

Send Message to QGroundControl

include

Arm/Disarm the vehicle

include

Change flight mode

include

Send RC (Joystick)

include

Send Manual Control

include

Read all parameters

include

Read and write parameters

include

Receive data and filter by message type

include

Request message interval

include

Control Camera Gimbal

include

Set Servo PWM

include

Advanced Servo/Gripper Example

include

Set Target Depth/Attitude

include

Send GPS position

include

Send rangefinder/computer vision distance measurement to the autopilot

include