0
$\begingroup$

I have a quite challenging question. I use ROS Melodic on Ubuntu18.04. My goal is to transform a ROS depth image to pointcloud2 format and show it in rviz. The theory seems ok, but I do not now where I fail. My problem can be seen on the image: it looks like that the pointcloud is somehow duplicated and shifted each other, although there is only one corridor in front of the camera.

I uploaded my code as a gist where I transform the depth image.

What I now see in rviz is this:

enter image description here

There is a corridoor in front of my camera, but somehow twice. I thought about the camera calibration and parameters, but I use the data from CameraInfo messages. Although I played with the fx,fy,cx,cy parameters, I cannot align to overleap the two corridor.

Where am I wrong?

$\endgroup$
1
  • $\begingroup$ What are your topic settings in rviz? Are you viewing stale data with a non-zero decay time? $\endgroup$
    – Chuck
    Nov 8, 2021 at 2:59

2 Answers 2

1
$\begingroup$

At first I thought there was some sort of systematic raw format or resolution error, sort of like ROS + kinect depth data duplication .

Then I noticed that each corridor appears in a different perspective, as if the sensor turned to point a different way between two captured frames. You didn't say what sensor you're using, but I assume it's not two cams that happen to point 45 degrees apart!

One might surmise that there are actually two or more frames piled up or appended in the same buffer -- sort of like a double exposure -- and the sensor actually did turn between the shots. Maybe some frame buffer or index needs to be cleared or reinitialized, or something, between frames?

$\endgroup$
1
  • $\begingroup$ Yes, I finally found out that this depth-pcl conversion is correct, but my datatypes are not. I processed the depth image in python, where the datatype was an uint8 array instead of uint16. $\endgroup$
    – Martzi
    Nov 9, 2021 at 14:30
1
$\begingroup$

I agree with r-bryan that you're likely missinterpreting some of the metadata. It could be the frame width or alternatively the stride width or something else in the depth image.

There's a good reference implementation that you can compare yours to the one in depth_image_proc The main part of the implementation is in this header where you can see that there's several more parameters from the metadata being processed.

As an exercise learning to do this is valuable. However for actual usage on a system, I'd highly recommend just using the nodelet already in the open source implementation in this package which has already been used heavily in many applications. If there's additional features or speedups you're looking for contributing them back there would be great too.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.