77 static constexpr ModeID kModeIDInvalid = 0xff;
79 static constexpr ModeID kModeIDPosctl = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_POSCTL;
80 static constexpr ModeID kModeIDTakeoff =
81 px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_TAKEOFF;
82 static constexpr ModeID kModeIDDescend = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_DESCEND;
83 static constexpr ModeID kModeIDLand = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_LAND;
84 static constexpr ModeID kModeIDRtl = px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_RTL;
85 static constexpr ModeID kModeIDPrecisionLand =
86 px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_PRECLAND;
87 static constexpr ModeID kModeIDLoiter =
88 px4_msgs::msg::VehicleStatus::NAVIGATION_STATE_AUTO_LOITER;
92 Settings(std::string mode_name) :
name(std::move(mode_name)) {}
101 Settings& activateEvenWhileDisarmed(
bool activate)
106 Settings& replaceInternalMode(
ModeID mode)
111 Settings& preventArming(
bool prevent)
116 Settings& userSelectable(
bool selectable)
123 ModeBase(rclcpp::Node& node, Settings settings,
const std::string& topic_namespace_prefix =
"");
124 ModeBase(
const ModeBase&) =
delete;
156 virtual void updateSetpoint(
float dt_s) {}
169 bool isArmed()
const {
return _is_armed; }
171 bool isActive()
const {
return _is_active; }
173 ConfigOverrides& configOverrides() {
return _config_overrides; }
182 void setSkipMessageCompatibilityCheck() { _skip_message_compatibility_check =
true; }
183 void setSkipSetpointCheck() { _skip_setpoint_check =
true; }
184 void overrideRegistration(
const std::shared_ptr<Registration>& registration);
186 void disableWatchdogTimer() { _health_and_arming_checks.disableWatchdogTimer(); }
188 void setWatchdogTimeoutCallback(HealthAndArmingChecks::WatchdogTimeoutCallback callback)
193 bool defaultMessageCompatibilityCheck();
196 void addSetpointType(SetpointBase* setpoint)
override;
197 void setRequirement(
const RequirementFlags& requirement_flags)
override;
199 friend class ModeExecutorBase;
200 RegistrationSettings getRegistrationSettings()
const;
201 void onAboutToRegister();
204 void unsubscribeVehicleStatus();
205 void vehicleStatusUpdated(
const px4_msgs::msg::VehicleStatus::UniquePtr& msg,
206 bool do_not_activate =
false);
208 void callOnActivate();
209 void callOnDeactivate();
211 void updateSetpointUpdateTimer();
213 void checkSetpointCompatibilityAndRequirements();
214 void setSetpointUpdateRateFromSetpointTypes();
215 void activateSetpointType(
const std::shared_ptr<SetpointBase>& setpoint);
216 void deactivateAllSetpointTypes();
218 std::shared_ptr<Registration> _registration;
220 const Settings _settings;
221 bool _skip_message_compatibility_check{
false};
222 bool _skip_setpoint_check{
false};
224 HealthAndArmingChecks _health_and_arming_checks;
226 rclcpp::Publisher<px4_msgs::msg::ModeCompleted>::SharedPtr _mode_completed_pub;
227 rclcpp::Publisher<px4_msgs::msg::SetpointConfig>::SharedPtr _setpoint_config_pub;
228 SharedSubscriptionCallbackInstance _setpoint_config_reply_sub_cb;
230 SharedSubscriptionCallbackInstance _vehicle_status_sub_cb;
232 bool _is_active{
false};
233 bool _is_armed{
false};
234 bool _completed{
false};
236 float _setpoint_update_rate_hz{0.f};
237 rclcpp::TimerBase::SharedPtr _setpoint_update_timer;
238 rclcpp::Time _last_setpoint_update{};
240 ConfigOverrides _config_overrides;
242 std::vector<std::shared_ptr<SetpointBase>> _setpoint_types;
243 std::vector<SetpointBase*>
245 std::shared_ptr<SetpointBase> _current_activating_setpoint;
Definition context.hpp:18