<div dir="ltr">Sietse,<div><br></div>Please ask questions like this on our Q&A's website, <a href="http://answers.ros.org">answers.ros.org</a>. We reserve this list for announcements. See:<div><br></div><div><a href="http://wiki.ros.org/Support">http://wiki.ros.org/Support</a><br>

</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 25, 2014 at 10:44 AM, Sietse Achterop <span dir="ltr"><<a href="mailto:s.achterop@rug.nl" target="_blank">s.achterop@rug.nl</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">   Dear list,<br>
<br>
Having trouble communicating between two simple ROS processes when they are on 2 different hosts.<br>
Networking as such is working as proved by netcat. I also turned off the firewall to be sure.<br>
<br>
One process publishes on a topic and another process subscribes to it.<br>
When that process receives a message, it sends a messsage to the first process via another topic.<br>
Running both processes on the same machine as roscore works perfectly, but fail otherwise.<br>
<br>
Both machines are Ubuntu 12.04, 64-bit, with ROS software (hydro) from the repository.<br>
To get it to work, on each machine I do next to the regular catkin sourcing:<br>
<br>
export HOSTNAME=`hostname`<br>
export ROS_IP=<IP-number of this host><br>
export ROS_MASTER_URI=http://<ip-<u></u>number-of-the-master>:11311<br>
<br>
So for example we get (for the lcal machine):<br>
HOSTNAME=fwn-nb4-16-202<br>
ROS_IP=129.125.16.202<br>
ROS_MASTER_URI=<a href="http://129.125.16.202:11311" target="_blank">http://129.125.<u></u>16.202:11311</a><br>
<br>
We have two machines: local (running master) and remote.<br>
When one process is on the remote somehow I only see<br>
that the first process is publishing (via INFO) and on the other nothing is seen.<br>
<br>
rostopic list<br>
  works on the both machines<br>
roswtf<br>
   no errors on the local machine<br>
   but hangs on the remote machine.<br>
     every 5 seconds we see:<br>
        unknown network error contacting node: timed out<br>
<br>
What can be wrong?<br>
<br>
For completeness below the code of the 2 processes.<br>
<br>
     Thanks in advance,<br>
           Sietse<br>
<br>
Node1.cpp:<br>
##############################<u></u>##############################<u></u>#<br>
#include "ros/ros.h"<br>
#include "std_msgs/String.h"<br>
#include <sstream><br>
<br>
void T2Callback(const std_msgs::String::ConstPtr& msg)<br>
{ ROS_INFO("What?: [%s]", msg->data.c_str()); }<br>
<br>
int main(int argc, char **argv)<br>
{<br>
 ros::init(argc, argv, "node1");<br>
 ros::NodeHandle n;<br>
 ros::Publisher T1_pub = n.advertise<std_msgs::String>(<u></u>"T1", 1000);<br>
 ros::Subscriber sub = n.subscribe("T2", 1000, T2Callback);<br>
 ros::Rate loop_rate(2);<br>
<br>
 int count = 0;<br>
do {<br>
<br>
 std_msgs::String msg;<br>
 std::stringstream ss;<br>
 ss << "hello world " << count;<br>
 msg.data = ss.str();<br>
<br>
 ROS_INFO("%s", msg.data.c_str());<br>
 T1_pub.publish(msg);<br>
 ros::spinOnce();<br>
 loop_rate.sleep();<br>
 ++count;<br>
} while (ros::ok());<br>
<br>
 return 0;<br>
}<br>
<br>
<br>
Node2.cpp:<br>
##############################<u></u>##############################<u></u>###<br>
#include <ros/ros.h><br>
#include "std_msgs/String.h"<br>
#include <sstream><br>
<br>
class SubscribeAndPublish<br>
{<br>
public:<br>
  SubscribeAndPublish()<br>
  { //Topic you want to publish on<br>
    T2_pub = n.advertise<std_msgs::String>(<u></u>"T2", 1000);<br>
    //Topic you want to subscribe to<br>
    sub = n.subscribe("T1", 1000, &SubscribeAndPublish::<u></u>callback, this);<br>
  }<br>
<br>
  void callback(const std_msgs::String& msg)<br>
  {     //msg contains data from subscribed topic       <br>
        //Output contains data which is published<br>
        ROS_INFO("Massage received");<br>
        std_msgs::String output;<br>
        std::stringstream ss;<br>
        ss << "You are listening to SublimeFM";<br>
        output.data = ss.str();<br>
        T2_pub.publish(output);<br>
  }<br>
<br>
private:<br>
  ros::NodeHandle n;<br>
  ros::Publisher T2_pub;<br>
  ros::Subscriber sub;<br>
<br>
};//End of class SubscribeAndPublish<br>
<br>
int main(int argc, char **argv)<br>
{<br>
  //Initiate ROS<br>
  ros::init(argc, argv, "subscribe_and_publish");<br>
  SubscribeAndPublish SAPObject;<br>
  ros::spin();<br>
  return 0;<br>
}<br>
<br>
______________________________<u></u>_________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@lists.ros.org" target="_blank">ros-users@lists.ros.org</a><br>
<a href="http://lists.ros.org/mailman/listinfo/ros-users" target="_blank">http://lists.ros.org/mailman/<u></u>listinfo/ros-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>William Woodall<div>ROS Development Team</div><div><a href="mailto:william@osrfoundation.org" target="_blank">william@osrfoundation.org</a></div><div><a href="http://williamjwoodall.com/" target="_blank">http://williamjwoodall.com/</a></div>


</div>