Access to drone information, telemetry and control objects are provided by a number of different plugins. For example, the Action plugin is used to arm, takeoff and land the vehicle, while the Telemetry plugin can be used to query the vehicle GPS status, flight mode, etc. A separate plugin instance must be created for each system that needs it.
All plugins are declared/used in the same way. This topic uses the
Actionplugin for the purposes of the demonstration.
To use a plugin first link the plugin library into the application. Do this by adding it to the
target_link_libraries section of the app's cmake build definition file:
target_link_libraries(your_executable_name mavsdk ... mavsdk_action ... )
Plugins are named using the convention mavsdk_plugin_name.so. For more information see Building C++ Apps
In the application source code:
#includethe header file for the plugin.
- Create a connection to a
Systemobject (below named:
- Make a shared pointer to the plugin object, specifying the
Systemit is to be used with:
auto action = std::make_shared<Action>(system);
- The pointer can then be used to invoke actions on the specified system. For example, to takeoff you would call the API as shown: