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:
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?