1

I have used this command in the terminal to publish /scan_new topic to the gmapping package in tb3_0 robot ROS_NAMESPACE=tb3_0 rosrun gmapping slam_gmapping scan:=scan_new set_base_frame:=tb3_0/base_footprint set_odom_frame:=tb3_0/odom set_map_frame:=tb3_0/map, but the gampping package is not subscribe to the /scan_new topic. What is the correct command to make sure that gmapping package of the tb3_0 robot is subscribe to the /scan_new topic?

*notes: As in the figure, red word is the ann_publisher node publish to the /scan_new and the gmapping package subscribe to /scan_new topic

rqt graph of multi-robot

AmirulJ
  • 118
  • 1
  • 11

1 Answers1

0

This isn't working as expected because you're giving the node a namespace. When doing this, topic remaps that don't specify a namespace will default to the node's namespace. Here it's /tb3_0, meaning it's actually trying to subscribe to /tb3_0/scan_new. There are a few different ways to fix this, the first being that you can just specify the global namespace with a / like so: scan:=/scan_new . You can also do the same thing, but in a launch file:

<?xml version="1.0"?>
<launch>
    <node ns="tb3_0" name="slam_gmapping" pkg="gmapping" type="slam_gmapping" output="screen">
        <param name="base_frame" value="tb3_0/base_footprint" />
        <param name="odom_frame" value="tb3_0/odom" />
        <param name="map_frame" value="tb3_0/map" />
        <remap from="scan" to="/scan_new" />
    </node>
</launch>

I would highly suggest using the launch file method. It is much cleaner and will be much easier to expand as the number of nodes you want to run increase.

BTables
  • 4,413
  • 2
  • 11
  • 30
  • Firstly, I have try the first method and it works. The gmapping can subscribe /scan_new topic in the namespace. But there are an error "[ WARN] [1632008194.010794315, 950.815000000]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_notifier] rosconsole logger to DEBUG for more information." When I open rviz, the map, laserscan and robot model cannot be displayed. (Should I create a new question for the error?). – AmirulJ Sep 19 '21 at 00:05
  • Secondly, for the second method, do I need to create a new launch file? If do. where can I create it? is it in the catkin_ws/src/turtlebot3/turtlebot3_slam/launch folder? – AmirulJ Sep 19 '21 at 00:05
  • Glad it worked, feel free to accept the answer if you think it was sufficient. Yes, I would create a new question for your first comment. As for the second, if you already have a launch file you're using you can put it there. If not, putting it in the project specific launch folder you mentioned would be the correct place. – BTables Sep 19 '21 at 01:14
  • Thank you @BTables. I have create a new question for the first comment. If you dont mind can you help me answer the question? https://stackoverflow.com/q/69241078/16594158 – AmirulJ Sep 19 '21 at 07:10
  • Hi @BTables can you help me with this question? https://stackoverflow.com/q/69303014/16594158 – AmirulJ Sep 23 '21 at 15:38
  • Hi @BTables if you dont mind, can you help me with this question? https://stackoverflow.com/q/70079102/16594158 – AmirulJ Nov 23 '21 at 10:23