CGraphSlamEngine_ROS_impl.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002          |                     Mobile Robot Programming Toolkit (MRPT)               |
00003          |                          http://www.mrpt.org/                             |
00004          |                                                                           |
00005          | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file        |
00006          | See: http://www.mrpt.org/Authors - All rights reserved.                   |
00007          | Released under BSD License. See details in http://www.mrpt.org/License    |
00008          +---------------------------------------------------------------------------+ */
00009 
00010 #ifndef CGRAPHSLAMENGINE_ROS_IMPL_H
00011 #define CGRAPHSLAMENGINE_ROS_IMPL_H
00012 namespace mrpt { namespace graphslam {
00013 
00014 template<class GRAPH_t>
00015 CGraphSlamEngine_ROS<GRAPH_t>::CGraphSlamEngine_ROS(
00016                 ros::NodeHandle* nh,
00017                 const std::string& config_file,
00018                 const std::string& rawlog_fname/* ="" */,
00019                 const std::string& fname_GT /* ="" */,
00020                 mrpt::graphslam::CWindowManager* win_manager /* = NULL */,
00021                 mrpt::graphslam::deciders::CNodeRegistrationDecider<GRAPH_t>* node_reg /* = NULL */,
00022                 mrpt::graphslam::deciders::CEdgeRegistrationDecider<GRAPH_t>* edge_reg /* = NULL */,
00023                 mrpt::graphslam::optimizers::CGraphSlamOptimizer<GRAPH_t>* optimizer /* = NULL */):
00024         m_nh(nh),
00025         parent::CGraphSlamEngine(
00026                         config_file,
00027                         rawlog_fname,
00028                         fname_GT,
00029                         win_manager,
00030                         node_reg,
00031                         edge_reg,
00032                         optimizer)
00033 {
00034         this->initClass();
00035 }
00036 
00037 template<class GRAPH_t>
00038 CGraphSlamEngine_ROS<GRAPH_t>::~CGraphSlamEngine_ROS() {
00039         MRPT_LOG_DEBUG_STREAM("In Destructor: Deleting CGraphSlamEngine_ROS instance...");
00040         ros::shutdown();
00041 }
00042 
00043 template<class GRAPH_t>
00044 void CGraphSlamEngine_ROS<GRAPH_t>::initClass() {
00045         using namespace mrpt::graphslam;
00046 
00047         ASSERT_(m_nh);
00048 
00049         this->m_class_name = "CGraphSlamEngine_ROS";
00050         this->setLoggerName(this->m_class_name);
00051 
00052         // http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers#queue_size:_publish.28.29_behavior_and_queuing
00053         m_queue_size = 10;
00054 
00055         this->setupComm();
00056 
00057         // in case of ROS specific deciders/optimizers (they inherit from the CDeciderOrOptimizer_ROS interface)
00058         // set the NodeHandle
00059         {
00060                 CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>* dec_opt_ros =
00061                         dynamic_cast<CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>*>(this->m_node_reg);
00062 
00063                 if (dec_opt_ros) {
00064                         dec_opt_ros->setNodeHandle(m_nh);
00065                 }
00066         }
00067         {
00068                 CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>* dec_opt_ros =
00069                         dynamic_cast<CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>*>(this->m_edge_reg);
00070                 if (dec_opt_ros) {
00071                         dec_opt_ros->setNodeHandle(m_nh);
00072                 }
00073         }
00074         {
00075                 CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>* dec_opt_ros =
00076                         dynamic_cast<CRegistrationDeciderOrOptimizer_ROS<GRAPH_t>*>(this->m_optimizer);
00077                 if (dec_opt_ros) {
00078                         dec_opt_ros->setNodeHandle(m_nh);
00079                 }
00080         }
00081 
00082         this->readParams();
00083 }
00084 
00085 template<class GRAPH_t>
00086 void CGraphSlamEngine_ROS<GRAPH_t>::readParams() {
00087 
00088         this->readROSParameters();
00089 }
00090 
00091 template<class GRAPH_t>
00092 void CGraphSlamEngine_ROS<GRAPH_t>::readROSParameters() { }
00093 
00094 template<class GRAPH_t>
00095 bool CGraphSlamEngine_ROS<GRAPH_t>::_execGraphSlamStep(
00096                 mrpt::obs::CActionCollectionPtr& action,
00097                 mrpt::obs::CSensoryFramePtr& observations,
00098                 mrpt::obs::CObservationPtr& observation,
00099                 size_t& rawlog_entry) {
00100 
00101         bool continue_exec = parent::_execGraphSlamStep(
00102                         action, observations, observation, rawlog_entry);
00103         this->usePublishersBroadcasters();
00104 
00105         return continue_exec;
00106 }
00107 
00108 template<class GRAPH_t>
00109 void CGraphSlamEngine_ROS<GRAPH_t>::usePublishersBroadcasters() { }
00110 
00111 template<class GRAPH_t>
00112 void CGraphSlamEngine_ROS<GRAPH_t>::setupComm() {
00113         MRPT_LOG_INFO_STREAM(
00114                 "Setting up subscribers, publishers, services...");
00115 
00116         // setup subscribers, publishers, services...
00117         this->setupSubs();
00118         this->setupPubs();
00119         this->setupSrvs();
00120 
00121 }
00122 
00123 template<class GRAPH_t>
00124 void CGraphSlamEngine_ROS<GRAPH_t>::setupSubs() {
00125         MRPT_LOG_DEBUG_STREAM("Setting up subscribers...");
00126 
00127 }
00128 
00129 template<class GRAPH_t>
00130 void CGraphSlamEngine_ROS<GRAPH_t>::setupPubs() {
00131         MRPT_LOG_DEBUG_STREAM("Setting up publishers...");
00132 
00133 }
00134 
00135 template<class GRAPH_t>
00136 void CGraphSlamEngine_ROS<GRAPH_t>::setupSrvs() {
00137         MRPT_LOG_DEBUG_STREAM("Setting up services...");
00138 
00139 }
00140 
00141 
00142 } } // end of namespaces
00143 
00144 #endif /* end of include guard: CGRAPHSLAMENGINE_ROS_IMPL_H */


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sun Sep 17 2017 03:02:04