0
$\begingroup$

Rosanswers logo

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.


Originally posted by user_123 on ROS Answers with karma: 23 on 2017-06-01

Post score: 0


Original comments

Comment by user_123 on 2017-06-01:
Please some one help with a solution whether it is possible or not...

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

When one uses more than one machine, the following exports are necessary:

  1. Machine 1: export ROS_MASTER_URI=http://MACHINE_1_IP:11311 export ROS_IP=MACHINE_1_IP
  2. Machine 2: export ROS_MASTER_URI=http://MACHINE_1_IP:11311 export ROS_IP=MACHINE_2_IP
  3. Machine 3: export ROS_MASTER_URI=http://MACHINE_1_IP:11311 export ROS_IP=MACHINE_3_IP

Note that these commands should be in your bashrc or execute them on every terminal before any ros command(rosrun, roslaunch, rostopic etc). I hope this helps


Originally posted by angeltop with karma: 351 on 2017-06-02

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by user_123 on 2017-06-02:
Thank you, it worked after setting this ROS_IP and ROS_MASTER_URI....

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.