mavsdk::Action Class Reference

#include: action.h


Enable simple actions such as arming, taking off, and landing.

Public Types

Type Description
enum Result Possible results returned for action requests.
std::function< void(Result)> result_callback_t Callback type for asynchronous Action calls.
std::function< void(Result, float)> altitude_callback_t Callback type for get_takeoff_altitude_async.
std::function< void(Result, float)> speed_callback_t Callback type for get_maximum_speed_async.
std::function< void(Result, float)> relative_altitude_m_callback_t Callback type for get_return_to_launch_altitude_async.

Public Member Functions

Type Name Description
  Action (System & system) Constructor. Creates the plugin for a specific System.
  ~Action () Destructor (internal use only).
  Action (const Action &)=delete Copy constructor (object is not copyable).
void arm_async (const result_callback_t callback) Send command to arm the drone.
Result arm () const Synchronous wrapper for arm_async().
void disarm_async (const result_callback_t callback) Send command to disarm the drone.
Result disarm () const Synchronous wrapper for disarm_async().
void takeoff_async (const result_callback_t callback) Send command to take off and hover.
Result takeoff () const Synchronous wrapper for takeoff_async().
void land_async (const result_callback_t callback) Send command to land at the current position.
Result land () const Synchronous wrapper for land_async().
void reboot_async (const result_callback_t callback) Send command to reboot the drone components.
Result reboot () const Synchronous wrapper for reboot_async().
void shutdown_async (const result_callback_t callback)

  • Send command to shut down the drone components.

  • </ul> Result | shutdown () const | Synchronous wrapper for shutdown_async(). void | kill_async (const result_callback_t callback) | Send command to kill the drone. Result | kill () const | Synchronous wrapper for kill_async(). void | return_to_launch_async (const result_callback_t callback) | Send command to return to the launch (takeoff) position and land. Result | return_to_launch () const | Synchronous wrapper for return_to_launch_async(). void | goto_location_async (double latitude_deg, double longitude_deg, float absolute_altitude_m, float yaw_deg, const result_callback_t callback) |

    • Send command to move the vehicle to a specific global position.

    • </ul> Result | goto_location (double latitude_deg, double longitude_deg, float absolute_altitude_m, float yaw_deg)const | Synchronous wrapper for goto_location_async(). void | transition_to_fixedwing_async (const result_callback_t callback) | Send command to transition the drone to fixedwing. Result | transition_to_fixedwing () const | Synchronous wrapper for transition_to_fixedwing_async(). void | transition_to_multicopter_async (const result_callback_t callback) | Send command to transition the drone to multicopter. Result | transition_to_multicopter () const | Synchronous wrapper for transition_to_multicopter_async(). void | get_takeoff_altitude_async (const altitude_callback_t callback) | Get the takeoff altitude (in meters above ground). std::pair< Result, float > | get_takeoff_altitude () const | Synchronous wrapper for get_takeoff_altitude_async(). void | set_takeoff_altitude_async (float altitude, const result_callback_t callback) | Set takeoff altitude (in meters above ground). Result | set_takeoff_altitude (float altitude)const | Synchronous wrapper for set_takeoff_altitude_async(). void | get_maximum_speed_async (const speed_callback_t callback) | Get the vehicle maximum speed (in metres/second). std::pair< Result, float > | get_maximum_speed () const | Synchronous wrapper for get_maximum_speed_async(). void | set_maximum_speed_async (float speed, const result_callback_t callback) | Set vehicle maximum speed (in metres/second). Result | set_maximum_speed (float speed)const | Synchronous wrapper for set_maximum_speed_async(). void | get_return_to_launch_altitude_async (const relative_altitude_m_callback_t callback) | Get the return to launch minimum return altitude (in meters). std::pair< Result, float > | get_return_to_launch_altitude () const | Synchronous wrapper for get_return_to_launch_altitude_async(). void | set_return_to_launch_altitude_async (float relative_altitude_m, const result_callback_t callback) | Set the return to launch minimum return altitude (in meters). Result | set_return_to_launch_altitude (float relative_altitude_m)const | Synchronous wrapper for set_return_to_launch_altitude_async(). const Action & | operator= (const Action &)=delete | Equality operator (object is not copyable).

      Static Public Member Functions

      Type Name Description
      const char * result_str (Result result) Returns a human-readable English string for a Result.

      Constructor & Destructor Documentation

      Action()

      mavsdk::Action::Action(System &system)
      

      Constructor. Creates the plugin for a specific System.

      The plugin is typically created as shown below:

      auto action = std::make_shared<Action>(system);
      

      Parameters

      • System& system - The specific system associated with this plugin.

      ~Action()

      mavsdk::Action::~Action()
      

      Destructor (internal use only).

      Action()

      mavsdk::Action::Action(const Action &)=delete
      

      Copy constructor (object is not copyable).

      Parameters

      Member Typdef Documentation

      typedef result_callback_t

      typedef std::function<void(Result)> mavsdk::Action::result_callback_t
      

      Callback type for asynchronous Action calls.

      typedef altitude_callback_t

      typedef std::function<void(Result, float)> mavsdk::Action::altitude_callback_t
      

      Callback type for get_takeoff_altitude_async.

      typedef speed_callback_t

      typedef std::function<void(Result, float)> mavsdk::Action::speed_callback_t
      

      Callback type for get_maximum_speed_async.

      typedef relative_altitude_m_callback_t

      typedef std::function<void(Result, float)> mavsdk::Action::relative_altitude_m_callback_t
      

      Callback type for get_return_to_launch_altitude_async.

      Member Enumeration Documentation

      enum Result

      Possible results returned for action requests.

      Value Description
      Unknown Unknown error.
      Success Success: the action command was accepted by the vehicle.
      NoSystem No system is connected.
      ConnectionError Connection error.
      Busy Vehicle is busy.
      CommandDenied Command refused by vehicle.
      CommandDeniedLandedStateUnknown Command refused because landed state is unknown.
      CommandDeniedNotLanded Command refused because vehicle not landed.
      Timeout Request timed out.
      VtolTransitionSupportUnknown Hybrid/VTOL transition refused because VTOL support is unknown.
      NoVtolTransitionSupport Vehicle does not support hybrid/VTOL transitions.
      ParameterError Error getting or setting parameter.

      Member Function Documentation

      arm_async()

      void mavsdk::Action::arm_async(const result_callback_t callback)
      

      Send command to arm the drone.

      Arming a drone normally causes motors to spin at idle. Before arming take all safety precautions and stand clear of the drone!

      Parameters

      arm()

      Result mavsdk::Action::arm() const
      

      Synchronous wrapper for arm_async().

      Returns

      Result - Result of request.

      disarm_async()

      void mavsdk::Action::disarm_async(const result_callback_t callback)
      

      Send command to disarm the drone.

      This will disarm a drone that considers itself landed. If flying, the drone should reject the disarm command. Disarming means that all motors will stop.

      Parameters

      disarm()

      Result mavsdk::Action::disarm() const
      

      Synchronous wrapper for disarm_async().

      Returns

      Result - Result of request.

      takeoff_async()

      void mavsdk::Action::takeoff_async(const result_callback_t callback)
      

      Send command to take off and hover.

      This switches the drone into position control mode and commands it to take off and hover at the takeoff altitude.

      Note that the vehicle must be armed before it can take off.

      Parameters

      takeoff()

      Result mavsdk::Action::takeoff() const
      

      Synchronous wrapper for takeoff_async().

      Returns

      Result - Result of request.

      land_async()

      void mavsdk::Action::land_async(const result_callback_t callback)
      

      Send command to land at the current position.

      This switches the drone to 'Land' flight mode.

      Parameters

      land()

      Result mavsdk::Action::land() const
      

      Synchronous wrapper for land_async().

      Returns

      Result - Result of request.

      reboot_async()

      void mavsdk::Action::reboot_async(const result_callback_t callback)
      

      Send command to reboot the drone components.

      This will reboot the autopilot, companion computer, camera and gimbal.

      Parameters

      reboot()

      Result mavsdk::Action::reboot() const
      

      Synchronous wrapper for reboot_async().

      Returns

      Result - Result of request.

      shutdown_async()

      void mavsdk::Action::shutdown_async(const result_callback_t callback)
      
      • Send command to shut down the drone components.

      This will shut down the autopilot, onboard computer, camera and gimbal. This command should only be used when the autopilot is disarmed and autopilots commonly reject it if they are not already ready to shut down.

      Parameters

      shutdown()

      Result mavsdk::Action::shutdown() const
      

      Synchronous wrapper for shutdown_async().

      Returns

      Result - Result of request.

      kill_async()

      void mavsdk::Action::kill_async(const result_callback_t callback)
      

      Send command to kill the drone.

      This will disarm a drone irrespective of whether it is landed or flying. Note that the drone will fall out of the sky if this command is used while flying.

      Parameters

      kill()

      Result mavsdk::Action::kill() const
      

      Synchronous wrapper for kill_async().

      Returns

      Result - Result of request.

      return_to_launch_async()

      void mavsdk::Action::return_to_launch_async(const result_callback_t callback)
      

      Send command to return to the launch (takeoff) position and land.

      This switches the drone into RTL mode which generally means it will rise up to a certain altitude to clear any obstacles before heading back to the launch (takeoff) position and land there.

      Parameters

      return_to_launch()

      Result mavsdk::Action::return_to_launch() const
      

      Synchronous wrapper for return_to_launch_async().

      Returns

      Result - Result of request.

      goto_location_async()

      void mavsdk::Action::goto_location_async(double latitude_deg, double longitude_deg, float absolute_altitude_m, float yaw_deg, const result_callback_t callback)
      
      • Send command to move the vehicle to a specific global position.

      The latitude and longitude are given in degrees (WGS84 frame) and the altitude in meters AMSL (above mean sea level).

      The yaw angle is in degrees (frame is NED, 0 is North, positive is clockwise).

      Parameters

      • double latitude_deg -
      • double longitude_deg -
      • float absolute_altitude_m -
      • float yaw_deg -
      • const result_callback_t callback -

      goto_location()

      Result mavsdk::Action::goto_location(double latitude_deg, double longitude_deg, float absolute_altitude_m, float yaw_deg) const
      

      Synchronous wrapper for goto_location_async().

      Parameters

      • double latitude_deg -
      • double longitude_deg -
      • float absolute_altitude_m -
      • float yaw_deg -

      Returns

      Result - Result of request.

      transition_to_fixedwing_async()

      void mavsdk::Action::transition_to_fixedwing_async(const result_callback_t callback)
      

      Send command to transition the drone to fixedwing.

      The associated action will only be executed for VTOL vehicles (on other vehicle types the command will fail). The command will succeed if called when the vehicle is already in fixedwing mode.

      Parameters

      transition_to_fixedwing()

      Result mavsdk::Action::transition_to_fixedwing() const
      

      Synchronous wrapper for transition_to_fixedwing_async().

      Returns

      Result - Result of request.

      transition_to_multicopter_async()

      void mavsdk::Action::transition_to_multicopter_async(const result_callback_t callback)
      

      Send command to transition the drone to multicopter.

      The associated action will only be executed for VTOL vehicles (on other vehicle types the command will fail). The command will succeed if called when the vehicle is already in multicopter mode.

      Parameters

      transition_to_multicopter()

      Result mavsdk::Action::transition_to_multicopter() const
      

      Synchronous wrapper for transition_to_multicopter_async().

      Returns

      Result - Result of request.

      get_takeoff_altitude_async()

      void mavsdk::Action::get_takeoff_altitude_async(const altitude_callback_t callback)
      

      Get the takeoff altitude (in meters above ground).

      Parameters

      get_takeoff_altitude()

      std::pair<Result, float> mavsdk::Action::get_takeoff_altitude() const
      

      Synchronous wrapper for get_takeoff_altitude_async().

      Returns

       std::pair< Result, float > - Result of request.

      set_takeoff_altitude_async()

      void mavsdk::Action::set_takeoff_altitude_async(float altitude, const result_callback_t callback)
      

      Set takeoff altitude (in meters above ground).

      Parameters

      set_takeoff_altitude()

      Result mavsdk::Action::set_takeoff_altitude(float altitude) const
      

      Synchronous wrapper for set_takeoff_altitude_async().

      Parameters

      • float altitude -

      Returns

      Result - Result of request.

      get_maximum_speed_async()

      void mavsdk::Action::get_maximum_speed_async(const speed_callback_t callback)
      

      Get the vehicle maximum speed (in metres/second).

      Parameters

      get_maximum_speed()

      std::pair<Result, float> mavsdk::Action::get_maximum_speed() const
      

      Synchronous wrapper for get_maximum_speed_async().

      Returns

       std::pair< Result, float > - Result of request.

      set_maximum_speed_async()

      void mavsdk::Action::set_maximum_speed_async(float speed, const result_callback_t callback)
      

      Set vehicle maximum speed (in metres/second).

      Parameters

      set_maximum_speed()

      Result mavsdk::Action::set_maximum_speed(float speed) const
      

      Synchronous wrapper for set_maximum_speed_async().

      Parameters

      • float speed -

      Returns

      Result - Result of request.

      get_return_to_launch_altitude_async()

      void mavsdk::Action::get_return_to_launch_altitude_async(const relative_altitude_m_callback_t callback)
      

      Get the return to launch minimum return altitude (in meters).

      Parameters

      get_return_to_launch_altitude()

      std::pair<Result, float> mavsdk::Action::get_return_to_launch_altitude() const
      

      Synchronous wrapper for get_return_to_launch_altitude_async().

      Returns

       std::pair< Result, float > - Result of request.

      set_return_to_launch_altitude_async()

      void mavsdk::Action::set_return_to_launch_altitude_async(float relative_altitude_m, const result_callback_t callback)
      

      Set the return to launch minimum return altitude (in meters).

      Parameters

      set_return_to_launch_altitude()

      Result mavsdk::Action::set_return_to_launch_altitude(float relative_altitude_m) const
      

      Synchronous wrapper for set_return_to_launch_altitude_async().

      Parameters

      • float relative_altitude_m -

      Returns

      Result - Result of request.

      operator=()

      const Action& mavsdk::Action::operator=(const Action &)=delete
      

      Equality operator (object is not copyable).

      Parameters

      Returns

       const Action & -

      result_str()

      static const char* mavsdk::Action::result_str(Result result)
      

      Returns a human-readable English string for a Result.

      Parameters

      • Result result - The enum value for which a human readable string is required.

      Returns

       const char * - Human readable string for the Result.

      © Dronecode 2017-2019. License: CC BY 4.0            Updated: 2020-03-31 23:21:37

      results matching ""

        No results matching ""