AMCL: No laser scan received
I am trying to locate my robot in a given map with the AMCL package, but I'm getting an error
No laser scan received (and thus no pose updates have been published) for x seconds
despite the amcl node subscribing to the right scan topic (see rosgraph below) and laser data being published on the topic (verified with rviz).
I had a look into the source code for the AMCL package and saw a message filter waiting for the tf frames to become available (here in line 479). I noticed that in the tf tree (see below) the 'most recent transform' value for the transform `red/base_footprint' is 0. Has that maybe something to do with the error?
Update: Further investigations by altering the amcl node myself show that tf cannot transform red/base_scan to base_footprint: Couldn't transform from red/base_scan to base_footprint, even though the message notifier is in use
. So this looks like a namespace problem.
Update 2: I solved the problems, one was the wrong tf namespace (i changed
<param name="base_frame_id" value="base_footprint"/>
to
<param name="base_frame_id" value="$(arg color)/base_footprint"/>
), the other was with the simulation timing, I chaned the code and may create a pull request.
My launchfile:
<launch>
<arg name="model" default="burger"/>
<arg name="first_tb3" default="red"/>
<arg name="second_tb3" default="green"/>
<arg name="map_file" default="$(find [package_name]/maps/map_1.yaml" />
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_house.world"/>
</include>
<node pkg="map_server" name="map_server" type="map_server" args="$(arg map_file)">
<group ns="$(arg first_tb3)">
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find [package_name])/urdf/turtlebot3_$(arg model).urdf.xacro" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
<param name="publish_frequency" type="double" value="50.0" />
<param name="tf_prefix" value="$(arg first_tb3)" />
</node>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg first_tb3) -param robot_description" />
<node pkg="amcl" type="amcl" name="amcl" output="screen">
<!--Some params-->
<param name="odom_frame_id" value="odom"/>
<param name="base_frame_id" value="base_footprint"/>
<param name="use_map_topic" value="true" />
<remap from="map" to="/map" />
</node>
</group>
<group ns="$(arg second_tb3)">
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find [packae_name])/urdf/turtlebot3_$(arg model).urdf.xacro" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
<param name="publish_frequency" type="double" value="50.0" />
<param name="tf_prefix" value="$(arg second_tb3)" />
</node>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg second_tb3) -param robot_description" />
</group>
</launch>
Rosgraph:
TF tree: