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

Add laser retro support in Ogre2 #194

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

doisyg
Copy link
Contributor

@doisyg doisyg commented Jan 10, 2021

As discussed here #181 and suggested by @iche033 . Taking huge inspiration and copypasting from Ogre2ThermalCamera (not sure I get the full shader logic). The implementation here is similar as the temperature tag from the Ogre2ThermalCamera.
laser retro values are valid on the range 0.0 to 2000.0 as it was, I believe, on Gazebo Classic. It can be an opportunity to discuss and change this behavior if needed.
There seem to be a loss of precision of around 5 retro value (see the test), don't know if it is due to some noise added in the pipeline or some shader witchery, but it works well for my use case (simulating lidar reflective tape).
With this PR, a pending PR in sdformat (gazebosim/sdformat#454) and one in ign-gazebo that I will soon post (but depends on sdformat), laser retro value will be settable from a sdf/urdf file.

@doisyg doisyg requested a review from iche033 as a code owner January 10, 2021 13:42
@github-actions github-actions bot added the 🏰 citadel Ignition Citadel label Jan 10, 2021
Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

nice, thanks for the contribution!

I'm curious where you find the 2000 limit in gazebo? I was looking through gazebo code but couldn't see where that limit is set.

We ran into precision issue with thermal camera readings as well. Need to investigate further to find out how to resolve this

ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
if (!subItem->hasCustomParameter(this->customParamIdx))
{
// limit laser retro value to 2000 (as in gazebo)
if (retro_value > 2000.0){
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm interesting, where did you find this limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See discussion below

ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
@doisyg
Copy link
Contributor Author

doisyg commented Jan 15, 2021

I'm curious where you find the 2000 limit in gazebo? I was looking through gazebo code but couldn't see where that limit is set.

You're right, there is no limit in gazebo classic, I somehow remembered that the max was 2000.0. I know for sure that I never encountered a laser_retro value (or ROS laserscan intensityhttp://docs.ros.org/en/api/sensor_msgs/html/msg/LaserScan.html) above 2000. But since the intensity is a lidar vendor specific unit maybe we should left it unbounded. What do you think ?

We ran into precision issue with thermal camera readings as well. Need to investigate further to find out how to resolve this

For my use case, since lidar intensity measurement are always noisy, this is fine.

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

But since the intensity is a lidar vendor specific unit maybe we should left it unbounded. What do you think ?

yeah I agree. I think we should make it unbounded.

ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
@doisyg
Copy link
Contributor Author

doisyg commented Jan 16, 2021

yeah I agree. I think we should make it unbounded.

Thinking a bit more about making it unbounded, I think we have a non trivial issue about the range we can accept due to the need of normalizing the value to [0,1] on a float to pass it to the pipeline:
https://github.com/ignitionrobotics/ign-rendering/blob/31af089b83d9dc23d1c46ed94cf258dd0e294fdc/ogre2/src/Ogre2GpuRays.cc#L259-L261

Float precision is not constant within its range: https://blog.demofox.org/2017/11/21/floating-point-precision/
On [0, 1], I believe can assume a precision of at least 0.00000011920929

Also, what do we want as a minimal laser_retro value step ? 0.1 ? 0.01 ?

@iche033
Copy link
Contributor

iche033 commented Jan 20, 2021

thanks for looking into the precision issue. Sounds like we still need an upper bound.

Also, what do we want as a minimal laser_retro value step ? 0.1 ? 0.01 ?

I tried to play around with different upper bound vs small retro values and noticed that we can't really have small step sizes due to the the precision / noise issue which you also noticed in your test. So I would not worry about trying to support a small step size for now until we fixed this problem.

@doisyg
Copy link
Contributor Author

doisyg commented Jan 21, 2021

I tried to play around with different upper bound vs small retro values and noticed that we can't really have small step sizes due to the the precision / noise issue which you also noticed in your test. So I would not worry about trying to support a small step size for now until we fixed this problem.

Ok, I guess leaving it bounded to 2000.0 for now should be ok (and easily changeable to another value if needed).
Any other blocking points ?

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

looks good to me. Can you fix DCO?

ogre2/src/Ogre2GpuRays.cc Outdated Show resolved Hide resolved
@doisyg doisyg force-pushed the add_laser_retro branch 2 times, most recently from a79a30c to 1866311 Compare January 26, 2021 18:34
Signed-off-by: Guillaume Doisy <[email protected]>
@doisyg
Copy link
Contributor Author

doisyg commented Jan 26, 2021

Fixed DCO mess by re-comiting from scratch

@doisyg
Copy link
Contributor Author

doisyg commented Feb 1, 2021

Anything else blocking the merge ?

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

CI looks good. Approving.

@iche033 iche033 merged commit 34a2e54 into gazebosim:ign-rendering3 Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants