Rosbag play & publisher-subscriber in ROS Indigo
I want to play the contents of a bag file in one machine, and get the details by subscribing to specific topics on another machine.The ROS master is running in the first machine. In another terminal of the first machine, I have played the bagfile, using rosbag play --clock basic_localization_stage.bag. In the second machine, I have written a simple code of subscriber as follows-
#include "ros/ros.h"
#include "ros/console.h"
#include "sensor_msgs/LaserScan.h"
#include "tf/tfMessage.h"
void laser_callback(const sensor_msgs::LaserScan::ConstPtr& msg)
{
ROS_INFO("\nI heard in topic base_scan %f",msg->scan_time);
}
int main(int argc,char ** argv)
{
ros::init(argc,argv,"subscriber1");
ros::NodeHandle node_;
ros::Subscriber sub1=node_.subscribe("base_scan",1000,laser_callback);
ros::spin();
return 0;
}
But even after subscribing, I am not getting any output in second machine terminal. The rosbag play command publishes on base_scan & tf topics,but if the node is subscribed to base_scan topic, it is not showing any output.
Please some one help with a solution whether it is possible or not...