Skip to content

Commit

Permalink
fix mesh map stamp when using sim time
Browse files Browse the repository at this point in the history
  • Loading branch information
Cakem1x committed Nov 20, 2024
1 parent 1f95987 commit 471741c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mesh_map/src/mesh_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,17 @@ bool MeshMap::readMap()
}
}

const rclcpp::Time map_stamp = node->now();
rclcpp::Time map_stamp = node->now();
// Workaround: Avoid publishing a map with zero timestamp.
// This can occur when using sim time and the node using mesh map starts to quickly,
// before whatever should publish /clock (e.g. gazebo) is ready.
// A map with timestamp zero will not get displayed in rviz.
// Generally, a zero timestamp is currently considered be an error / unintialized stamp.
// Issue https://github.com/ros2/rclcpp/issues/2025 might want to change that, though.
while (map_stamp.nanoseconds() == 0) { // TODO check whether time is zero
sleep(0.5);
map_stamp = node->now();
}
mesh_geometry_pub->publish(mesh_msgs_conversions::toMeshGeometryStamped<float>(*mesh_ptr, global_frame, uuid_str, vertex_normals, map_stamp));
publishVertexColors(map_stamp);

Expand Down

0 comments on commit 471741c

Please sign in to comment.