Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
auterion::Mode Class Reference

Defines a mode to control the vehicle using a (set) of setpoint types. More...

#include <auterion_sdk/control/mode.hpp>

Public Member Functions

 Mode (SDK &sdk, const std::string &mode_name, const std::vector< ModalityConfig > &controls, ModeConfiguration config=ModeConfiguration{})
 Constructor to initialize a mode. More...
 
void onActivate (const std::function< void()> &callback)
 Sets a callback function to be called when the mode is activated. More...
 
void onDeactivate (const std::function< void()> &callback)
 Sets a callback function to be called when the mode is deactivated. More...
 
void onUpdateSetpoint (const std::function< Setpoint(float)> &callback)
 Sets a callback function to be called at periodically at the update frequency of the mode. More...
 
auterion::ManualControlInput lastManualControlInput () const
 

Detailed Description

Defines a mode to control the vehicle using a (set) of setpoint types.

Example usage:

To create your own flight mode:

class MyAppWithMode
{
private:
public:
MyAppWithMode(auterion::SDK &sdk) : _mode(sdk, "My Mode", {
}) {};
};
Defines a mode to control the vehicle using a (set) of setpoint types.
Definition: mode.hpp:221
SDK execution class. All callbacks are called on the same thread.
Definition: auterion.hpp:45
Sets controller's default speed limits for local goto setpoint.
Definition: local_frame_goto_control.hpp:98

To register callbacks to specific events in the mode life cycle:

_mode.onActivate([this]() {
// Gets called when the user activates this mode by switching into it
});
_mode.onDeactivate([]() {
// Gets called when user or system deactives this modes by switching to another mode
});
_mode.onUpdateSetpoint([this](float dt_s) -> auterion::Setpoint {
// Gets called regularly while mode is active.
// Here, any of the setpoint types specified in the constructor
// can be returned. The vehicle will then try to follow the returned setpoints.
return auterion::multicopter::LocalFrameGotoSetpoint{}.withPosition({x, y, z});
});
Represents a setpoint for controlling the local frame position and heading.
Definition: local_frame_goto_control.hpp:88
std::variant< RateSetpoint, AttitudeSetpoint, multicopter::LocalFrameDynamicsSetpoint, multicopter::BodyFrameDynamicsSetpoint, multicopter::LocalFrameGotoSetpoint, multicopter::GlobalFrameGotoSetpoint > Setpoint
Type alias for representing various types of setpoints.
Definition: control.hpp:66

Constructor & Destructor Documentation

◆ Mode()

auterion::Mode::Mode ( SDK sdk,
const std::string &  mode_name,
const std::vector< ModalityConfig > &  controls,
ModeConfiguration  config = ModeConfiguration{} 
)

Constructor to initialize a mode.

Parameters
sdkReference to the SDK instance.
mode_nameName of the mode.
controlsVector of ModalityConfig objects specifying which setpoints types the mode will output.
configOptional ModeConfiguration specifying mode requirements and capabilities.

Member Function Documentation

◆ onActivate()

void auterion::Mode::onActivate ( const std::function< void()> &  callback)

Sets a callback function to be called when the mode is activated.

Parameters
callbackFunction to call on mode activation.

◆ onDeactivate()

void auterion::Mode::onDeactivate ( const std::function< void()> &  callback)

Sets a callback function to be called when the mode is deactivated.

Parameters
callbackFunction to call on mode deactivation.

◆ onUpdateSetpoint()

void auterion::Mode::onUpdateSetpoint ( const std::function< Setpoint(float)> &  callback)

Sets a callback function to be called at periodically at the update frequency of the mode.

The ModalityConfig(s) used to instantiate the mode determine the update frequency of the mode, as well as the expected return Setpoint types of the callback function passed to this method.

Parameters
callbackFunction to call to update setpoints.

The documentation for this class was generated from the following file: