Doesn't get robots /scan events
I'm trying to get robot /scan events notification. This works for me:
// Subscribe to the simulated robot's laser scan topic
laserSub = nh.subscribe("/scan", 1, &MyObject::scanCallback, this);
But when I change the topic to my_robot_name/scan, it doesn't work: I don't get any robot scan notification to my callback.
// Subscribe to the simulated robot's laser scan topic
laserSub = nh.subscribe(my_robot_name + "/scan", 1, &MyObject::scanCallback, this);
I run "rostopic info my_robot_name/scan", and it looks that no publisher to my_robot_name/scan at all.
How can I solve this? Thanks in advance.
Launch file:
<?xml version="1.0"?>
<launch>
<param name="/use_sim_time" value="true" />
<arg name="robot_name" default="robot1"/>
<!-- Launch the turtle bot world -->
<include file="$(find turtlebot_gazebo)/launch/turtlebot_world.launch">
<arg name="world_file" value="$(find turtlebot_gazebo)/worlds/corridor.world"/>
</include>
<!-- Launch stopper node -->
<node name="stopper" pkg="stopper" type="stopper" output="screen" args="$(arg robot_name)">
<remap from="/scan" to="$(arg robot_name)/scan"/>
<remap from="/cmd_vel_mux/input/teleop" to="$(arg robot_name)/cmd_vel_mux/input/teleop"/>
</node>
</launch>
We're gonna need a bit more info. What node is publishing the
/scan
topic?I'm running the gazebo, so /laserscan_nodelet_manager should publish the messages to my node the subscriber to its events. When my subscriber topic is just "/scan", everything works well. However, when I changed the topic to be my_robot_name + "scan", I have no publisher but just my subscriber as previous. Thank you.
@moni213 the reason you don't have the topic is because you changed your subscriber's target to be "my_robot_name + 'scan'", as opposed to the publisher's topic name. You likely need to add a
<remap from=”scan” to=”$(arg scan_topic)”/>
to your<node/>
section of the launch file you are using (feel free to update your question with aforementioned launch file for me to be more specific).@allenh1 I tried to use "remap", as you suggested but it still doesn't work. I still have no publisher to "my_robot_name/scan" but only to "/scan". Subscriber I have in both cases. Here is my updated launch file and my definitions: link text. Do you know what the problem is? Thank you
@moni213 please update your question with a copy and paste of the files instead of using a link to a paste bin. This will keep the question self-contained should that link go bad.