Problem with amcl (laser will not align with map after moving)
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 ...
Does moving straight work but rotation is bad?
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?
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.
The distance between wheels is 155mm, so thats 0.155 m. Should I increase/decrease the value to get a usable odometry?
Try it I suppose.