Base class for a mode.
More...
#include <px4_ros2/components/mode.hpp>
|
|
using | ModeID = uint8_t |
| | Mode ID, corresponds to nav_state.
|
| |
|
|
static constexpr ModeID | kModeIDInvalid = 0xff |
| |
|
static constexpr ModeID | kModeIDPosctl = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_POSCTL |
| |
| static constexpr ModeID | kModeIDTakeoff |
| |
|
static constexpr ModeID | kModeIDDescend = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_DESCEND |
| |
|
static constexpr ModeID | kModeIDLand = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_LAND |
| |
|
static constexpr ModeID | kModeIDRtl = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_RTL |
| |
| static constexpr ModeID | kModeIDPrecisionLand |
| |
| static constexpr ModeID | kModeIDLoiter |
| |
|
|
void | setSkipMessageCompatibilityCheck () |
| |
|
void | setSkipSetpointCheck () |
| |
|
void | overrideRegistration (const std::shared_ptr< Registration > ®istration) |
| |
|
void | disableWatchdogTimer () |
| |
|
void | setWatchdogTimeoutCallback (HealthAndArmingChecks::WatchdogTimeoutCallback callback) |
| |
|
bool | defaultMessageCompatibilityCheck () |
| |
◆ checkArmingAndRunConditions()
◆ completed()
| void px4_ros2::ModeBase::completed |
( |
Result |
result | ) |
|
Mode completed signal. Call this when the mode is finished. A mode might never call this, but modes like RTL, Land or Takeoff are expected to signal their completion.
- Parameters
-
◆ deferFailsafes()
| void px4_ros2::ModeBase::deferFailsafes |
( |
bool |
enabled, |
|
|
int |
timeout_s = 0 |
|
) |
| |
Enable/disable deferring failsafes. While enabled (and the mode is active), most failsafes are prevented from being triggered until the given timeout is exceeded. Some failsafes that cannot be prevented:
- the mode cannot run (some mode requirements are not met, such as no position estimate)
- vehicle exceeds attitude limits (can be disabled via PX4 parameters)
- geofence breach, wind limit and flight time limit exceeded
The FMU stores the setting per mode and applies it while the mode is active. It persists across activations until changed, i.e. it is not cleared automatically on deactivation.
Unlike ModeExecutorBase::deferFailsafesSync() this does not wait for the FMU to acknowledge, the request is resent until it is confirmed. Use onFailsafeDeferred() to get notified when the FMU wants to trigger a failsafe while it is being deferred.
- Parameters
-
| enabled | |
| timeout_s | 0=system default, -1=no timeout |
◆ doRegister()
| bool px4_ros2::ModeBase::doRegister |
( |
| ) |
|
Register the mode. Call this once on startup, unless there's an associated executor. This is a blocking method.
- Returns
- true on success
◆ modeRequirements()
Get / modify mode requirements. These are generally automatically set based on selected setpoint types, and are used to prevent arming or trigger failsafes.
◆ onActivate()
| virtual void px4_ros2::ModeBase::onActivate |
( |
| ) |
|
|
inlinevirtual |
Called whenever the mode is activated, also if the vehicle is disarmed
◆ onDeactivate()
| virtual void px4_ros2::ModeBase::onDeactivate |
( |
| ) |
|
|
inlinevirtual |
Called whenever the mode is deactivated, also if the vehicle is disarmed
◆ onFailsafeDeferred()
| virtual void px4_ros2::ModeBase::onFailsafeDeferred |
( |
| ) |
|
|
inlinevirtual |
Called when failsafes are currently being deferred, and the FMU wants to trigger a failsafe.
- See also
- deferFailsafes()
◆ setSetpointUpdateRate()
| void px4_ros2::ModeBase::setSetpointUpdateRate |
( |
float |
rate_hz | ) |
|
Set the update rate when the mode is active. This is set automatically from the configured setpoints, but can be set as needed.
- Parameters
-
| rate_hz | set to 0 to disable |
◆ kModeIDLoiter
| constexpr ModeID px4_ros2::ModeBase::kModeIDLoiter |
|
staticconstexpr |
Initial value:=
px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_LOITER
◆ kModeIDPrecisionLand
| constexpr ModeID px4_ros2::ModeBase::kModeIDPrecisionLand |
|
staticconstexpr |
Initial value:=
px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_PRECLAND
◆ kModeIDTakeoff
| constexpr ModeID px4_ros2::ModeBase::kModeIDTakeoff |
|
staticconstexpr |
Initial value:=
px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_TAKEOFF
The documentation for this class was generated from the following file:
- px4_ros2_cpp/include/px4_ros2/components/mode.hpp