setup_assistant_main.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2012, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Dave Coleman */
00036 
00037 #include "widgets/setup_assistant_widget.h"
00038 #include <ros/ros.h>
00039 #include <QApplication>
00040 #include <QMessageBox>
00041 #include <boost/program_options.hpp>
00042 #include <signal.h>
00043 #include <locale.h>
00044 
00045 static void siginthandler(int param)
00046 {
00047   QApplication::quit();
00048 }
00049 
00050 void usage(boost::program_options::options_description& desc, int exit_code)
00051 {
00052   std::cout << desc << std::endl;
00053   exit(exit_code);
00054 }
00055 
00056 int main(int argc, char** argv)
00057 {
00058   // Parse parameters
00059   namespace po = boost::program_options;
00060 
00061   // Declare the supported options
00062   po::options_description desc("Allowed options");
00063   desc.add_options()("help,h", "Show help message")("debug,g", "Run in debug/test mode")(
00064       "urdf_path,u", po::value<std::string>(), "Optional, path to URDF file in ROS package")(
00065       "config_pkg,c", po::value<std::string>(), "Optional, pass in existing config package to load");
00066 
00067   // Process options
00068   po::variables_map vm;
00069   try
00070   {
00071     po::store(po::parse_command_line(argc, argv, desc), vm);
00072     po::notify(vm);
00073 
00074     if (vm.count("help"))
00075       usage(desc, 0);
00076   }
00077   catch (const std::exception& e)
00078   {
00079     std::cerr << e.what() << std::endl;
00080     usage(desc, 1);
00081   }
00082   // Start ROS Node
00083   ros::init(argc, argv, "moveit_setup_assistant", ros::init_options::NoSigintHandler);
00084 
00085   // ROS Spin
00086   ros::AsyncSpinner spinner(1);
00087   spinner.start();
00088 
00089   ros::NodeHandle nh;
00090 
00091   // Create Qt Application
00092   QApplication qtApp(argc, argv);
00093   // numeric values should always be POSIX
00094   setlocale(LC_NUMERIC, "C");
00095 
00096   // Load Qt Widget
00097   moveit_setup_assistant::SetupAssistantWidget saw(NULL, vm);
00098   saw.setMinimumWidth(980);
00099   saw.setMinimumHeight(550);
00100   //  saw.setWindowState( Qt::WindowMaximized );
00101 
00102   saw.show();
00103 
00104   signal(SIGINT, siginthandler);
00105 
00106   // Wait here until Qt App is finished
00107   const int result = qtApp.exec();
00108 
00109   // Shutdown ROS
00110   ros::shutdown();
00111 
00112   return result;
00113 }


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Wed Jun 19 2019 19:25:13