main.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 SoftBank Robotics Europe
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015 */
00016 
00017 #include <boost/program_options.hpp>
00018 
00019 #include "romeo_moveit_actions/simplepickplace.hpp"
00020 
00021 void parse_command_line(int argc, char ** argv,
00022                         std::string &robot_name_,
00023                         double &test_step_,
00024                         double &x_min_,
00025                         double &x_max_,
00026                         double &y_min_,
00027                         double &y_max_,
00028                         double &z_min_,
00029                         double &z_max_,
00030                         std::string &left_arm_name_,
00031                         std::string &right_arm_name_,
00032                         bool &verbose_)
00033 {
00034   std::string robot_name;
00035   double test_step(0.0);
00036   double x_min(0.0);
00037   double x_max(0.0);
00038   double y_min(0.0);
00039   double y_max(0.0);
00040   double z_min(0.0);
00041   double z_max(0.0);
00042   std::string left_arm_name("");
00043   std::string right_arm_name("");
00044   bool verbose;
00045   boost::program_options::options_description desc("Configuration");
00046   desc.add_options()
00047     ("help", "show this help message")
00048     ("robot_name", boost::program_options::value<std::string>(&robot_name)->default_value(robot_name_),
00049      "robot_name")
00050     ("test_step", boost::program_options::value<double>(&test_step)->default_value(test_step_),
00051      "test_step")
00052     ("x_min", boost::program_options::value<double>(&x_min)->default_value(x_min_),
00053      "x_min")
00054     ("x_max", boost::program_options::value<double>(&x_max)->default_value(x_max_),
00055      "x_max")
00056     ("y_min", boost::program_options::value<double>(&y_min)->default_value(y_min_),
00057      "y_min")
00058     ("y_max", boost::program_options::value<double>(&y_max)->default_value(y_max_),
00059      "y_max")
00060     ("z_min", boost::program_options::value<double>(&z_min)->default_value(z_min_),
00061      "z_min")
00062     ("z_max", boost::program_options::value<double>(&z_max)->default_value(z_max_),
00063      "z_max")
00064     ("left_arm_name", boost::program_options::value<std::string>(&left_arm_name)->default_value(left_arm_name),
00065      "left_arm_name")
00066     ("right_arm_name", boost::program_options::value<std::string>(&right_arm_name)->default_value(right_arm_name),
00067      "right_arm_name")
00068     ("verbose", boost::program_options::value<bool>(&verbose)->default_value(verbose_),
00069      "verbose")
00070     /*("depth_frame_id", boost::program_options::value<std::string>(&depth_frame_id)->default_value(m_depth_frame_id),
00071      "depth_frame_id")*/
00072     ;
00073   boost::program_options::variables_map vm;
00074   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
00075   boost::program_options::notify(vm);
00076   robot_name_ = vm["robot_name"].as<std::string>();
00077   test_step_ = vm["test_step"].as<double>();
00078   x_min_ = vm["x_min"].as<double>();
00079   x_max_ = vm["x_max"].as<double>();
00080   y_min_ = vm["y_min"].as<double>();
00081   y_max_ = vm["y_max"].as<double>();
00082   z_min_ = vm["z_min"].as<double>();
00083   z_max_ = vm["z_max"].as<double>();
00084   left_arm_name_ = vm["left_arm_name"].as<std::string>();
00085   right_arm_name_ = vm["right_arm_name"].as<std::string>();
00086   verbose_ = vm["verbose"].as<bool>();
00087 
00088   ROS_INFO_STREAM("robot name = " << robot_name_);
00089   /*ROS_INFO_STREAM("test_step= " << test_step_);
00090   ROS_INFO_STREAM("x_min= " << x_min_);
00091   ROS_INFO_STREAM("x_max= " << x_max_);
00092   ROS_INFO_STREAM("y_min= " << y_min_);
00093   ROS_INFO_STREAM("y_max= " << y_max_);
00094   ROS_INFO_STREAM("z_min= " << z_min_);
00095   ROS_INFO_STREAM("z_max= " << z_max_);
00096   ROS_INFO_STREAM("left_arm_name = " << left_arm_name);
00097   ROS_INFO_STREAM("right_arm_name = " << right_arm_name);*/
00098 
00099   if (vm.count("help")) {
00100     std::cout << desc << "\n";
00101     return ;
00102   }
00103 }
00104 
00105 int main(int argc, char **argv)
00106 {
00107   ros::init (argc, argv, "moveit_simple_action");
00108   ros::AsyncSpinner spinner(1);
00109   spinner.start();
00110 
00111   // Check for verbose flag
00112   bool verbose = false;
00113 
00114   std::string robot_name("romeo");
00115   double test_step(0.0);
00116   double x_min(0.0);
00117   double x_max(0.0);
00118   double y_min(0.0);
00119   double y_max(0.0);
00120   double z_min(0.0);
00121   double z_max(0.0);
00122   std::string left_arm_name("left");
00123   std::string right_arm_name("right");
00124   parse_command_line(argc, argv, robot_name, test_step,
00125                      x_min, x_max, y_min, y_max, z_min, z_max,
00126                      left_arm_name, right_arm_name,
00127                      verbose);
00128 
00129   srand (time(NULL));
00130 
00131   // Start the pick place node
00132   moveit_simple_actions::SimplePickPlace server_pickplace(robot_name,
00133                                                           test_step,
00134                                                           x_min,
00135                                                           x_max,
00136                                                           y_min,
00137                                                           y_max,
00138                                                           z_min,
00139                                                           z_max,
00140                                                           left_arm_name,
00141                                                           right_arm_name,
00142                                                           verbose);
00143 
00144   server_pickplace.run();
00145 
00146   ROS_INFO_STREAM_NAMED("moveit_simple_action", "Shutting down.");
00147   spinner.stop();
00148   ros::shutdown();
00149 
00150   return 0;
00151 }


romeo_moveit_actions
Author(s):
autogenerated on Thu Jun 6 2019 21:57:24