ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

setup problem for a publisher/subscriber running on different PCs

asked 2014-12-08 16:14:49 -0500

Nicola Pedrocchi gravatar image

updated 2014-12-09 03:24:57 -0500

bvbdort gravatar image

Hi,

I am really a ROS and Baxter beginner, and I am experiencing strange behaviour of the ROS communication layer that I do not understand. Consider two trivial scripts, a publisher and a subscriber:

publisher.py:

import rospy
from std_msgs.msg import String

pub = rospy.Publisher('foo', String)
rospy.init_node('publisher_test')
r = rospy.Rate(10)
while not rospy.is_shutdown():
    pub.publish("hello world")
    r.sleep()

subscriber.py:

import rospy
from std_msgs.msg import String

def callback(data):
    rospy.loginfo("I heard %s",data.data)

rospy.init_node('subscriber_test')
rospy.Subscriber("foo", String, callback)
rospy.spin()

The ROS_MASTER is running in the Baxter internal PC.

I have 4 different shell opened: two shells in my PC, both configured launching the script baxter.sh, and two SSH shells - both configured launching the script baxter.sh. I have done 4 different experiment:

  1. If I launch both the publisher and the subscriber from my PC, no problem arises.

  2. If I launch both the publisher and the subscriber from the Baxter PC, no problem arises.

  3. If I launch the publisher in from my PC and the subscriber from Baxter PC, no problem arises.

  4. If I launch the publisher in the Baxter internal PC and the subscrber in my PC, the subscriber does not receive any message. If I launch "rostopic echo /foo" from my PC, it does not print anything. However, if I launch "/robot/joint_states" from my PC, no problem arises.

The PC and the baxter are direct connected with a twisted cable.

Some ideas?

Many thanks,

Sincerely Nicola

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-12-09 22:25:40 -0500

ahendrix gravatar image

You probably need to set the ROS_IP environment variable on Baxter.

For a more detailed explanation, check out my ROSCon talk from 2013: slides and video

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-12-08 16:14:49 -0500

Seen: 349 times

Last updated: Dec 09 '14