MAVSDK
MAVSDK copied to clipboard
Provide Autopilot/Server functionality for MAVLink services
It would be exceptionally useful to have MAVSDK provide server functionality for MAVLink microservices.
There is currently a gap missing in MAVLink, the raw data types are provided by the MAVLink headers but the implementation of the microservices (Command, Mission, Heartbeat, Parameters etc) is still up to the user to implement. This can easily lead to fragmentation of the standard with the services. It also makes MAVLink integration into existing systems difficult.
MAVSDK does a good job of tackling this from a GCS/Companion side, but API is not currently suitable for the autopilot side as it was built on the assumption we're communicating with a MAVLink autopilot that implements the services we require. MAVSDK connects as a client.
There is a real case for server implementation in MAVSDK along these lines and MAVSDK could be used as a basis for a MAVLink autopilot. While obviously not for embedded platforms, there are certainly use-cases for this on non-PX4/Ardupilot autopilot systems but also in testing frameworks. In addition MAVSDK could bridge existing autopilot systems with MAVLink.
I propose MAVSDK implement the following plugins:
- Mission server (
MISSION_REQUEST_INT
workflow from autopilot side) - Command server (subscribe to commands, ack, etc)
- Parameter server
- Message server (
MAV_CMD_REQUEST_MESSAGE
?MAV_CMD_SET_MESSAGE_INTERVAL
support?)
I've recently documented what MAVLink messages + parameters MAVSDK requires in order to function, I can list these as it would probably be a useful starting point for these services.
Here is a big list of messages used by MAVSDK in action, telemetry & mission plugins.
Parameters required to set health OK in Telemetry:
- CAL_GYRO0_ID // Set to true once gyro is stabilised. (true if doesn't exist)
- CAL_ACC0_ID // Set to true once accelerometer is stabilised (true if doesn't exist)
- CAL_MAG0_ID // Set to true once magnetometer is stabilised (true if doesn't exist)
Telemetry Messages
------------------
+----------------------+----------------------+----------------------+----------------------+----------------------+
| Message | ID | Direction | Description | Notes |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| HEARTBEAT | #0 | Bidirectional | Heartbeat message is | Autopilot should |
| | | | used to register | emit heartbeats |
| | | | MAVLink compatible | periodically (>1hz). |
| | | | systems | This is used to |
| | | | | identify autopilot |
| | | | | version and vehicle |
| | | | | frame type (e.g. *M |
| | | | | AV_TYPE_SURFACE_BOA |
| | | | | T*) |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| AUTOPILOT_VERSION | #148 | Autopilot to | Version and | Used to register |
| | | | capability of | autopilot system. |
| | | | autopilot software. | Requested via *MAV_ |
| | | | | CMD_REQUEST_AUTOPIL |
| | | | | OT_CAPABILITIES* |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| HOME_POSITION | #242 | Autopilot to MAVSDK | Send the vehicle | Required for Health |
| | | | home (recovery) | OK |
| | | | position | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| LOCAL_POSITION_NED | #32 | Autopilot to MAVSDK | Vehicle position | Must be sent at |
| | | | relative to startup | minimum 1hz if |
| | | | global position | available. Required |
| | | | | for MAVSDK Health OK |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| GPS_RAW_INT | #24 | Autopilot to MAVSDK | Vehicle raw global | Required for MAVSDK |
| | | | position from GPS | Health OK (>1 Hz) |
| | | | sensor | once GPS OK |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| GLOBAL_POSITION_INT | #33 | Autopilot to MAVSDK | Vehicle | Required for MAVSDK |
| | | | filtered/estimated | Health OK (>1 Hz) |
| | | | global position | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| GPS_GLOBAL_ORIGIN | #49 | Autopilot to MAVSDK | GPS of local origin | Required for MAVSDK |
| | | | (local 0,0,0) | Health OK |
| | | | position | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
Parameter Messages
------------------
+----------------------+----------------------+----------------------+----------------------+----------------------+
| Message | ID | Direction | Description | Notes |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_REQUEST_READ | #20 | MAVSDK to Autopilot | Used to request a | |
| | | | parameter value | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_VALUE | #22 | Bidirectional | Used to deliver a | |
| | | | requested parameter | |
| | | | value | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_SET | #23 | MAVSDK to Autopilot | Used to set a | |
| | | | parameter value on | |
| | | | the target | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_EXT_VALUE | #322 | Bidirectional | Used to deliver a | |
| | | | requested extended | |
| | | | parameter value | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_EXT_SET | #323 | MAVSDK to Autopilot | Used to set an | |
| | | | extended parameter | |
| | | | value on the target | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_EXT_REQUEST_R | #320 | MAVSDK to Autopilot | Used to request an | |
| EAD | | | extended parameter | |
| | | | value | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| PARAM_EXT_ACK | #324 | Autopilot to MAVSDK | Acknowledgment | |
| | | | response to | |
| | | | *PARAM_EXT_SET* | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
Command Messages
----------------
+----------------------+----------------------+----------------------+----------------------+----------------------+
| Message | ID | Direction | Description | Notes |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| COMMAND_LONG | #76 | MAVSDK to Autopilot | Used to command the | *COMMAND_LONG* has |
| | | | autopilot to perform | different |
| | | | an action with long | functionality |
| | | | type parameters | depending on the |
| | | | | command id |
| | | | | transmitted. Refer |
| | | | | to command service |
| | | | | MAVLink |
| | | | | documentation |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| COMMAND_INT | #75 | MAVSDK to Autopilot | Used to command the | *COMMAND_INT* has |
| | | | autopilot to perform | different |
| | | | an action with int | functionality |
| | | | type parameters | depending on the |
| | | | | command id |
| | | | | transmitted. Refer |
| | | | | to command service |
| | | | | MAVLink |
| | | | | documentation |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| COMMAND_ACK | #77 | Autopilot to MAVSDK | Used to acknowledge | |
| | | | receipt of a command | |
| | | | and provide the | |
| | | | result | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
Mission Messages
----------------
+----------------------+----------------------+----------------------+----------------------+----------------------+
| Message | ID | Direction | Description | Notes |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_COUNT | #43 | MAVSDK to Autopilot | Sets the number of | |
| | | | items in the | |
| | | | incoming mission | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_REQUEST_INT | #51 | Autopilot to MAVSDK | Used to request | |
| | | | mission item | |
| | | | information | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_ITEM_INT | #73 | MAVSDK to Autopilot | Add a mission Item | |
| | | | to the current | |
| | | | mission | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_ACK | #47 | Autopilot to MAVSDK | Sent when a mission | |
| | | | has been | |
| | | | acknowledged | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_ITEM_REACHED | #46 | Autopilot to MAVSDK | Announces a mission | |
| | | | item has been | |
| | | | reached | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_CURRENT | #42 | Autopilot to MAVSDK | Announces current | Transmitted |
| | | | active Mission | regularly (>1hz) |
| | | | sequence | from autopilot |
+----------------------+----------------------+----------------------+----------------------+----------------------+
| MISSION_CLEAR_ALL | #45 | MAVSDK to Autopilot | Clears specified | Can be main mission |
| | | | mission type from | or fence mission |
| | | | autopilot | |
+----------------------+----------------------+----------------------+----------------------+----------------------+
Command Types Used In MAVSDK
-----------------------------------------------
Command Types used in GCS
^^^^^^^^^^^^^^^^^^^^^^^^^
+---------------------------+---------------------------+---------------------------+---------------------------+
| Command Name | Command ID (MAV_CMD) | Description | Notes |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_COMPONENT_ARM_DI | #400 | Arms or disarms the | Used prior to launching a |
| SARM | | vehicle | mission |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_DO_SET_MODE | #176 | Change the autopilot | GCS uses this to enable |
| | | system mode | Mission mode. |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_REQUEST_MESSAGE | #512 | Single-shot request of | GCS uses this message to |
| | | specific MAVLink message | request specific MAVLink |
| | | | messages |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_SET_MESSAGE_INTE | #511 | Set repeat interval of | GCS uses this message to |
| RVAL | | specific MAVLink message | request specific MAVLink |
| | | | messages at a regular |
| | | | interval |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_REQUEST_AUTOPILO | #520 | Request autopilot | MAVSDK uses this CMD to |
| T_CAPABILITIES | | capabilities | identify the autopilot |
| | | | via the |
| | | | *AUTOPILOT_VERSION* |
| | | | message |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_NAV_WAYPOINT | #16 | Navigate to specfied | Used in MAVLink missions. |
| | | waypoint (Lat/Lon/Accept | COMMAND_INT, param5 |
| | | Radius/Hold Time) | latitude in degrees * |
| | | | 10^7, param6 longitude in |
| | | | degrees * 10^7 |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_NAV_LOITER_UNLIM | #19 | Loiter at the specfied | Used in MAVLink missions. |
| | | lat/lon/heading/radius | |
| | | for a unlimited period | |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_DO_CHANGE_SPEED | #178 | Change speed and/or | Used in MAVLink missions. |
| | | throttle | |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_NAV_FENCE_POLYGO | #5002 | Fence vertex for an | |
| N_VERTEX_EXCLUSION | | exclusion polygon. The | |
| | | vehicle must stay outside | |
| | | this area. | |
+---------------------------+---------------------------+---------------------------+---------------------------+
| MAV_CMD_DO_REPOSITION | #192 | Reposition the vehicle to | Is used for debugging |
| | | target co-ordinates | guidance. |
+---------------------------+---------------------------+---------------------------+---------------------------+
@julianoes: About CAL_GYRO0_ID, CAL_ACC0_ID and CAL_MAG0_ID: wasn't that supposed to be replaced by the so-called "events interface" at some point? Do you know anything about that?
@JonasVautherin I think the calibration check and the telemetry health flags should be covered by SYS_STATUS.
Server functionality has been added: (after much hardwork :tada:)
mission_raw_server
#1488
action_server
https://github.com/mavlink/MAVSDK/pull/1491
telemetry_server
https://github.com/mavlink/MAVSDK/pull/1482
plugin_server
https://github.com/mavlink/MAVSDK/pull/1473
Documentation and examples required: