setup_assistant_main.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman */
36 
38 #include <ros/ros.h>
39 #include <QApplication>
40 #include <QMessageBox>
41 #include <boost/program_options.hpp>
42 #include <signal.h>
43 #include <locale.h>
44 
45 static void siginthandler(int param)
46 {
47  QApplication::quit();
48 }
49 
50 void usage(boost::program_options::options_description& desc, int exit_code)
51 {
52  std::cout << desc << std::endl;
53  exit(exit_code);
54 }
55 
56 int main(int argc, char** argv)
57 {
58  // Parse parameters
59  namespace po = boost::program_options;
60 
61  // Declare the supported options
62  po::options_description desc("Allowed options");
63  desc.add_options()("help,h", "Show help message")("debug,g", "Run in debug/test mode")(
64  "urdf_path,u", po::value<std::string>(), "Optional, path to URDF file in ROS package")(
65  "config_pkg,c", po::value<std::string>(), "Optional, pass in existing config package to load");
66 
67  // Process options
68  po::variables_map vm;
69  try
70  {
71  po::store(po::parse_command_line(argc, argv, desc), vm);
72  po::notify(vm);
73 
74  if (vm.count("help"))
75  usage(desc, 0);
76  }
77  catch (const std::exception& e)
78  {
79  std::cerr << e.what() << std::endl;
80  usage(desc, 1);
81  }
82  // Start ROS Node
83  ros::init(argc, argv, "moveit_setup_assistant", ros::init_options::NoSigintHandler);
84 
85  // ROS Spin
87  spinner.start();
88 
89  ros::NodeHandle nh;
90 
91  // Create Qt Application
92  QApplication qtApp(argc, argv);
93  // numeric values should always be POSIX
94  setlocale(LC_NUMERIC, "C");
95 
96  // Load Qt Widget
98  saw.setMinimumWidth(980);
99  saw.setMinimumHeight(550);
100  // saw.setWindowState( Qt::WindowMaximized );
101 
102  saw.show();
103 
104  signal(SIGINT, siginthandler);
105 
106  // Wait here until Qt App is finished
107  const int result = qtApp.exec();
108 
109  // Shutdown ROS
110  ros::shutdown();
111 
112  return result;
113 }
void usage(boost::program_options::options_description &desc, int exit_code)
#define NULL
desc
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static void siginthandler(int param)
void spinner()
int main(int argc, char **argv)
ROSCPP_DECL void shutdown()


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Sun Oct 18 2020 13:19:28