AMCL does't work

asked 2020-10-03 13:03:35 -0500

reavers92 gravatar image

updated 2020-10-03 13:20:09 -0500

Hi everyone. My bild is based on rasberry pi4, ros melodic, ydlidar, on a two wheel base. I am trying to do localization by using AMCL, currently the movement of the robot is guaranteed by a simple python script that converts the cmd_vel command sent from the keyboard (turtlebot_teleop keyboard_teleop.launch) into motion. The other node that I launch is: amcl_setup.launch, but the robot is unable to locate itself and moving the robot the cloud of particles does not update. I wanted to know if I’m forgetting some important node or have I made some mistakes? Below I have typed the nodes amcl_setup.launch and amcl.launch, the TF tree and the RVIZ screen where you can see that the laser and AMCL are not working properly. Thanks everyone.

amcl_setup.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" />

 <!--- TF  -->
 <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" />`

amcl.launch:

enter code here

<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"/> ...
(more)
edit retag flag offensive close merge delete

Comments

1

For you amcl node add output="screen" like <node pkg="amcl" type="amcl" name="amcl" output="screen">. This might help you debug. But if you can add the pdf output of rosrun tf view_frames.

Right off the bat I see a big problem which is that you odom->base_link is a static tf. This should instead by a dynamic transform that is published by a node like a robot_localization ekf.

JackB gravatar image JackB  ( 2020-10-03 16:16:18 -0500 )edit
2

AMCL needs a few things to work. 1 - initial pose. You have to tell AMCL where the robot is in the map. This can be done in RVIZ pretty easily. 2 - AMCL only updates if the robot is moving. If you don't have a node publishing ODOM topic and the ODOM-Baselink TF, then AMCL won't run.

billy gravatar image billy  ( 2020-10-03 19:13:39 -0500 )edit

Thank you very much for the quick reply. Yes, my problem is the transformation odom -> base_link, I searched online for various solutions or useful examples, but I did not find anything. Are there scripts .cpp/.py or packages besides robot_localization (this gives compatibility problems in the installation) that I can use to solve this problem? Thanks a lot again for your help

reavers92 gravatar image reavers92  ( 2020-10-05 15:19:37 -0500 )edit

Use an instance of a robot_localization ekf node to generate the odom->base_link tf

JackB gravatar image JackB  ( 2020-10-05 16:05:24 -0500 )edit

If your wheels have encoders it is relatively simple to output odom info directly and in that case I would advise against robot_localization. Do wheels have encoders?

billy gravatar image billy  ( 2020-10-05 17:51:42 -0500 )edit

Yes @billy the wheels have the encoder.

reavers92 gravatar image reavers92  ( 2020-10-06 02:14:34 -0500 )edit

@JackB Unfortunately I tried with robot_localization ekf but it didn't work, I also looked for online guides but nothing worked

reavers92 gravatar image reavers92  ( 2020-10-06 13:34:32 -0500 )edit

What HW are you using? They may have a driver already that publishes Odom for you.

billy gravatar image billy  ( 2020-10-07 11:11:05 -0500 )edit