dronecode_sdk::Action Class Reference

#include: action.h


The Action class enables simple actions for a drone such as arming, taking off, and landing.

Synchronous and asynchronous variants of the action methods are supplied.

The action methods send their associated MAVLink commands to the vehicle and complete (return synchronously or callback asynchronously) with an ActionResult value indicating whether the vehicle has accepted or rejected the command, or that there has been some error. If the command is accepted, the vehicle will then start to perform the associated action.

Public Types

Type Description
std::function< void(ActionResult)> result_callback_t Callback type for asynchronous Action calls.

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).
ActionResult arm () const Send command to arm the drone (synchronous).
ActionResult disarm () const Send command to disarm the drone (synchronous).
ActionResult kill () const Send command to kill the drone (synchronous).
ActionResult takeoff () const Send command to take off and hover (synchronous).
ActionResult land () const Send command to land at the current position (synchronous).
ActionResult return_to_launch () const Send command to return to the launch (takeoff) position and land (asynchronous).
ActionResult transition_to_fixedwing () const Send command to transition the drone to fixedwing.
ActionResult transition_to_multicopter () const Send command to transition the drone to multicopter.
void arm_async (result_callback_t callback) Send command to arm the drone (asynchronous).
void disarm_async (result_callback_t callback) Send command to disarm the drone (asynchronous).
void kill_async (result_callback_t callback) Send command to kill the drone (asynchronous).
void takeoff_async (result_callback_t callback) Send command to take off and hover (asynchronous).
void land_async (result_callback_t callback) Send command to land at the current position (asynchronous).
void return_to_launch_async (result_callback_t callback) Send command to return to the launch (takeoff) position and land (asynchronous).
void transition_to_fixedwing_async (result_callback_t callback) Send command to transition the drone to fixedwing (asynchronous).
void transition_to_multicopter_async (result_callback_t callback) Send command to transition the drone to multicopter (asynchronous).
void set_takeoff_altitude (float relative_altitude_m) Set takeoff altitude above ground.
float get_takeoff_altitude_m () const Get the takeoff altitude.
void set_max_speed (float speed_m_s) Set vehicle maximum speed.
float get_max_speed_m_s () const Get the vehicle maximum speed.
const Action & operator= (const Action &)=delete Equality operator (object is not copyable).

Constructor & Destructor Documentation

Action()

dronecode_sdk::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()

dronecode_sdk::Action::~Action()

Destructor (internal use only).

Action()

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

Copy constructor (object is not copyable).

Parameters

Member Typdef Documentation

typedef result_callback_t

typedef std::function<void(ActionResult)> dronecode_sdk::Action::result_callback_t

Callback type for asynchronous Action calls.

Member Function Documentation

arm()

ActionResult dronecode_sdk::Action::arm() const

Send command to arm the drone (synchronous).

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

Returns

ActionResult - ActionResult of request.

disarm()

ActionResult dronecode_sdk::Action::disarm() const

Send command to disarm the drone (synchronous).

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.

Returns

ActionResult - ActionResult of request.

kill()

ActionResult dronecode_sdk::Action::kill() const

Send command to kill the drone (synchronous).

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.

Returns

ActionResult - ActionResult of request.

takeoff()

ActionResult dronecode_sdk::Action::takeoff() const

Send command to take off and hover (synchronous).

This switches the drone into position control mode and commands it to take off and hover at the takeoff altitude (set using set_takeoff_altitude()).

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

Returns

ActionResult - ActionResult of request.

land()

ActionResult dronecode_sdk::Action::land() const

Send command to land at the current position (synchronous).

This switches the drone to Land mode.

Returns

ActionResult - ActionResult of request.

return_to_launch()

ActionResult dronecode_sdk::Action::return_to_launch() const

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

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.

Returns

ActionResult - ActionResult of request.

transition_to_fixedwing()

ActionResult dronecode_sdk::Action::transition_to_fixedwing() const

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 with an ActionResult). The command will succeed if called when the vehicle is already in fixedwing mode.

Returns

ActionResult - ActionResult of request.

transition_to_multicopter()

ActionResult dronecode_sdk::Action::transition_to_multicopter() const

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 with an ActionResult). The command will succeed if called when the vehicle is already in multicopter mode.

Returns

ActionResult - ActionResult of request.

arm_async()

void dronecode_sdk::Action::arm_async(result_callback_t callback)

Send command to arm the drone (asynchronous).

Note that arming a drone normally means that the motors will spin at idle. Therefore, before arming take all safety precautions and stand clear of the drone.

Parameters

disarm_async()

void dronecode_sdk::Action::disarm_async(result_callback_t callback)

Send command to disarm the drone (asynchronous).

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

kill_async()

void dronecode_sdk::Action::kill_async(result_callback_t callback)

Send command to kill the drone (asynchronous).

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

Parameters

takeoff_async()

void dronecode_sdk::Action::takeoff_async(result_callback_t callback)

Send command to take off and hover (asynchronous).

This switches the drone into position control mode and commands it to take off and hover at the takeoff altitude set using set_takeoff_altitude().

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

Parameters

land_async()

void dronecode_sdk::Action::land_async(result_callback_t callback)

Send command to land at the current position (asynchronous).

This switches the drone to Land mode.

Parameters

return_to_launch_async()

void dronecode_sdk::Action::return_to_launch_async(result_callback_t callback)

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

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

transition_to_fixedwing_async()

void dronecode_sdk::Action::transition_to_fixedwing_async(result_callback_t callback)

Send command to transition the drone to fixedwing (asynchronous).

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

Parameters

transition_to_multicopter_async()

void dronecode_sdk::Action::transition_to_multicopter_async(result_callback_t callback)

Send command to transition the drone to multicopter (asynchronous).

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

Parameters

set_takeoff_altitude()

void dronecode_sdk::Action::set_takeoff_altitude(float relative_altitude_m)

Set takeoff altitude above ground.

Parameters

  • float relative_altitude_m - Takeoff altitude relative to takeoff location, in meters.

get_takeoff_altitude_m()

float dronecode_sdk::Action::get_takeoff_altitude_m() const

Get the takeoff altitude.

Returns

 float - takeoff Takeoff altitude relative to ground/takeoff location, in meters.

set_max_speed()

void dronecode_sdk::Action::set_max_speed(float speed_m_s)

Set vehicle maximum speed.

Parameters

  • float speed_m_s - Maximum speed in metres/second.

get_max_speed_m_s()

float dronecode_sdk::Action::get_max_speed_m_s() const

Get the vehicle maximum speed.

Returns

 float - Maximum speed in metres/second.

operator=()

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

Equality operator (object is not copyable).

Parameters

Returns

 const Action & -

© Dronecode 2017. License: CC BY 4.0            Updated: 2018-07-12 03:09:32

results matching ""

    No results matching ""