20 #include "rclcpp/rclcpp.hpp"
21 #include "nav2_util/lifecycle_service_client.hpp"
24 using namespace std::chrono_literals;
25 using namespace nav2_util;
29 cerr <<
"Invalid command line.\n\n";
30 cerr <<
"This command will take a set of unconfigured lifecycle nodes through the\n";
31 cerr <<
"CONFIGURED to the ACTIVATED state\n";
32 cerr <<
"The nodes are brought up in the order listed on the command line\n\n";
34 cerr <<
" > lifecycle_startup <node name> ...\n";
38 #define RETRY(fn, retries) \
45 } catch (const std::runtime_error & e) { \
47 if (count > (retries)) { \
53 inline void startupLifecycleNode(
54 const std::string & node_name,
55 const std::chrono::seconds service_call_timeout,
64 sc.change_state(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE, service_call_timeout),
67 sc.change_state(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE, service_call_timeout),
71 inline void startup_lifecycle_nodes(
72 const std::vector<std::string> & node_names,
73 const std::chrono::seconds service_call_timeout,
74 const int retries = 3)
76 for (
const auto & node_name : node_names) {
77 startupLifecycleNode(node_name, service_call_timeout, retries);
82 int main(
int argc,
char * argv[])
87 rclcpp::init(0,
nullptr);
88 startup_lifecycle_nodes(
89 std::vector<std::string>(argv + 1, argv + argc),
Helper functions to interact with a lifecycle node.