Class LifecycleServiceClient
Defined in File lifecycle_manager.hpp
Inheritance Relationships
Base Type
public rclcpp::Node
Class Documentation
-
class LifecycleServiceClient : public rclcpp::Node
Client node to manage the lifecycle of another ROS2 node.
Provides methods to query and change the state of a managed node using the lifecycle management services.
Public Functions
-
explicit LifecycleServiceClient(const std::string &node_name, const std::string &managed_node)
Construct a new LifecycleServiceClient object.
- Parameters:
node_name – [in] Name for this client node.
managed_node – [in] Name of the node to be managed.
-
void init()
Initializes the service clients for lifecycle management.
-
unsigned int get_state(std::chrono::seconds time_out = std::chrono::seconds(3))
Gets the current state of the managed node.
- Parameters:
time_out – [in] Timeout for the service call (default: 3 seconds).
- Returns:
unsigned int The current state as defined in lifecycle_msgs::msg::State.
-
bool change_state(std::uint8_t transition, std::chrono::seconds time_out = std::chrono::seconds(3))
Changes the state of the managed node.
- Parameters:
transition – [in] The transition ID to trigger.
time_out – [in] Timeout for the service call (default: 3 seconds).
- Returns:
true if the transition was successful, false otherwise.
-
explicit LifecycleServiceClient(const std::string &node_name, const std::string &managed_node)