TNeighborAgentMapProps.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
11 
12 #include <mrpt/version.h>
13 #if MRPT_VERSION>=0x199
14 using namespace mrpt::system;
15 #else
16 using namespace mrpt::utils;
17 #endif
18 
19 using namespace mrpt_msgs;
20 using namespace mrpt::maps;
21 using namespace mrpt::graphslam;
22 using namespace ros;
23 using namespace nav_msgs;
24 using namespace std;
25 
26 
27 TNeighborAgentMapProps::TNeighborAgentMapProps(
28  mrpt::utils::COutputLogger* logger_in,
29  const mrpt_msgs::GraphSlamAgent& agent_in,
30  ros::NodeHandle* nh_in):
31  m_logger(logger_in),
32  nh(nh_in),
33  agent(agent_in),
34  queue_size(1),
35  has_init_class(false),
36  has_setup_comm(false)
37 {
38  ASSERT_(nh);
40  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps constructor");
41 
42  this->map_topic = "/" + agent.topic_namespace.data + "/" +
43  "feedback" + "/" + "gridmap";
44  this->robot_trajectory_topic = "/" + agent.topic_namespace.data + "/" +
45  "feedback" + "/" + "robot_trajectory";
46 
47  cout << "Map topic: " << this->map_topic << endl;
48  cout << "Trajectory topic: " << this->robot_trajectory_topic << endl;
49 
50  has_init_class = true;
52 
53 }
54 
56  //std::map<std::sttring, std::string> agent_pose;
57  //bool res = nh->getParam("/" + agent.topic_namespace.data + "/" + "global_pos", agent_pose);
58 
59  //if (res) {
60  //m_logger->logFmt(LVL_INFO, "%s", getMapAsString(agent_pose).c_str());
61 
62  //global_init_pos = pose_t(
63  //atof(pos_x),
64  //atof(pos_y),
65  //atof(rot_z));
66  //m_logger->logFmt(LVL_INFO, "global_init_pos: %s\n", global_init_pos);
67  //}
68  //else {
69  //cout << "parameter fetch was not successful" << endl;
70  //}
71 
72 }
73 
76  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps::setupComm");
77  this->setupSubs();
78  has_setup_comm = true;
79 }
80 
82  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps::setupSubs");
84  this->map_topic,
85  this->queue_size,
87 
88  this->robot_trajectory_sub = nh->subscribe<nav_msgs::Path>(
90  this->queue_size,
92 } // end of setupSubs
93 
95  const nav_msgs::OccupancyGrid::ConstPtr& nav_gridmap) {
96  nav_map = nav_gridmap;
97 } // end of updateGridMap
98 
100  const nav_msgs::Path::ConstPtr& nav_robot_traj) {
101  nav_robot_trajectory = nav_robot_traj;
102 }
103 
void updateRobotTrajectory(const nav_msgs::Path::ConstPtr &nav_robot_traj)
Callback method to be called when new data in the Estimated Trajectory topic is available.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void updateGridMap(const nav_msgs::OccupancyGrid::ConstPtr &nav_gridmap)
Callback method to be called when new data in the map topic is available.
nav_msgs::Path::ConstPtr nav_robot_trajectory
Trajectory of the correspondign agent - in ROS form.
const mrpt_msgs::GraphSlamAgent & agent
Pointer to the GraphSlamAgent instance of the neighbor.
ros::Subscriber map_sub
Map subscriber instance.
nav_msgs::OccupancyGrid::ConstPtr nav_map
Map generated by the corresponding agent - in ROS form.
#define ASSERT_(f)
std::string map_topic
Map topic to subscribe and fetch the map from.


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sat May 2 2020 03:44:17