Managing Systems/Vehicles (Using Plugins)
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
Action
plugin 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:
#include
the header file for the plugin.#include <mavsdk/plugins/action/action.h>
- Create a connection to a
System
object (below named:system
). - Create the plugin instance, specifying the
System
it is to be used with:auto action = 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:
action.takeoff();