Go to the documentation of this file.00001
00006 #include <signal.h>
00007 #include <ros/ros.h>
00008 #include <ros/xmlrpc_manager.h>
00009 #include "slam/base.h"
00010
00011
00012 sig_atomic_t volatile g_request_shutdown = 0;
00013
00014
00015 void sigIntHandler(int sig)
00016 {
00017 g_request_shutdown = 1;
00018 }
00019
00020
00021 void shutdownCallback(XmlRpc::XmlRpcValue& params, XmlRpc::XmlRpcValue& result)
00022 {
00023 int num_params = 0;
00024 if (params.getType() == XmlRpc::XmlRpcValue::TypeArray)
00025 num_params = params.size();
00026 if (num_params > 1)
00027 {
00028 std::string reason = params[1];
00029 ROS_WARN("Shutdown request received. Reason: [%s]", reason.c_str());
00030 g_request_shutdown = 1;
00031 }
00032
00033 result = ros::xmlrpc::responseInt(1, "", 0);
00034 }
00035
00036 int main(int argc, char **argv)
00037 {
00038
00039 ros::init(argc, argv, "stereo_slam", ros::init_options::NoSigintHandler);
00040 signal(SIGINT, sigIntHandler);
00041
00042
00043 ros::XMLRPCManager::instance()->unbind("shutdown");
00044 ros::XMLRPCManager::instance()->bind("shutdown", shutdownCallback);
00045
00046
00047 ros::NodeHandle nh;
00048 ros::NodeHandle nh_private("~");
00049 slam::SlamBase slam_node(nh,nh_private);
00050
00051
00052 while (!g_request_shutdown)
00053 {
00054
00055 ros::spinOnce();
00056 usleep(100000);
00057 }
00058
00059
00060 slam_node.finalize();
00061
00062
00063 ros::shutdown();
00064 }