mavsdk::MavlinkDirect Class Reference ​
#include: mavlink_direct.h
Enable direct MAVLink communication using libmav.
Data Structures ​
struct MavlinkMessage
Public Types ​
| Type | Description |
|---|---|
| enum Result | Possible results returned for action requests. |
| std::function< void(Result)> ResultCallback | Callback type for asynchronous MavlinkDirect calls. |
| std::function< void(MavlinkMessage)> MessageCallback | Callback type for subscribe_message. |
| Handle< MavlinkMessage > MessageHandle | Handle type for subscribe_message. |
Public Member Functions ​
| Type | Name | Description |
|---|---|---|
| Â | MavlinkDirect (System & system) | Constructor. Creates the plugin for a specific System. |
| Â | MavlinkDirect (std::shared_ptr< System > system) | Constructor. Creates the plugin for a specific System. |
| Â | ~MavlinkDirect () override | Destructor (internal use only). |
| Â | MavlinkDirect (const MavlinkDirect & other) | Copy constructor. |
| Result | send_message (MavlinkMessage message)const | Send a MAVLink message directly to the system. |
| MessageHandle | subscribe_message (std::string message_name, const MessageCallback & callback) | Subscribe to incoming MAVLink messages. |
| void | unsubscribe_message (MessageHandle handle) | Unsubscribe from subscribe_message. |
| Result | load_custom_xml (std::string xml_content)const | Load custom MAVLink message definitions from XML. |
| const MavlinkDirect & | operator= (const MavlinkDirect &)=delete | Equality operator (object is not copyable). |
Constructor & Destructor Documentation ​
MavlinkDirect() ​
mavsdk::MavlinkDirect::MavlinkDirect(System &system)Constructor. Creates the plugin for a specific System.
The plugin is typically created as shown below:
auto mavlink_direct = MavlinkDirect(system);Parameters
- System& system - The specific system associated with this plugin.
MavlinkDirect() ​
mavsdk::MavlinkDirect::MavlinkDirect(std::shared_ptr< System > system)Constructor. Creates the plugin for a specific System.
The plugin is typically created as shown below:
auto mavlink_direct = MavlinkDirect(system);Parameters
- std::shared_ptr< System > system - The specific system associated with this plugin.
~MavlinkDirect() ​
mavsdk::MavlinkDirect::~MavlinkDirect() overrideDestructor (internal use only).
MavlinkDirect() ​
mavsdk::MavlinkDirect::MavlinkDirect(const MavlinkDirect &other)Copy constructor.
Parameters
- const MavlinkDirect& other -
Member Typdef Documentation ​
typedef ResultCallback ​
using mavsdk::MavlinkDirect::ResultCallback = std::function<void(Result)>Callback type for asynchronous MavlinkDirect calls.
typedef MessageCallback ​
using mavsdk::MavlinkDirect::MessageCallback = std::function<void(MavlinkMessage)>Callback type for subscribe_message.
typedef MessageHandle ​
using mavsdk::MavlinkDirect::MessageHandle = Handle<MavlinkMessage>Handle type for subscribe_message.
Member Enumeration Documentation ​
enum Result ​
Possible results returned for action requests.
| Value | Description |
|---|---|
Unknown | Unknown result. |
Success | Request succeeded. |
Error | Error. |
InvalidMessage | Invalid MAVLink message. |
InvalidField | Invalid field name or value. |
ConnectionError | Connection error. |
NoSystem | No system connected. |
Timeout | Request timed out. |
Member Function Documentation ​
send_message() ​
Result mavsdk::MavlinkDirect::send_message(MavlinkMessage message) constSend a MAVLink message directly to the system.
This allows sending any MAVLink message with full control over the message content.
This function is blocking.
Parameters
- MavlinkMessage message -
Returns
 Result - Result of request.
subscribe_message() ​
MessageHandle mavsdk::MavlinkDirect::subscribe_message(std::string message_name, const MessageCallback &callback)Subscribe to incoming MAVLink messages.
This provides direct access to incoming MAVLink messages. Use an empty string in message_name to subscribe to all messages, or specify a message name (e.g., "HEARTBEAT") to filter for specific message types.
Parameters
- std::string message_name -
- const MessageCallback& callback -
Returns
 MessageHandle -
unsubscribe_message() ​
void mavsdk::MavlinkDirect::unsubscribe_message(MessageHandle handle)Unsubscribe from subscribe_message.
Parameters
- MessageHandle handle -
load_custom_xml() ​
Result mavsdk::MavlinkDirect::load_custom_xml(std::string xml_content) constLoad custom MAVLink message definitions from XML.
This allows loading custom MAVLink message definitions at runtime, extending the available message types beyond the built-in definitions.
This function is blocking.
Parameters
- std::string xml_content -
Returns
 Result - Result of request.
operator=() ​
const MavlinkDirect & mavsdk::MavlinkDirect::operator=(const MavlinkDirect &)=deleteEquality operator (object is not copyable).
Parameters
- const MavlinkDirect& -
Returns
 const MavlinkDirect & -

