Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
lifecycle_bringup_commandline.cpp
1 // Copyright (c) 2019 Intel Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <vector>
16 #include <string>
17 #include <iostream>
18 #include <cstdlib>
19 #include <chrono>
20 #include "rclcpp/rclcpp.hpp"
21 #include "nav2_util/lifecycle_utils.hpp"
22 
23 using std::cerr;
24 using namespace std::chrono_literals;
25 
26 void usage()
27 {
28  cerr << "Invalid command line.\n\n";
29  cerr << "This command will take a set of unconfigured lifecycle nodes through the\n";
30  cerr << "CONFIGURED to the ACTIVATED state\n";
31  cerr << "The nodes are brought up in the order listed on the command line\n\n";
32  cerr << "Usage:\n";
33  cerr << " > lifecycle_startup <node name> ...\n";
34  std::exit(1);
35 }
36 
37 int main(int argc, char * argv[])
38 {
39  if (argc == 1) {
40  usage();
41  }
42  rclcpp::init(0, nullptr);
43  nav2_util::startup_lifecycle_nodes(
44  std::vector<std::string>(argv + 1, argv + argc),
45  10s);
46  rclcpp::shutdown();
47 }