From debe3dab6141f2b320c4d4ebb08f7621bb23c25c Mon Sep 17 00:00:00 2001 From: Damien SIX Date: Fri, 5 Jul 2024 11:44:52 +0200 Subject: [PATCH] feat: new setting to allow arming with executor --- px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp | 1 + px4_ros2_cpp/src/components/mode_executor.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp b/px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp index 0dbb3fc..eda1ed4 100644 --- a/px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp +++ b/px4_ros2_cpp/include/px4_ros2/components/mode_executor.hpp @@ -35,6 +35,7 @@ class ModeExecutorBase struct Settings { bool activate_immediately{false}; ///< If set activate the mode (and executor) immediately. Only use this for fully autonomous executors that also arm the vehicle + bool is_allowed_to_arm{false}; ///< If set, the executor is allowed to arm the vehicle }; enum class DeactivateReason diff --git a/px4_ros2_cpp/src/components/mode_executor.cpp b/px4_ros2_cpp/src/components/mode_executor.cpp index be1ba50..e3dabee 100644 --- a/px4_ros2_cpp/src/components/mode_executor.cpp +++ b/px4_ros2_cpp/src/components/mode_executor.cpp @@ -291,7 +291,7 @@ void ModeExecutorBase::vehicleStatusUpdated(const px4_msgs::msg::VehicleStatus:: _is_armed = msg->arming_state == px4_msgs::msg::VehicleStatus::ARMING_STATE_ARMED; const bool wants_to_activate_immediately = _settings.activate_immediately && _was_never_activated; const bool is_in_charge = id() == msg->executor_in_charge && - (_is_armed || wants_to_activate_immediately); + (_is_armed || wants_to_activate_immediately || _settings.is_allowed_to_arm); const bool changed_to_armed = !was_armed && _is_armed; bool got_activated = false;