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

Determine height "y" of ground debris such as gravel or snow along a depth 'z" line, center "x" in front of robot #1884

Closed
richardrye opened this issue May 20, 2021 · 11 comments
Labels

Comments

@richardrye
Copy link

richardrye commented May 20, 2021

I'm currently using a D435i depth camera, mounted on a wheel loader type robot, with realsence2 and rtabmap_ros loaded. I would like to remove ground debris such as snow or gravel and to verify it is removed would like to know the average height of material, just in a line directly in front of the robot.

To clarify, I would like to specify a z distance, x would be fixed at center line of robot, and I would like to know the heights y from the ground, starting at the robot to the z distance at regular intervals up to z.

If you can provide the C++ code to determine the height y of one position along this line, given a depth and x position would be extremely helpful.

I've added a pic of the robot for context.

Thanks
IMG_2874

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented May 20, 2021

Hi @richardrye Is the camera mounted inside the white box on the rear of the vehicle, please?

Also, is the camera pointed downwards facing towards the ground instead of facing straight ahead, and you want to set a maximum distance for z so that only depth data under a defined maximum distance from the camera is registered?

If that is your intention then you could set a maximum depth distance in the RealSense ROS wrapper with the clip_distance instruction.

The rs_launch launch file provides an example of defining clip_distance:

https://github.com/IntelRealSense/realsense-ros/blob/development/realsense2_camera/launch/rs_camera.launch#L58

If your camera is not facing downwards towards the ground, please provide information about how the camera is set up on the vehicle.

In regard to getting the distance, there are more resources for Python than for C++. An approach that may work for you is to subscribe to /camera/aligned_depth_to_color/image_raw as described in the links below.

#637 (comment)

#1785 (comment)

Alternatively, a discussion in the link below provides C++ scripting for obtaining the distance in the ROS wrapper using the depth map.

https://answers.ros.org/question/299888/using-a-depth-map/

@richardrye
Copy link
Author

richardrye commented May 20, 2021 via email

@MartyG-RealSense
Copy link
Collaborator

Hi @richardrye The drawings did not appear, as emailed posts tend not to generate images on the GitHub. Can you add them later when you have a chance to access a web browser please? I will wait for the drawings before commenting further. Thanks!

@richardrye
Copy link
Author

Finding height of debris at regular intervals

I've attached a descriptive picture as requested.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented May 20, 2021

Thanks very much. This is actually my first impression of what you were describing before the facing-downwards theory that I posted in the end. It was not clear to me how the camera would be able to see what is on the ground from the straight-ahead viewpoint if the vehicle was in front of the camera and potentially obscuring the lower half of its field of view.

The other point that I considered was how the camera could observe the 'y' height of the snow or gravel in front of the vehicle if looking straight ahead from the white box, since it was looking over the top of the snow / gravel instead of havig a top-down view towards the ground. In that situation, it seemed as though the snow / gravel would be detected if it was high enough to enter the bottom of the field of view of the facing-ahead camera.

I hope that I've explained my thoughts clearly. If not, pease feel free to add futher information. Thanks!

@richardrye
Copy link
Author

richardrye commented May 20, 2021 via email

@MartyG-RealSense
Copy link
Collaborator

Hi @richardrye Do you have an update about this case that you can provide, please? Thanks!

@richardrye
Copy link
Author

Hi Marty,
I've found a suitable piece of code on "https://answers.ros.org/question/90696/get-depth-from-kinect-sensor-in-gazebo-simulator/" that enables one to select any pixel and it gives the depth of that pixel. With this and some basic trigonometry I am able to find the height of ground covering.
Thanks,

@MartyG-RealSense
Copy link
Collaborator

It's excellent to hear that you found a solution @richardrye - thanks very much for the update!

@richardrye
Copy link
Author

Oh one more thing, to work with the D435i I had to change one parameter, specifically "/camera/depth/image_rect_raw" and located in this portion of the code:

image_transport::Subscriber sub = it.subscribe("/camera/depth/image_rect_raw", 1, imageCallback);

May save someone a bit of time.

@MartyG-RealSense
Copy link
Collaborator

@richardrye Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants