36#include <auterion_sdk/auterion.hpp>
37#include <auterion_sdk/control/control.hpp>
43class HealthAndArmingCheckReporter;
75 bool needs_angular_velocity{
false};
76 bool needs_attitude{
false};
77 bool needs_local_altitude{
false};
78 bool needs_local_position{
false};
79 bool needs_local_position_relaxed{
false};
80 bool needs_global_position{
false};
81 bool needs_valid_mission{
false};
82 bool needs_valid_home{
false};
83 bool needs_manual_control_input{
false};
84 bool can_prevent_arming{
false};
85 bool user_selectable{
true};
87 ModeConfiguration merge(
const ModeConfiguration& other)
const {
88 ModeConfiguration config = *
this;
89 config.needs_angular_velocity =
90 config.needs_angular_velocity || other.needs_angular_velocity;
91 config.needs_attitude = config.needs_attitude || other.needs_attitude;
92 config.needs_local_altitude = config.needs_local_altitude || other.needs_local_altitude;
93 config.needs_local_position = config.needs_local_position || other.needs_local_position;
94 config.needs_local_position_relaxed =
95 config.needs_local_position_relaxed || other.needs_local_position_relaxed;
96 config.needs_global_position = config.needs_global_position || other.needs_global_position;
97 config.needs_valid_mission = config.needs_valid_mission || other.needs_valid_mission;
98 config.needs_valid_home = config.needs_valid_home || other.needs_valid_home;
99 config.needs_manual_control_input =
100 config.needs_manual_control_input || other.needs_manual_control_input;
101 config.can_prevent_arming = config.can_prevent_arming || other.can_prevent_arming;
102 config.user_selectable = config.user_selectable || other.user_selectable;
118 needs_angular_velocity = needs;
122 ModeConfiguration& needsAttitude(
bool needs =
true) {
123 needs_attitude = needs;
127 ModeConfiguration& needsLocalAltitude(
bool needs =
true) {
128 needs_local_altitude = needs;
132 ModeConfiguration& needsLocalPosition(
bool needs =
true) {
133 needs_local_position = needs;
137 ModeConfiguration& needsLocalPositionRelaxed(
bool needs =
true) {
138 needs_local_position_relaxed = needs;
142 ModeConfiguration& needsGlobalPosition(
bool needs =
true) {
143 needs_global_position = needs;
147 ModeConfiguration& needsValidMission(
bool needs =
true) {
148 needs_valid_mission = needs;
152 ModeConfiguration& needsValidHome(
bool needs =
true) {
153 needs_valid_home = needs;
157 ModeConfiguration& needsManualControlInput(
bool needs =
true) {
158 needs_manual_control_input = needs;
162 ModeConfiguration& canPreventArming(
bool can =
true) {
163 can_prevent_arming = can;
167 ModeConfiguration& userSelectable(
bool selectable =
true) {
168 user_selectable = selectable;
180enum class ModeFailureReason {
198 void fail(ModeFailureReason reason);
201 friend class ModeImpl;
202 explicit FailureReporter(px4_ros2::HealthAndArmingCheckReporter& reporter)
203 : _reporter(reporter) {}
205 px4_ros2::HealthAndArmingCheckReporter& _reporter;
217 ModeFailureOther = 100,
227 float roll_input_normalized;
228 float pitch_input_normalized;
229 float yaw_input_normalized;
230 float throttle_input_normalized;
232 float aux1_input_normalized;
233 float aux2_input_normalized;
234 float aux3_input_normalized;
235 float aux4_input_normalized;
236 float aux5_input_normalized;
237 float aux6_input_normalized;
281 std::shared_ptr<ModeImpl> _impl;
293 Mode(
SDK& sdk,
const std::string& mode_name,
const std::vector<ModalityConfig>& controls,
346 [[nodiscard]] ModeConfiguration::PX4Mode::ID
id()
const;
Reports reasons why a mode cannot arm or run, passed to the Mode::canRun() callback.
Definition mode.hpp:190
void fail(ModeFailureReason reason)
Reports a reason why the mode cannot arm or run.
Configuration flags for specifying mode requirements and capabilities.
Definition mode.hpp:54
PX4Mode::ID replace_px4_mode
Definition mode.hpp:71
ModeConfiguration & replacesPX4Mode(PX4Mode::ID px4_mode_id)
Configures a Mode to replace an existing PX4 mode.
Definition mode.hpp:112
Defines a mode to control the vehicle using a (set) of setpoint types.
Definition mode.hpp:279
ModeConfiguration::PX4Mode::ID id() const
Returns the nav_state ID assigned to this mode after registration with PX4.
void canRun(const std::function< void(FailureReporter &)> &callback)
Sets a callback that checks whether the mode is allowed to arm and run, reporting the reasons to the ...
void onDeactivate(const std::function< void()> &callback)
Sets a callback function to be called when the mode is deactivated.
void completed(Result result)
Signal that the mode has finished and hand control back to PX4.
Mode(SDK &sdk, const std::string &mode_name, const std::vector< ModalityConfig > &controls, ModeConfiguration config=ModeConfiguration{})
Constructor to initialize a mode.
void onActivate(const std::function< void()> &callback)
Sets a callback function to be called when the mode is activated.
void onUpdateSetpoint(const std::function< Setpoint(float)> &callback)
Sets a callback function to be called at periodically at the update frequency of the mode.
SDK execution class. All callbacks are called on the same thread.
Definition auterion.hpp:119
std::variant< RateSetpoint, AttitudeSetpoint, multicopter::LocalFrameDynamicsSetpoint, multicopter::BodyFrameDynamicsSetpoint, multicopter::LocalFrameGotoSetpoint, multicopter::GlobalFrameGotoSetpoint, fixedwing::DynamicsSetpoint, fixedwing::GuidanceSetpoint, vtol::TransitionSetpoint > Setpoint
Type alias for representing various types of setpoints.
Definition control.hpp:71
Struct storing PX4 mode IDs.
Definition mode.hpp:59
static const ID kModeIDRtl
PX4 RTL mode.
Definition mode.hpp:67
static const ID kModeIDPrecisionLand
PX4 Precision Land mode.
Definition mode.hpp:68
static const ID kModeIDLand
PX4 Land mode.
Definition mode.hpp:66
static const ID kModeIDInvalid
Invalid mode, will not replace any PX4 mode.
Definition mode.hpp:61
static const ID kModeIDDescend
PX4 Descend mode.
Definition mode.hpp:65
static const ID kModeIDTakeoff
PX4 Takeoff mode.
Definition mode.hpp:64
static const ID kModeIDPosctl
PX4 Position mode.
Definition mode.hpp:63