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
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.