{% include "../archive-notice.html" %}
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.
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.
# 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 mavproxyWith Python and pip installed, run pip install wheel mavproxy.
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_startpageNote that pymavlink.__doc__ will show some information about the package.
This is a record of this example running in python interactive shell:
Pymavlink has 3 types of messages:
command_long_send: To create a raw package<message_name>_send: To send simple mavlink messagesmavutil: Functions to abstract some MAVLink messages
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.255all devices from192.168.1.1to192.168.1.255will receive the data.
- Using the IP
- 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.
- Autopilot connected to the computer via serial
- Run pyMavlink on the surface computer
- Run pyMavlink on the companion computer
- Send Message to QGroundControl
- Arm/Disarm the vehicle
- Change flight mode
- Send RC (Joystick)
- Send Manual Control
- Read all parameters
- Read and write parameters
- Receive data and filter by message type
- Request message interval
- Control Camera Gimbal
- Set Servo PWM
- Advanced Servo/Gripper Example
- Set Target Depth/Attitude
- Send GPS position
- Send rangefinder/computer vision distance measurement to the autopilot