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 reboot () const Send command to reboot the drone components.
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 goto_location (double latitude_deg, double longitude_deg, float altitude_amsl_m, float yaw_deg) Send command to reposition the vehicle to a specific WGS84 global position.
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).
ActionResult set_takeoff_altitude (float relative_altitude_m) Set takeoff altitude above ground.
std::pair< ActionResult, float > get_takeoff_altitude () const Get the takeoff altitude.
ActionResult set_max_speed (float speed_m_s) Set vehicle maximum speed.
std::pair< ActionResult, float > get_max_speed () const Get the vehicle maximum speed.
ActionResult set_return_to_launch_return_altitude (float relative_altitude_m) Set the return to launch minimum return altitude.
std::pair< ActionResult, float > get_return_to_launch_return_altitude () const Get the return to launch minimum return altitude.
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.

reboot()

ActionResult dronecode_sdk::Action::reboot() const

Send command to reboot the drone components.

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

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.

goto_location()

ActionResult dronecode_sdk::Action::goto_location(double latitude_deg, double longitude_deg, float altitude_amsl_m, float yaw_deg)

Send command to reposition the vehicle to a specific WGS84 global position.

This sends the vehicle to a specified lattitude/longitude/altitude coordinates.

Parameters

  • double latitude_deg - Latitude in degrees
  • double longitude_deg - Longitude in degrees
  • float altitude_amsl_m - Altitude AMSL in meters
  • float yaw_deg - Yaw angle in degrees

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

ActionResult 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.

Returns

ActionResult - Result of request.

get_takeoff_altitude()

std::pair<ActionResult, float> dronecode_sdk::Action::get_takeoff_altitude() const

Get the takeoff altitude.

Returns

 std::pair< ActionResult, float > - A pair containing the result of request and if successful, the takeoff altitude relative to ground/takeoff location, in meters.

set_max_speed()

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

Set vehicle maximum speed.

Parameters

  • float speed_m_s - Maximum speed in metres/second.

Returns

ActionResult - Result of request.

get_max_speed()

std::pair<ActionResult, float> dronecode_sdk::Action::get_max_speed() const

Get the vehicle maximum speed.

Returns

 std::pair< ActionResult, float > - A pair containing the result of the request and if successful, the maximum speed in metres/second.

set_return_to_launch_return_altitude()

ActionResult dronecode_sdk::Action::set_return_to_launch_return_altitude(float relative_altitude_m)

Set the return to launch minimum return altitude.

When return to launch is initiated, the vehicle climbs to the return altitude if it is lower and stays at the current altitude if higher than the return altitude. Then it returns to the home location and lands there.

Parameters

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

Returns

ActionResult - Result of request.

get_return_to_launch_return_altitude()

std::pair<ActionResult, float> dronecode_sdk::Action::get_return_to_launch_return_altitude() const

Get the return to launch minimum return altitude.

Returns

 std::pair< ActionResult, float > - A pair containing the result of the request and if successful, the return altitude relative to takeoff location, in meters.

See Also:

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-09-20 23:28:43

results matching ""

    No results matching ""