Skip to content

Commit

Permalink
Create the robot path message from poses in the correct frame (ros-pe…
Browse files Browse the repository at this point in the history
  • Loading branch information
svwilliams committed Aug 2, 2018
1 parent f899a41 commit 95eb652
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/slam_karto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,21 +960,9 @@ SlamKarto::updateMap()
scans.push_back(scan);
}
}
// If the map->local rotation is non-zero, transform the scans before building the map
if (map_to_local_rotation_ != 0)
{
karto::Pose2 map_to_local_pose(0, 0, map_to_local_rotation_);
karto::Transform map_to_local_transform(map_to_local_pose);
for (size_t i = 0; i < scans.size(); ++i)
{
karto::LocalizedRangeScan* scan = scans.at(i);
scan->SetCorrectedPose(map_to_local_transform.TransformPose(scan->GetCorrectedPose()));
}
}
// Build a map from the laserscans
karto::OccupancyGrid* occ_grid = karto::OccupancyGrid::CreateFromScans(scans, resolution_);

// Create the path message
// Create the path message. The path message is published in the "local_map" frame so that it can be displayed in
// RViz. Thus, we create it from the raw scans before transforming them into the "map" frame.
nav_msgs::Path path_msg;
path_msg.header.stamp = ros::Time::now();
path_msg.header.frame_id = local_map_frame_;
Expand All @@ -991,7 +979,21 @@ SlamKarto::updateMap()
path_msg.poses.push_back(pose_3d);
}

// Delete the transformed scans
// If the map->local rotation is non-zero, transform the scans before building the map
if (map_to_local_rotation_ != 0)
{
karto::Pose2 map_to_local_pose(0, 0, map_to_local_rotation_);
karto::Transform map_to_local_transform(map_to_local_pose);
for (size_t i = 0; i < scans.size(); ++i)
{
karto::LocalizedRangeScan* scan = scans.at(i);
scan->SetCorrectedPose(map_to_local_transform.TransformPose(scan->GetCorrectedPose()));
}
}
// Build a map from the laserscans
karto::OccupancyGrid* occ_grid = karto::OccupancyGrid::CreateFromScans(scans, resolution_);

// Delete the copied scans
for (size_t i = 0; i < scans.size(); ++i)
{
delete scans.at(i);
Expand Down

0 comments on commit 95eb652

Please sign in to comment.