Ask Your Question

Transform PointCloud2 doesn't work as expected

asked 2020-01-02 16:35:43 -0500

rosNewbie gravatar image

updated 2022-01-22 16:10:14 -0500

Evgeny gravatar image

I tried to transform my pointcloud2 in python like stated here.

But somehow the result is not correct. I am not able to visualize the pointcloud I get as a result in rviz. This is why I tried to just use an empty transformation on my pointcloud and I get some different cloud as a result. Does anyone know what I am doing wrong?


from tf2_sensor_msgs.tf2_sensor_msgs import do_transform_cloud

def transform_pointcloud(self, pointcloud):
    trans = TransformStamped()
    trans.header.stamp = pointcloud.header.stamp
    trans.header.frame_id = pointcloud.header.frame_id
    trans.header.seq = pointcloud.header.seq
    trans.child_frame_id = "corner"
    trans.transform.translation.x = 0
    trans.transform.translation.y = 0
    trans.transform.translation.z = 0
    trans.transform.rotation.x = 0
    trans.transform.rotation.y = 0
    trans.transform.rotation.z = 0
    trans.transform.rotation.w = 0

    newpointcloud = do_transform_cloud(pointcloud, trans)
    return newpointcloud
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-03 02:32:28 -0500

aPonza gravatar image

One thing that jumps to my eye is trans.transform.rotation.w = 0: quaternions should be normalized, so this has to be trans.transform.rotation.w = 1.

edit flag offensive delete link more


@aPonza stupid from me. This fixed it. Thanks alot!

rosNewbie gravatar image rosNewbie  ( 2020-01-03 06:10:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-01-02 16:35:43 -0500

Seen: 171 times

Last updated: Jan 02 '20