Skip to content

Add support for enable_lifecycle_services parameter in LifecycleNode #5307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion nav2_ros_common/include/nav2_ros_common/lifecycle_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
const std::string & node_name,
const std::string & ns,
const rclcpp::NodeOptions & options = rclcpp::NodeOptions())
: rclcpp_lifecycle::LifecycleNode(node_name, ns, options)
: rclcpp_lifecycle::LifecycleNode(node_name, ns, options, getEnableLifecycleServices(options))
{
// server side never times out from lifecycle manager
this->declare_parameter(bond::msg::Constants::DISABLE_HEARTBEAT_TIMEOUT_PARAM, true);
Expand Down Expand Up @@ -395,6 +395,24 @@
std::unique_ptr<bond::Bond> bond_{nullptr};
double bond_heartbeat_period{0.1};
rclcpp::TimerBase::SharedPtr autostart_timer_;

private:
/**
* @brief Get the enable_lifecycle_services parameter value from NodeOptions
* @param options NodeOptions to check for the parameter
* @return true if lifecycle services should be enabled, false otherwise
*/
static bool getEnableLifecycleServices(const rclcpp::NodeOptions & options)
{
// Check if the parameter is explicitly set in NodeOptions
for (const auto & param : options.parameter_overrides()) {
if (param.get_name() == "enable_lifecycle_services") {
return param.as_bool();

Check warning on line 410 in nav2_ros_common/include/nav2_ros_common/lifecycle_node.hpp

View check run for this annotation

Codecov / codecov/patch

nav2_ros_common/include/nav2_ros_common/lifecycle_node.hpp#L410

Added line #L410 was not covered by tests
}
}
// Default to true if not specified
return true;
}
};

} // namespace nav2
Expand Down
Loading