Open ingramator opened 3 years ago
Here's a sample image:
TLDR; Your suspicion is correct, you can get a colored pointcloud by doing the following things (quick and dirty solution):
<camera id for rgb image>
] (be careful to only lookup the image message from image_map once per call to FillPointCloudHelper, otherwise the map lookups will hurt performance)Detailed explanation and proposed long-term solution:
The mono issue you are referring to is because the image_msg_
member variable is reused in the GazeboRosRealsense::OnNewFrame() callback for the left IR, right IR, and rgb cameras. So by the time you reach the pointcloud generation in FillPointCloudHelper(), imagemsg has been overwritten by one of the IR images.
One possible fix would be to replace imagemsg with a map from camera_id to image messages, fill the appropriate image_msg[camera_id] with the image message in OnNewFrame(), and then when you go to generate the pointcloud, fill the pointcloud with the appropriate message (maybe give the user the choice about which image is used?).
However, that does not solve the problem fully because depending on your urdf plugin description setup, the color image may not be aligned with the depth image (and in reality they are definitely not aligned). This also does not handle the case where you are using an fov and/or resolution for the color image that is not equal to that of the depth image.
imho one long-term solution would be to have the gazebo camera sensors positioned realistically (i.e. actually separated in space) and add a function to the plugin that aligns the depth image to the color image before generating the pointcloud with rgb data. although some people might not appreciate the extra computational overhead when just trying to run a simulation, so you would also probably want an option to just generate a pointcloud without doing the alignment :sweat_smile:
could you just have separate imagemsgs objects for the IR cameras and the RGB camera and work? Would that change the code a lot?
Greating everyone, I'm recently facing the same problem, so I did the steps john-maidbot provided. And the result stays the same, RGB data does not merged into the pointcloud. Consider that I'm bad at coding and lack of experience, I believe I made some mistakes. Could anyone kindly post the modified code? It will helps me a lot, thanks.
Hey everyone, I have the same Problem of not being able to get a coloured Pointcloud. I didn´t get the solution mentioned by john-maidbot to work. Did anyone solve the issue? Thank you in advance.
When running with pointcloud enable I can only seem to get mono output from the pointcloud output. I am checking RGB in Rviz and manually inspected the cloud output to verify that indeed it is only publishing mono data.
I can see that the plugin is always dropping into this else if: https://github.com/pal-robotics/realsense_gazebo_plugin/blob/49ab134fa517280bb8393e715173dc631ccc2557/src/gazebo_ros_realsense.cpp#L185-L190
Since we are filling the
this->image_msg_
data with both RGB colour images and MONO IR images here: https://github.com/pal-robotics/realsense_gazebo_plugin/blob/49ab134fa517280bb8393e715173dc631ccc2557/src/gazebo_ros_realsense.cpp#L90-L92I'm suspecting that somehow only the MONO images are actually being used exclusively for:
https://github.com/pal-robotics/realsense_gazebo_plugin/blob/49ab134fa517280bb8393e715173dc631ccc2557/src/gazebo_ros_realsense.cpp#L167
It seems at least one other user may have experienced this issue too: #3
Any ideas or fixes would be much appreciated! Happy to contribute back if I figure something out too.
Cheers