manhon
manhon

Reputation: 683

ROS gmapping laser scan wrong range problem

I found the requirement of laser scan is,

-pi to pi, positive step, and 0 degree is the car's moving forward direction. i.e.

angle_min= -135 * (pi/180); //angle correspond to FIRST beam in scan ( in rad)
angle_max= 135 * (pi/180); //angle correspond to LAST beam in scan ( in rad)
angle_increment =0.25 * (pi/180); // Angular resolution i.e angle between 2 beams

https://answers.ros.org/question/198843/need-explanation-on-sensor_msgslaserscanmsg/

now my lidar is 0 to 180 degree. negative step, and 90 degree is the car's moving forward direction.

angle_min= 0; 
angle_max=  (pi/180); 
angle_increment = -0.25 * (pi/180); 

and it did not work!

I scanned a map. Then I used AMCL to locate the robot.

Even the laser scan are matched in below pic. But the direction is wrong. the yellow arrow is correct one, the red arrow was wrongly estimated by AMCL.

How can I resolve this direction conflict?

thank you.

enter image description here

Upvotes: 0

Views: 1471

Answers (2)

nayab
nayab

Reputation: 2380

You are setting the scan angles incorrectly

angle_min= 0; 
angle_max= pi; 
angle_increment = 0.25 * (pi/180);

For your robot base to laser tf, laser scan rays must match like below

 angle of ray 0   = 0                                     // positive y-axis of robot base
 angle of ray 1   = angle_min + (angle_increment) * 1
 angle of ray 2   = angle_min + (angle_increment) * 2
 .
 .
 angle of ray 360 = angle_min + (angle_increment) * 360 // positive x-axis of robot base
 .
 .
 angle of ray 720 = angle_min + (angle_increment) * 720 // negative y-axis of robot base

Upvotes: 1

Victoria Kepler
Victoria Kepler

Reputation: 136

I don't know why you need explicitly matching moving direction with Rviz, but from what I can see on the screenshot TF node is used. It might affect your robot base frame orientation. You can experiment with its parameters, so you will be able to rotate your robot base frame as @MRFalcon mentioned. Here is a couple of tutorials, should be enough to solve your problem.

Upvotes: 0

Related Questions