0
$\begingroup$

I am pretty new to gazebo and am currently trying to simulate my physical robot. I have already created a world and am now trying to create a map for it. I am using this repository for all the launch files aswell as this repository for the kobuki description. I have modified the kobuki_ros/kobuki_description/urdf/kobuki_gazebo.urdf.xacro file in the last line and added

      <gazebo reference="hokuyo_link">
<sensor type="ray" name="head_hokuyo_sensor">
  <pose>0 0 0 0 0 0</pose>
  <visualize>false</visualize>
  <update_rate>40</update_rate>
  <ray>
    <scan>
      <horizontal>
        <samples>720</samples>
        <resolution>1</resolution>
        <min_angle>-1.570796</min_angle>
        <max_angle>1.570796</max_angle>
      </horizontal>
    </scan>
    <range>
      <min>0.10</min>
      <max>30.0</max>
      <resolution>0.01</resolution>
    </range>
    <noise>
      <type>gaussian</type>
      <!-- Noise parameters based on published spec for Hokuyo laser
           achieving "+-30mm" accuracy at range < 10m.  A mean of 0.0m and
           stddev of 0.01m will put 99.7% of samples within 0.03m of the true
           reading. -->
      <mean>0.0</mean>
      <stddev>0.01</stddev>
    </noise>
  </ray>
  <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
    <topicName>/tb2/scan</topicName>
    <frameName>hokuyo_link</frameName>
  </plugin>
  </sensor>
  </gazebo>

Whenever I try to launch the turtlebot2_slam.launch.py, the world opens aswell as rviz2, but rviz2 cannot find the fixed frame (map) and adding all LaserScan topics in rviz2 wont show me any marks in rviz2. Ive checked rqt_graph which looks like this: enter image description here and rqt is showing that the only messages received for this topic type are for /tb2/scan. I know that i somehow need to publish the messages on to /scan but changing the topic name in the modified part of kobuki_gazebo.urdf.xacro from /tb2/scan to /scan does not change anything. Can anyone help me out? Thank you in advance!

$\endgroup$

2 Answers 2

1
$\begingroup$

you can do 3 things:

  • change the configuration of slam to listen the specific topic of tb2/scan in the slam configuration params
  • remap the topic when slam is launched to listen /tb2/scan instead scan.
  • remap the topic when turtlebot is launched to publish in /scan instead on /tb2/scan
$\endgroup$
11
  • $\begingroup$ Thank you for the answer! I forgot to add that I have already tried the first option and it didnt work. As for the second and third option there are only a few nodes in the launch file, in which node do I need to remap? (turtlebot2_slam.launch.py=Nodes: rviz2,async_slam_toolbox_node; turtlebot2_spawn_robot.launch.py=Nodes: robot_state_publisher,spawn_entity.py) $\endgroup$
    – DJ1NN
    Jan 23 at 16:10
  • 1
    $\begingroup$ I would think it would also be possible to change the line in the xacro file: ` <topicName>/tb2/scan</topicName>` to be ` <topicName>/scan</topicName>` or just remove it entirely if the default topic for Hokuyo is "/scan." But if there's something else trying to publish on that topic, then there will be conflicts. $\endgroup$
    – proan
    Jan 23 at 16:11
  • 1
    $\begingroup$ And as for remapping, you need to remap either the publisher or all the subscribers so they are all looking at the same topic name. $\endgroup$
    – proan
    Jan 23 at 16:12
  • 1
    $\begingroup$ I was thinking remove the topicName section, but I find it interesting that just changing it doesn't seem to work. For the remapping, you've already got rqt_graph going, so you can use that to sort it all out, hopefully. $\endgroup$
    – proan
    Jan 23 at 16:17
  • 1
    $\begingroup$ @DJ1NN I think slam is using the slam package configuration called 'mapper_params_online_async.yaml'. You can change that file, change the path of the 'slam_params_file' default to os.path.join(get_package_share_directory( 'turtlebot2_gazebo'), 'config', 'slam_toolbox_params.yaml'), or just launch with parameter 'slam_params_file' with the path of 'slam_toolbox_params.yaml'. The most recommended is the last one, just need the path of the params to be used. $\endgroup$
    – rdelgadov
    Jan 23 at 18:03
1
$\begingroup$

I was surprised to see that topic remapping wasn't working, but it looks like the launch files have been written to enable multiple Turtlebots and spawning each one within its own namespace. Each set of topics is remapped by the launch files away from their defaults in the global namespace.

It looks like you can set use_namespace = false on Line 19 of your launch file and edit your xacro file so you're publishing on "/scan": <topicName>/scan</topicName>

$\endgroup$
9
  • $\begingroup$ Thank you for your answer! But isnt use_namespace = false already set in line 41? $\endgroup$
    – DJ1NN
    Jan 23 at 21:37
  • $\begingroup$ It sure looks like that, and at least for the slam_toolbox topics they are in the global namespace. Somehow your laser scan is not in the global namespace though, and that seems to be the issue. $\endgroup$
    – proan
    Jan 23 at 22:49
  • $\begingroup$ Do you maybe have an idea on how to bring the /tb2 topic to the global namespace? Maybe somehow remap in the launch file? $\endgroup$
    – DJ1NN
    Jan 23 at 23:11
  • $\begingroup$ You should be able to remap in the launch file, yes. The turtlebot2_slam.launch.py eventually runs the Kobuki xacro files in turtlebot2_spawn_robot_launch.py, but it looks like turtlebot2_world.launc.py does not pass along that use_namespace = false from the turtlebot2_slam.launch.py. See if your changes starting at Line 83 <github.com/igrak34/turtlebot2-ros2/blob/…> result in the change you desire. $\endgroup$
    – proan
    Jan 24 at 5:53
  • $\begingroup$ The problem is, whenever I launch the turtlebot2_nav2.launch.py and check the rqt_graph, nearly every node/topic is in the tb2 namespace and connected (the /tb2/scan aswell). Doesnt that mean, that the turtlebot2_world.launch.py is working fine and that there should be changes in the turtlebot2_slam.launch.py-file? $\endgroup$
    – DJ1NN
    Jan 24 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.