[ros-users] Remote processes cannot communicate in ros-hydro

William Woodall william at osrfoundation.org
Fri Apr 25 17:58:32 UTC 2014


Sietse,

Please ask questions like this on our Q&A's website, answers.ros.org. We
reserve this list for announcements. See:

http://wiki.ros.org/Support


On Fri, Apr 25, 2014 at 10:44 AM, Sietse Achterop <s.achterop at rug.nl> wrote:

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



-- 
William Woodall
ROS Development Team
william at osrfoundation.org
http://williamjwoodall.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20140425/bcb6eb67/attachment.html>


More information about the ros-users mailing list