Search code examples
roslidar

ROS: tf with RPlidar


I'm using ROS and a RPLidar A2 and apparently the sensor turns clockwise which means its reference frame (see image below) isn't the same as a normal cartesian frame (x axis on 0°, y axis on 90°). So i need to transform the frame via tf to make it easier to understand. Thus, i guess i just need to make a +90° rotation around axis z to match the normal cartesian frame.

How can i make this happen? Do i need to add the static TF transformation information to the launch file?

enter image description here


Solution

  • You are correct that a transform needs to be applied. This can usually be done one of two ways, depending on your overall application. The easiest, like you mentioned, would be to just add a static transform; it can also be done via launch file:

    <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0 0 0 0 0 0.7071 0.7071 parent_frame_id child_frame_id 100" />
    

    Note that the parameters for this node are as follows: x y z qx qy qz qw parent_frame_id child_frame_id period_in_ms

    This works quite well for quick and easy transforms, however, it doesn't scale when many sensors and frames get added in. If you expect more sensors to be added that all need their own transforms, you should instead use a URDF file. It will allow you to easily layout relational data about position/orientation of features on your robot.