15 #include "nav2_lifecycle_manager/lifecycle_manager_client.hpp"
22 #include "nav2_util/geometry_utils.hpp"
24 namespace nav2_lifecycle_manager
26 using nav2_util::geometry_utils::orientationAroundZAxis;
31 return callService(ManageLifecycleNodes::Request::STARTUP, timeout);
37 return callService(ManageLifecycleNodes::Request::SHUTDOWN, timeout);
43 return callService(ManageLifecycleNodes::Request::PAUSE, timeout);
49 return callService(ManageLifecycleNodes::Request::RESUME, timeout);
55 return callService(ManageLifecycleNodes::Request::RESET, timeout);
61 return callService(ManageLifecycleNodes::Request::CONFIGURE, timeout);
67 return callService(ManageLifecycleNodes::Request::CLEANUP, timeout);
73 auto request = std::make_shared<std_srvs::srv::Trigger::Request>();
74 auto response = std::make_shared<std_srvs::srv::Trigger::Response>();
77 logger_,
"Waiting for the %s service...",
78 active_service_name_.c_str());
81 return SystemStatus::TIMEOUT;
85 logger_,
"Sending %s request",
86 active_service_name_.c_str());
89 response = is_active_client_->
invoke(request, timeout);
90 }
catch (std::runtime_error &) {
91 return SystemStatus::TIMEOUT;
94 if (response->success) {
95 return SystemStatus::ACTIVE;
97 return SystemStatus::INACTIVE;
104 auto request = std::make_shared<ManageLifecycleNodes::Request>();
105 request->command = command;
108 logger_,
"Waiting for the %s service...",
109 manage_service_name_.c_str());
113 RCLCPP_ERROR(logger_,
"Client interrupted while waiting for service to appear");
116 RCLCPP_DEBUG(logger_,
"Waiting for service to appear...");
120 logger_,
"Sending %s request",
121 manage_service_name_.c_str());
123 auto future_result = manager_client_->
invoke(request, timeout);
124 return future_result->success;
125 }
catch (std::runtime_error &) {
ResponseType::SharedPtr invoke(typename RequestType::SharedPtr &request, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1), const std::chrono::nanoseconds wait_for_service_timeout=std::chrono::seconds(10))
Invoke the service and block until completed or timed out.
bool wait_for_service(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds::max())
Block until a service is available or timeout.
bool cleanup(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make cleanup service call.
bool pause(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make pause service call.
SystemStatus is_active(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Check if lifecycle node manager server is active.
bool shutdown(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make shutdown service call.
bool reset(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make reset service call.
bool startup(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make start up service call.
bool configure(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make configure service call.
bool callService(uint8_t command, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
A generic method used to call startup, shutdown, etc.
bool resume(const std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Make resume service call.