Skip to content

Commit 03250b5

Browse files
eyeam3bkueng
authored andcommitted
mode: configuration to make a mode not user selectable
1 parent 8cb4268 commit 03250b5

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

px4_ros2_cpp/include/px4_ros2/components/mode.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ class ModeBase : public Context
9393
// NOLINTNEXTLINE allow implicit conversion
9494
Settings(
9595
std::string mode_name, bool want_activate_even_while_disarmed = false,
96-
ModeID request_replace_internal_mode = kModeIDInvalid)
96+
ModeID request_replace_internal_mode = kModeIDInvalid, bool request_user_selectable = true)
9797
: name(std::move(mode_name)), activate_even_while_disarmed(want_activate_even_while_disarmed),
98+
user_selectable(request_user_selectable),
9899
replace_internal_mode(request_replace_internal_mode) {}
99100
std::string name; ///< Name of the mode with length < 25 characters
100101
bool activate_even_while_disarmed{true}; ///< If true, the mode is also activated while disarmed if selected
102+
bool user_selectable{true}; ///< If true, the mode is selectable by the user
101103
ModeID replace_internal_mode{kModeIDInvalid}; ///< Can be used to replace an fmu-internal mode
102104
};
103105

px4_ros2_cpp/src/components/mode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ RegistrationSettings ModeBase::getRegistrationSettings() const
100100
settings.enable_replace_internal_mode = true;
101101
settings.replace_internal_mode = _settings.replace_internal_mode;
102102
}
103+
settings.user_selectable = _settings.user_selectable;
103104

104105
return settings;
105106
}

px4_ros2_cpp/src/components/registration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ bool Registration::doRegister(const RegistrationSettings & settings)
6565
request.enable_replace_internal_mode = settings.enable_replace_internal_mode;
6666
request.replace_internal_mode = settings.replace_internal_mode;
6767
request.activate_mode_immediately = settings.activate_mode_immediately;
68+
request.not_user_selectable = !settings.user_selectable;
6869
request.px4_ros2_api_version = kLatestPX4ROS2ApiVersion;
6970

7071
std::random_device rd;

px4_ros2_cpp/src/components/registration.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct RegistrationSettings
2525
bool enable_replace_internal_mode{false};
2626
px4_ros2::ModeBase::ModeID replace_internal_mode{};
2727
bool activate_mode_immediately{false};
28+
bool user_selectable{true};
2829
};
2930

3031
class Registration

0 commit comments

Comments
 (0)