ScitosServer.cpp
Go to the documentation of this file.
00001 
00002 #include <string>
00003 
00004 #include <ros/ros.h>
00005 
00006 #include "ScitosBase.h"
00007 
00008 #include "SchunkServer.h"
00009 
00010 
00011 
00012 void robotArmThread(ScitosBase& scitos_base, ros::NodeHandle nh_schunk) {
00013         ROS_INFO("Starting ros schunk connector...");
00014         SchunkServer schunk_server(nh_schunk);
00015 
00016         try {
00017                 while (nh_schunk.ok())
00018                         boost::this_thread::sleep(boost::posix_time::minutes(42));
00019         }
00020         catch(const boost::thread_interrupted&) {
00021                 ROS_INFO("Robot arm thread was interrupted and returns, stopping the arm interface.");
00022         }
00023 }
00024 
00025 
00026 int main(int argc, char **argv) {
00027         ros::init(argc, argv, "metralabs_ros");
00028 
00029         ros::NodeHandle nh_private("~");
00030         ros::NodeHandle nh_scitos("scitos");
00031         ros::NodeHandle nh_schunk("schunk");
00032 
00033 
00035 
00036         std::string scitos_config_file;
00037         nh_private.param<std::string>("scitos_config_file", scitos_config_file,
00038                         "/opt/MetraLabs/MLRobotic/etc/config/SCITOS-G5_without_Head_config.xml");
00039 
00040 
00042 
00043         ROS_INFO("Starting robot base...");
00044         ScitosBase base(scitos_config_file.c_str(), argc, argv, nh_scitos);
00045 
00046 
00048 
00049         boost::thread robot_arm_thread_;
00050         std::string robot_arm_class;
00051         if(nh_private.getParam("robot_arm_class", robot_arm_class) && robot_arm_class != "None") {
00052                 // if the parameter exists and does not match "None"
00053                 robot_arm_thread_ = boost::thread(robotArmThread, boost::ref(base), boost::ref(nh_schunk));
00054         }
00055 
00056 
00058 
00059         ROS_INFO("Initializing done, starting ROS spinner");
00060         ros::spin();
00061 
00062 
00063         // clean up
00064 
00065         if(robot_arm_thread_.joinable()) {
00066                 robot_arm_thread_.interrupt();
00067                 robot_arm_thread_.join();
00068         }
00069         else
00070                 ROS_WARN("robot arm thread not joinable, should this happen?");
00071 
00072         return 0;
00073 }


metralabs_ros
Author(s): Yianni Gatsoulis and Chris Burbridge and Lorenzo Riano and Felix Kolbe
autogenerated on Mon Oct 6 2014 07:27:58