Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mesh map stamp when using sim time #67

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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