How to change the rotation in the result of depth_image_proc/point_cloud_xyz?
Hello guys, I am trying to use the depth_image_proc/point_cloud_xyz nodelet to convert my depth images into point cloud data.
Everything goes well except the rotation, which rotates my data in the top of my robot when it was displayed in rviz. Please see my screenshot followed:
The data displays correct unless I set the urdf files with a extra rotation as:
rpy = "-1.57 0 4.71"
It gives a result like this:
And I find that there is also a offset and a scaling ( about x7.0 ) in the data which is different to my laser scan and makes the true ground (horizon) under the map ground:
And here is my camera info:
height: 270
width: 480
distortion_model: "plumb_bob"
D: [0.0, 0.0, 0.0, 0.0, 0.0]
K: [237.78233998783918, 0.0, 240.0, 0.0, 237.78233998783918, 135.0, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [237.78233998783918, 0.0, 240.0, 0.0, 0.0, 237.78233998783918, 135.0, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 0
binning_y: 0
roi:
x_offset: 0
y_offset: 0
height: 0
width: 0
do_rectify: False
How can I solve this problem? Thank you!
Generally to manipulate pointclouds you have to use pcl library. to convert from rosmessage to pcl format there is some straightforward implementations: http://docs.ros.org/indigo/api/pcl_co...
Once you have the pointcloud as pcl data there is functions which should allow you to rotate easily. from (http://docs.ros.org/indigo/api/pcl_ro...) An example:
Edit: i think is not exactly what you want. anyway i leave this here just in case it's useful for someone
It's actually possible the OP is surprised by the fact that
PointCloud
s and other image based sensors have their sensor data aligned with Z+. See REP-103: Standard Units of Measure and Coordinate Conventions - Suffix Frames.As RViz follows REP-103 (with X+ forward, Y+ left, Z+ up),
PointCloud
s end up "on the ceiling" or "above the robot".The proper solution would then be to configure the TF tree correctly and make sure the camera / sensor frames are correctly oriented.
I would not use PCL to rotate anything, it introduces quite some overhead and should not be necessary if I understand the description by the OP correctly.
If I am not wrong, the implementation of the library you are using is based on opencv. from there (https://docs.opencv.org/2.4/modules/c...) is possible to see that R is the rotation matrix. Maybe just changing the values for the desired ones using an easy converter: https://www.andre-gaschler.com/rotati...
you are right about you response @gvdhoorn. The best solution is what you say
@Konye: please attach your screenshot to the question directly instead of linking to an offline site.
I've given you sufficient karma.
According to the message definition for CameraInfo, a R matrix is for steroeo cameras only and
(mentioned in P matrix). What I am using now is a mono camera in a simulation world and all the CameraInfo is setted manually based on the message definition and the opencv website you mentioned, so I set R as identity matrix. Maybe I should double check again, thank you.
Please look into your TF tree first.
Do not start rotating anything by hand or changing
CameraInfo
settings.If you have a regular ROS setup with a proper TF tree, this should not be needed.
@gvdhoorn:I have updated my screenshot now, sorry for the inconvenience.