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 lidar visualization when gz_frame_id is specified #2481

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Jul 15, 2024

🦟 Bug fix

Summary

The lidar visualization plugin has an assumption that the frame_id in the lidar scan msg is the name of the lidar sensor and uses this to find the lidar entity in the ECM. With the changes in gazebosim/gz-sensors#447, this is no longer true. The lidar scan msg's frame_id is now correctly set to <gz_frame_id> or the sensor name if gz_frame_id is not supplied. This PR fixes lidar visualization by finding the lidar entity based on the subscribed topic name.

manually tested using gpu_lidar_sensor.sdf by adding <gz_frame_id> to the lidar sensor and verifying lidar visualization still works:

gpu_lidar_sensor.patch
diff --git a/examples/worlds/gpu_lidar_sensor.sdf b/examples/worlds/gpu_lidar_sensor.sdf
index 756de3eb3..8a7781f8c 100644
--- a/examples/worlds/gpu_lidar_sensor.sdf
+++ b/examples/worlds/gpu_lidar_sensor.sdf
@@ -139,6 +139,7 @@
         </visual>
 
         <sensor name='gpu_lidar' type='gpu_lidar'>
+          <gz_frame_id>my_lidar_frame_id</gz_frame_id>
           <topic>lidar</topic>
           <update_rate>10</update_rate>
           <lidar>

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

_ecm.EntityByComponents(components::SensorTopic(topic));
}

if (lidarEnt == kNullEntity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do something to avoid this message to show up over and over if we don't find the entity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to print only once. I also added extra checks for null entity in case the lidar is deleted. cf6ed2c

@iche033 iche033 merged commit dd8c4d7 into gz-sim8 Jul 17, 2024
9 checks passed
@iche033 iche033 deleted the lidar_visual_fix branch July 17, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants