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

Publish lidar scan only if there are lidar scan connections #447

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Jul 12, 2024

🦟 Bug fix

Summary

The GpuLidarSensor publishes to 2 topics: 1) lidar scan and 2) points cloud. Previously if the user subscribes to just the point cloud topic, we perform extra computation to pack and publish lidar scans as well. This PR adds an additional check to make sure we don't do extra work when there are not lidar scan subscribers.

In order to make this work, I also had to modify functions for directly accessing lidar scan data. They were accessing the lidar scan msg (which now never gets populated if there are no subscribers), so I modified them to access data from the raw laser buffer instead.

I also fixed the frame id for the lidar scan msg.

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.

@github-actions github-actions bot added the 🎵 harmonic Gazebo Harmonic label Jul 12, 2024
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

linters

  /github/workspace/src/Lidar.cc:453:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/Lidar.cc:469:  Lines should be <= 80 characters long  [whitespace/line_length] [2]

/// outside the detectable range.
/// NAN values will be clamped to max range.
/// \return Clamped range value.
private: double Clamp(double _range) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

why you don't use std::clamp ?

Copy link
Contributor Author

@iche033 iche033 Jul 15, 2024

Choose a reason for hiding this comment

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

needed to use special handling for clamping nan and inf values. Used std::clamp inside the function. 5c28cce

src/Lidar.cc Outdated Show resolved Hide resolved
Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Jul 15, 2024

linters

  /github/workspace/src/Lidar.cc:453:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/Lidar.cc:469:  Lines should be <= 80 characters long  [whitespace/line_length] [2]

fixed. 5c28cce

@iche033 iche033 merged commit f8a1a2e into gz-sensors8 Jul 15, 2024
9 checks passed
@iche033 iche033 deleted the iche033/lidar_scan_pub branch July 15, 2024 20:56
iche033 added a commit that referenced this pull request Jul 15, 2024
iche033 added a commit that referenced this pull request Aug 7, 2024
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