AMCL on real robot

Hi everyone.
I am trying to do the localization by AMCL, the map is loaded, the lidar publishes the SCAN without problems and the AMCL node starts without problems. but when I start moving the robot its position on the map doesn’t change, the laser frame moves and the AMCL cloud doesn’t update. Below I report the codes I used.
where am i wrong?
Thank you

amcl_demo.launch:

<launch>

  <!-- Run the map server -->
  <arg name="map_file" default="$(find robot_controll)/maps/my_map.yaml"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" >
    <param name="frame_id" value="map"/>
    </node>

     <!-- YDLIDAR_NODE -->
     <node name="ydlidar_node" pkg="ydlidar" type="ydlidar_node" output="screen">
      <param name="port" type="string" value="/dev/ttyUSB0"/>
      <param name="baudrate" type="int" value="128000"/>
      <param name="frame_id" type="string" value="laser"/>
      <param name="low_exposure" type="bool" value="false"/>
      <param name="resolution_fixed" type="bool" value="true"/>
      <param name="auto_reconnect" type="bool" value="true"/>
      <param name="reversion" type="bool" value="true"/>
      <param name="angle_min" type="double" value="-180" />
      <param name="angle_max" type="double" value="180" />
      <param name="range_min" type="double" value="0.1" />
      <param name="range_max" type="double" value="16.0" />
      <param name="ignore_array" type="string" value="" />
      <param name="samp_rate" type="int" value="9"/>
      <param name="frequency" type="double" value="2"/>
     </node>



  <!--- Run AMCL -->
  <include file="$(find robot_controll)/launch/amcl.launch" />


  <node pkg ="tf" 	type="static_transform_publisher" 	name="odom_to_base_link"  	args="0.0 0.0 0.0 0.0 0.0 0.0 /odom /base_link 40"/>
  <node pkg ="tf" 	type="static_transform_publisher" 	name="base_link_to_laser" 	args="0.0 0.0 0.0 0.0 0.0 0.0 /base_link /laser 40" />
  
  
</launch>

amcl.launch:

<launch>

  <arg name="use_map_topic" default="false"/>
  <arg name="scan_topic" default="/scan" />

  <node pkg="amcl" type="amcl" name="amcl">

    <param name="use_map_topic" value="$(arg use_map_topic)"/>
    <!-- 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="gui_publish_rate" value="10.0"/>
    <param name="laser_max_beams" value="60"/>
    <param name="laser_max_range" value="12.0"/>
    <param name="min_particles" value="500"/>
    <param name="max_particles" value="2000"/>
    <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.2"/>
    <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_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.25"/>
    <param name="update_min_a" value="0.2"/>
    <param name="odom_frame_id" value="odom"/>
    <param name="resample_interval" value="1"/>
    <!-- Increase tolerance because the computer can get quite busy -->
    <param name="transform_tolerance" value="1.0"/>
    <param name="recovery_alpha_slow" value="0.0"/>
    <param name="recovery_alpha_fast" value="0.0"/>
    <remap from="scan" to="$(arg scan_topic)"/>
  </node>

</launch>

Hello @reavers92,

Well, it’s hard to help you in this case without being able to test the setup… In any case, I would suggest you start by making sure that all the transforms are OK (have a look at the TF tree with rosrun tf view_frames) and also, check that the frame names and topic names (specially the laser) are properly remapped in your launch file.

Best,

Hello @albertoezquerro,
thanks for the quick reply, I have attached the TF tree in the question, it does not give any problem, it also attached the problem that manifests itself in RVIZ, the parameters I double checked and they seem correct, as a startup file at the moment I only use amcl_demo .launch and a .py file that converts the cmd_vel mess into motion.
some idea?

Thanks again

Hey everyone

I also faced same problem on real robot. Any suggestion to solve this issue. When I launch amcl on real robot, the scan do not match with the map I constructed, rather the laser moves and amcl don’t update the pose of the robot based on the scan data it gets.

Thank you

okay so the problem might be here im guessing, try this and let me know. so in a simulated robot gazebo is taking care of /odom topic. in a real robot we will have to write the necessary code to take care of publishing into the /odom topic, thereby also taking care of the tf of base link and odom respectively. so in the code that publishes the tf of odom topic we specify the parent link as odom and the child as base_link and establish a tf here. when the robot moves the tf between the keeps changing and the robot moves. i hope i made some sense here. i think the problem boils down to this point. let me know if it works. cheers!