mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-09 11:17:03 +08:00
Added mapOdomCache topic. Updated rtabmap_ros/Info msg.
This commit is contained in:
@@ -299,6 +299,7 @@ private:
|
|||||||
ros::Publisher infoPub_;
|
ros::Publisher infoPub_;
|
||||||
ros::Publisher mapDataPub_;
|
ros::Publisher mapDataPub_;
|
||||||
ros::Publisher mapGraphPub_;
|
ros::Publisher mapGraphPub_;
|
||||||
|
ros::Publisher odomCachePub_;
|
||||||
ros::Publisher landmarksPub_;
|
ros::Publisher landmarksPub_;
|
||||||
ros::Publisher labelsPub_;
|
ros::Publisher labelsPub_;
|
||||||
ros::Publisher mapPathPub_;
|
ros::Publisher mapPathPub_;
|
||||||
|
|||||||
@@ -45,3 +45,6 @@ float32[] statsValues
|
|||||||
# std::vector<int> localPath
|
# std::vector<int> localPath
|
||||||
int32[] localPath
|
int32[] localPath
|
||||||
int32 currentGoalId
|
int32 currentGoalId
|
||||||
|
|
||||||
|
# std::vector<int> odomCache
|
||||||
|
MapGraph odom_cache
|
||||||
@@ -266,6 +266,7 @@ void CoreWrapper::onInit()
|
|||||||
infoPub_ = nh.advertise<rtabmap_ros::Info>("info", 1);
|
infoPub_ = nh.advertise<rtabmap_ros::Info>("info", 1);
|
||||||
mapDataPub_ = nh.advertise<rtabmap_ros::MapData>("mapData", 1);
|
mapDataPub_ = nh.advertise<rtabmap_ros::MapData>("mapData", 1);
|
||||||
mapGraphPub_ = nh.advertise<rtabmap_ros::MapGraph>("mapGraph", 1);
|
mapGraphPub_ = nh.advertise<rtabmap_ros::MapGraph>("mapGraph", 1);
|
||||||
|
odomCachePub_ = nh.advertise<rtabmap_ros::MapGraph>("mapOdomCache", 1);
|
||||||
landmarksPub_ = nh.advertise<geometry_msgs::PoseArray>("landmarks", 1);
|
landmarksPub_ = nh.advertise<geometry_msgs::PoseArray>("landmarks", 1);
|
||||||
labelsPub_ = nh.advertise<visualization_msgs::MarkerArray>("labels", 1);
|
labelsPub_ = nh.advertise<visualization_msgs::MarkerArray>("labels", 1);
|
||||||
mapPathPub_ = nh.advertise<nav_msgs::Path>("mapPath", 1);
|
mapPathPub_ = nh.advertise<nav_msgs::Path>("mapPath", 1);
|
||||||
@@ -4171,6 +4172,40 @@ void CoreWrapper::publishStats(const ros::Time & stamp)
|
|||||||
mapGraphPub_.publish(msg);
|
mapGraphPub_.publish(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(odomCachePub_.getNumSubscribers())
|
||||||
|
{
|
||||||
|
rtabmap_ros::MapGraphPtr msg(new rtabmap_ros::MapGraph);
|
||||||
|
msg->header.stamp = stamp;
|
||||||
|
msg->header.frame_id = mapFrameId_;
|
||||||
|
|
||||||
|
// For visualization of the constraints (MapGraph rviz plugin), we should include target nodes from the map
|
||||||
|
std::map<int, Transform> poses = stats.odomCachePoses();
|
||||||
|
// transform in map frame
|
||||||
|
for(std::map<int, Transform>::iterator iter=poses.begin();
|
||||||
|
iter!=poses.end();
|
||||||
|
++iter)
|
||||||
|
{
|
||||||
|
iter->second = stats.mapCorrection() * iter->second;
|
||||||
|
}
|
||||||
|
for(std::multimap<int, rtabmap::Link>::const_iterator iter=stats.odomCacheConstraints().begin();
|
||||||
|
iter!=stats.odomCacheConstraints().end();
|
||||||
|
++iter)
|
||||||
|
{
|
||||||
|
std::map<int, Transform>::const_iterator pter = stats.poses().find(iter->second.to());
|
||||||
|
if(pter != stats.poses().end())
|
||||||
|
{
|
||||||
|
poses.insert(*pter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rtabmap_ros::mapGraphToROS(
|
||||||
|
poses,
|
||||||
|
stats.odomCacheConstraints(),
|
||||||
|
stats.mapCorrection(),
|
||||||
|
*msg);
|
||||||
|
|
||||||
|
odomCachePub_.publish(msg);
|
||||||
|
}
|
||||||
|
|
||||||
if(localGridObstacle_.getNumSubscribers() && !stats.getLastSignatureData().sensorData().gridObstacleCellsRaw().empty())
|
if(localGridObstacle_.getNumSubscribers() && !stats.getLastSignatureData().sensorData().gridObstacleCellsRaw().empty())
|
||||||
{
|
{
|
||||||
pcl::PCLPointCloud2::Ptr cloud = rtabmap::util3d::laserScanToPointCloud2(LaserScan::backwardCompatibility(stats.getLastSignatureData().sensorData().gridObstacleCellsRaw()));
|
pcl::PCLPointCloud2::Ptr cloud = rtabmap::util3d::laserScanToPointCloud2(LaserScan::backwardCompatibility(stats.getLastSignatureData().sensorData().gridObstacleCellsRaw()));
|
||||||
|
|||||||
@@ -507,6 +507,13 @@ void infoFromROS(const rtabmap_ros::Info & info, rtabmap::Statistics & stat)
|
|||||||
stat.setLocalPath(info.localPath);
|
stat.setLocalPath(info.localPath);
|
||||||
stat.setCurrentGoalId(info.currentGoalId);
|
stat.setCurrentGoalId(info.currentGoalId);
|
||||||
|
|
||||||
|
std::map<int, rtabmap::Transform> poses;
|
||||||
|
std::multimap<int, rtabmap::Link> constraints;
|
||||||
|
rtabmap::Transform t;
|
||||||
|
mapGraphFromROS(info.odom_cache, poses, constraints, t);
|
||||||
|
stat.setOdomCachePoses(poses);
|
||||||
|
stat.setOdomCacheConstraints(constraints);
|
||||||
|
|
||||||
// Statistics data
|
// Statistics data
|
||||||
for(unsigned int i=0; i<info.statsKeys.size() && i<info.statsValues.size(); i++)
|
for(unsigned int i=0; i<info.statsKeys.size() && i<info.statsValues.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -542,6 +549,7 @@ void infoToROS(const rtabmap::Statistics & stats, rtabmap_ros::Info & info)
|
|||||||
info.labelsValues = uValues(stats.labels());
|
info.labelsValues = uValues(stats.labels());
|
||||||
info.localPath = stats.localPath();
|
info.localPath = stats.localPath();
|
||||||
info.currentGoalId = stats.currentGoalId();
|
info.currentGoalId = stats.currentGoalId();
|
||||||
|
mapGraphToROS(stats.odomCachePoses(), stats.odomCacheConstraints(), stats.mapCorrection(), info.odom_cache);
|
||||||
|
|
||||||
// Statistics data
|
// Statistics data
|
||||||
info.statsKeys = uKeys(stats.data());
|
info.statsKeys = uKeys(stats.data());
|
||||||
|
|||||||
Reference in New Issue
Block a user