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

Problem with amcl (laser will not align with map after moving)

asked 2020-03-02 05:24:04 -0500

mimi gravatar image

updated 2020-03-02 06:10:57 -0500

I have created a map using hector_slam, loaded the map via map_server. Run my odometry and amcl for localization, at first the laserscan aligns with the map but then when i move the robot using teleop_twist_keyboard the laserscan gets mis aligned. Is this suppose to act this way? I tried changing the Fixed Frame from(laser,map,odom,base_link) and all has the same result. Can anyone identify whats causing the problem? Thanks in advance :)

ROS melodic ROS Master: Raspberry pi 4 ROS Slave: Raspberry pi 4

Master terminal:

1.roscore
2.mimi.launch

Slave terminal:

mimi.launch

Ros Master Launch file:

<launch>

    <node pkg="amcl" type="amcl" name="amcl" output="screen">
       <!-- Publish scans from best pose at a max of 10 Hz -->
      <param name="odom_model_type" value="diff"/>
      <param name="odom_alpha5" value="0.1"/>
      <param name="transform_tolerance" value="0.2" />
      <param name="gui_publish_rate" value="10.0"/>
      <param name="laser_max_beams" value="30"/>
      <param name="min_particles" value="500"/>
      <param name="max_particles" value="5000"/>
      <param name="kld_err" value="0.05"/>
      <param name="kld_z" value="0.99"/>
      <param name="odom_alpha1" value="0.2"/>
      <param name="odom_alpha2" value="0.2"/>
      <!-- translation std dev, m -->
      <param name="odom_alpha3" value="0.8"/>
      <param name="odom_alpha4" value="0.2"/>
      <param name="laser_z_hit" value="0.5"/>
      <param name="laser_z_short" value="0.05"/>
      <param name="laser_z_max" value="0.05"/>
      <param name="laser_z_rand" value="0.5"/>
      <param name="laser_sigma_hit" value="0.2"/>
      <param name="laser_lambda_short" value="0.1"/>
      <param name="laser_lambda_short" value="0.1"/>
      <param name="laser_model_type" value="likelihood_field"/>
      <!-- <param name="laser_model_type" value="beam"/> -->
      <param name="laser_likelihood_max_dist" value="2.0"/>
      <param name="update_min_d" value="0.2"/>
      <param name="update_min_a" value="0.5"/>
      <param name="odom_frame_id" value="odom"/>
      <param name="resample_interval" value="1"/>
      <param name="transform_tolerance" value="0.2"/>
      <param name="recovery_alpha_slow" value="0.0"/>
      <param name="recovery_alpha_fast" value="0.0"/>
    </node>
    <!--node pkg="tf" type="static_transform_publisher" name="base_laser" args="0 0 0 0 0 0 base_link laser 100"/-->
    <node pkg="teleop_twist_keyboard" name="teleop_twist_keyboard" type="teleop_twist_keyboard.py" output="screen"/> 
    <node pkg="rviz" type="rviz" name="rviz"/>

</launch>

Ros Slave Launch file:

 <launch>
  <node name="rplidarNode"          pkg="rplidar_ros"  type="rplidarNode" output="screen">
  <param name="serial_port"         type="string" value="/dev/ttyUSB0"/>
  <param name="serial_baudrate"     type="int"    value="115200"/><!--A1/A2 -->
  <!--param name="serial_baudrate"     type="int"    value="256000"--><!--A3 -->
  <param name="frame_id"            type="string" value="laser"/>
  <param name="inverted"            type="bool"   value="false"/>
  <param name="angle_compensate"    type="bool"   value="true"/>
  </node>
<node pkg="mimi_2dnav" name="odom" type="odom.py" output="screen"/>
<node pkg="mimi_2dnav" name="subscrib" type="subscrib.py" output="screen"/>
<node pkg="map_server" type="map_server" name="map_server" args="/home/pi/catkin_workspace/src/navigation/map_server/m.yaml" />
<node pkg="tf" type="static_transform_publisher" name="base_link_to_laser" args="0.0 0 ...
(more)
edit retag flag offensive close merge delete

Comments

Does moving straight work but rotation is bad?

stevemacenski gravatar image stevemacenski  ( 2020-03-02 11:19:50 -0500 )edit

We've been tinkering with the odometry for quite a while now, there were settings that makes moving straight align with the map and the rotation is just bad. But for this settings both rotating and moving straight will destroy the alignment. Do you think the problem is all on the odometry?

mimi gravatar image mimi  ( 2020-03-02 11:24:35 -0500 )edit

If you move forward and it works fine, then yes, its probably your odometry. I'd move slowly in rotation and see if you see what's happening (wrong sign, wrong wheel bias distance, etc). If your wheel bias (distance between wheels) is wrong, you're going to have lots of drift problems that will only manifest in rotations because straight forward both motors are spinning at the same speed forward so there's no contribution.

stevemacenski gravatar image stevemacenski  ( 2020-03-02 11:26:22 -0500 )edit

The distance between wheels is 155mm, so thats 0.155 m. Should I increase/decrease the value to get a usable odometry?

mimi gravatar image mimi  ( 2020-03-02 17:52:58 -0500 )edit

Try it I suppose.

stevemacenski gravatar image stevemacenski  ( 2020-03-02 18:24:08 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-03-02 21:56:42 -0500

mimi gravatar image

We fixed it. We rotated the laserscanner by 180° and increased the wheel base by about 27mm. Adjusted the amcl tolerance and odom alphas. Thank you so much for the insight.

edit flag offensive delete link more

Comments

Yeah, a flipped laser and 3cms would do it! Can you close the question as resolved?

Or @gvdhoorn use your admin magic to move this dialog to an answer to accept ;-)

stevemacenski gravatar image stevemacenski  ( 2020-03-03 00:24:53 -0500 )edit

Only a moderator, but there you go.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-03 01:25:18 -0500 )edit

It took me awhile to realize you could do that. I thought I was going crazy on occasion when my comment appeared as an answer and vise versa ;-)

stevemacenski gravatar image stevemacenski  ( 2020-03-03 09:16:55 -0500 )edit

@mimi My Rplidar A1 is also looking backwards due to my design choices, can you tell me if you physically rotated the lidar or just from tf, etc?

berk tepebag gravatar image berk tepebag  ( 2020-04-16 02:15:11 -0500 )edit

Physically, although changing the tf values should work too I guess.

mimi gravatar image mimi  ( 2020-04-16 02:21:39 -0500 )edit

I have changed it physically but no luck. Is this problem looking similar the one you had?

berk tepebag gravatar image berk tepebag  ( 2020-04-16 07:08:45 -0500 )edit

Quite similar. Just to be sure, do you have odometry from wheel encoders?

mimi gravatar image mimi  ( 2020-04-16 07:52:57 -0500 )edit

Also, try changing the parameters in amcl and double check your distance between wheels as it has great impact even just a cm difference.

mimi gravatar image mimi  ( 2020-04-16 07:54:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-02 05:24:04 -0500

Seen: 1,397 times

Last updated: Mar 02 '20