ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Gmapping and TF frames

asked 2015-04-30 06:27:48 -0500

nouf gravatar image

updated 2015-04-30 06:28:55 -0500

Hello,

I'm using Ubuntu 14.04 and ROS indigo

I published base_link>camera_link frames using static_transform_publisher as follows:

<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0 0 0.1 0 0 0 1 base_link camera_link 100" />

Then, when I started slam_gmapping it gives the following error:

Laser has to be mounted planar! Z-coordinate has to be 1 or -1, but gave: 0.00000

This is solved when I change X value to 0 in the transformation as follows:

<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="1 0 0.1 0 0 0 1 base_link camera_link 100" />

But this doesn't reflect my robot's situation correctly.

Also, I noticed in rviz that camera_depth_optical_frame and camera_rgb_optical_frame frames are upside down (as in the picture) and it is also upside down when I change the X value to 0.

Is this normal?

image description

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-01 19:41:06 -0500

If the Z-coord needs to be 1 or negative 1, have you tried setting it to be 1 or negative 1?

Most camera publishers add additional frames (the optical frames) so that the axes align with the camera lens. This means z-axis out the front of the camera, x positive right, and y positive down (the upper-left corner of the screen is 0,0). This is true for depth cameras such as the Kinect, and I'd image that it's the same for your laser scanner.

edit flag offensive delete link more
0

answered 2017-12-31 08:29:48 -0500

Marvin gravatar image

Solved this problem by changing the depthimage_to_laserscan 'output_frame_id' to "camera_depth_frame" or "camera_link", ie:

 <node pkg="depthimage_to_laserscan" type="depthimage_to_laserscan" name="depthimage_to_laserscan" >
    <param name="scan_height" value="3"/> 
    <param name="output_frame_id" value="camera_depth_frame" />
    <remap from="/image" to="/camera/depth/image_raw" />
</node>

Originally, had the output_frame_id has "camera_depth_optical_frame".

The tf tree is camera_link --> camera_depth_frame --> camera_depth_optical_frame but there's an inbuilt rotation of rpy (-1.571, 0, -1.571) rads in the last transform. Can be seen by:

rosrun tf tf_monitor camera_depth_frame camera_depth_optical_frame

Hence, the required static transform between base_link and the camera can be set as required for the particular robot.

edit flag offensive delete link more
0

answered 2015-05-01 06:02:45 -0500

It seems that the base_frame choosen to launch gmapping might not be the good one. How do you launch gmapping? In the source code of gmapping:

  v.setValue(0, 0, 1 + laser_pose.getOrigin().z());
  tf::Stamped<tf::Vector3> up(v, scan.header.stamp,
                                      base_frame_);
      [...]

  // gmapping doesnt take roll or pitch into account. So check for correct sensor alignment.
  if (fabs(fabs(up.z()) - 1) > 0.001)
  {
    ROS_WARN("Laser has to be mounted planar! Z-coordinate has to be 1 or -1, but gave: %.5f",
                 up.z());
    return false;
  }

Where laser_pose is the tf between the frame "base_frame" ( which is "base_link" by default ) and the frame of your laser

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-30 06:27:48 -0500

Seen: 1,376 times

Last updated: Dec 31 '17