ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The reason why your callback is not called is topic names mismatch. Let me explain.
Let's say your variable lidar_input_topic_name_
contains value echo
. You probably expect to subscribe to the topic name /echo
. However, in reality ROS subscribes to <your node name>/echo
because you pass private_node_handle_("~")
into nodeHandle_
variable of the class constructor.
This causes all subscriptions to have your node name in front of topic names. See http://wiki.ros.org/roscpp/Overview/NodeHandles for explanation
So minimal way to fix it is to change
ros::NodeHandle private_node_handle_("~");
to
ros::NodeHandle private_node_handle_
;
I just tested on my machine and it works.
P.S. By the way, my usual practice is to pass two NodeHandle
variables into my constructors - one regular (i.e. without ~
) and one private
Then I use regular handle for all of my publishers, subscribers and global parameters and I use private handle to get node's private parameters with <private nh>.param()
function