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  */
10 
12 
13 using namespace mrpt::system;
14 using namespace mrpt_msgs;
15 using namespace mrpt::maps;
16 using namespace mrpt::graphslam;
17 using namespace ros;
18 using namespace nav_msgs;
19 using namespace std;
20 
21 TNeighborAgentMapProps::TNeighborAgentMapProps(
22  mrpt::system::COutputLogger* logger_in,
23  const mrpt_msgs::GraphSlamAgent& agent_in, ros::NodeHandle* nh_in)
24  : m_logger(logger_in),
25  nh(nh_in),
26  agent(agent_in),
27  queue_size(1),
28  has_init_class(false),
29  has_setup_comm(false)
30 {
31  ASSERT_(nh);
32  ASSERT_(m_logger);
33  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps constructor");
34 
35  this->map_topic =
36  "/" + agent.topic_namespace.data + "/" + "feedback" + "/" + "gridmap";
37  this->robot_trajectory_topic = "/" + agent.topic_namespace.data + "/" +
38  "feedback" + "/" + "robot_trajectory";
39 
40  cout << "Map topic: " << this->map_topic << endl;
41  cout << "Trajectory topic: " << this->robot_trajectory_topic << endl;
42 
43  has_init_class = true;
45 }
46 
48 {
49  // std::map<std::sttring, std::string> agent_pose;
50  // bool res = nh->getParam("/" + agent.topic_namespace.data + "/" +
51  // "global_pos", agent_pose);
52 
53  // if (res) {
54  // m_logger->logFmt(LVL_INFO, "%s", getMapAsString(agent_pose).c_str());
55 
56  // global_init_pos = pose_t(
57  // atof(pos_x),
58  // atof(pos_y),
59  // atof(rot_z));
60  // m_logger->logFmt(LVL_INFO, "global_init_pos: %s\n", global_init_pos);
61  //}
62  // else {
63  // cout << "parameter fetch was not successful" << endl;
64  //}
65 }
66 
68 {
69  ASSERT_(has_init_class);
70  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps::setupComm");
71  this->setupSubs();
72  has_setup_comm = true;
73 }
74 
76 {
77  m_logger->logFmt(LVL_WARN, "In TNeighborAgentMapProps::setupSubs");
78  this->map_sub = nh->subscribe<nav_msgs::OccupancyGrid>(
79  this->map_topic, this->queue_size,
81 
82  this->robot_trajectory_sub = nh->subscribe<nav_msgs::Path>(
85 } // end of setupSubs
86 
88  const nav_msgs::OccupancyGrid::ConstPtr& nav_gridmap)
89 {
90  nav_map = nav_gridmap;
91 } // end of updateGridMap
92 
94  const nav_msgs::Path::ConstPtr& nav_robot_traj)
95 {
96  nav_robot_trajectory = nav_robot_traj;
97 }
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.
std::string map_topic
Map topic to subscribe and fetch the map from.


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sun Jun 26 2022 02:12:26