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 bool defaultMessageCompatibilityCheck();
191 void addSetpointType(SetpointBase* setpoint)
override;
192 void setRequirement(
const RequirementFlags& requirement_flags)
override;
194 friend class ModeExecutorBase;
195 RegistrationSettings getRegistrationSettings()
const;
196 void onAboutToRegister();
199 void unsubscribeVehicleStatus();
200 void vehicleStatusUpdated(
const px4_msgs::msg::VehicleStatus::UniquePtr& msg,
201 bool do_not_activate =
false);
203 void callOnActivate();
204 void callOnDeactivate();
206 void updateSetpointUpdateTimer();
208 void checkSetpointCompatibilityAndRequirements();
209 void setSetpointUpdateRateFromSetpointTypes();
210 void activateSetpointType(
const std::shared_ptr<SetpointBase>& setpoint);
211 void deactivateAllSetpointTypes();
213 std::shared_ptr<Registration> _registration;
215 const Settings _settings;
216 bool _skip_message_compatibility_check{
false};
217 bool _skip_setpoint_check{
false};
219 HealthAndArmingChecks _health_and_arming_checks;
221 rclcpp::Publisher<px4_msgs::msg::ModeCompleted>::SharedPtr _mode_completed_pub;
222 rclcpp::Publisher<px4_msgs::msg::SetpointConfig>::SharedPtr _setpoint_config_pub;
223 SharedSubscriptionCallbackInstance _setpoint_config_reply_sub_cb;
225 SharedSubscriptionCallbackInstance _vehicle_status_sub_cb;
227 bool _is_active{
false};
228 bool _is_armed{
false};
229 bool _completed{
false};
231 float _setpoint_update_rate_hz{0.f};
232 rclcpp::TimerBase::SharedPtr _setpoint_update_timer;
233 rclcpp::Time _last_setpoint_update{};
235 ConfigOverrides _config_overrides;
237 std::vector<std::shared_ptr<SetpointBase>> _setpoint_types;
238 std::vector<SetpointBase*>
240 std::shared_ptr<SetpointBase> _current_activating_setpoint;
Definition context.hpp:18