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

How can I do a Networking between ROS (Linux) and a C++ Program running on Windows?

asked 2013-01-13 05:32:33 -0500

Alfredo Rodriguez gravatar image

updated 2014-01-28 17:14:49 -0500

ngrennan gravatar image

The C++ program has been made in Visual C++. How can I establish a network with my program and ROS but without having ROS on Windows?, I mean a directly conexion between my program in VC++ and ROS.

I know that ROS can run on Windows, but my goal is not do a network between ROS on windows and ROS on Linux.

I have already created a Client/Server code in C++, so I think that I can implement that code in ROS (with cpp) and my program just to send/recieve messages between them. Is it possible just configure a network on ROS? I mean to set up IP, port, protocol.

I would appreciate your help with tips or example of codes.

Thanks.

edit retag flag offensive close merge delete

Comments

If I do that "dbworth" recomended me, can I use functions of ROS just to obtain values from a device with a ROS driver and then use the TCP connection to send that value to the VC++ program (Computer running on Windows)? I mean send that value to process it in the program in VC++.

Alfredo Rodriguez gravatar image Alfredo Rodriguez  ( 2013-01-14 10:38:03 -0500 )edit

My goal is just send values (that are obtained from a device connected with ROS, for example a sensor) from ROS on Linux to a VC++ program on Windows and process those values in that VC++ program.

Alfredo Rodriguez gravatar image Alfredo Rodriguez  ( 2013-01-14 10:44:59 -0500 )edit

Of course, you can write a little node that subscribes to a topic, then in the callback it writes the data to some variable. Then in the while loop (mentioned below) it sends the current value out via non-ROS TCP socket.

dbworth gravatar image dbworth  ( 2013-01-14 20:52:48 -0500 )edit

Is there a format message to subscribe to a topic? How can I do it? Thanks.

Alfredo Rodriguez gravatar image Alfredo Rodriguez  ( 2013-01-17 06:16:47 -0500 )edit

Okay, step 1 is to do all the ROS Tutorials. It is important. Then make a new package to read the sensor. Write the CPP code for your new node, and get it to print the sensor data to terminal window. Then you can add the code for creating a TCP socket in Linux, and output that data on a socket.

dbworth gravatar image dbworth  ( 2013-01-17 06:50:40 -0500 )edit

3 Answers

Sort by » oldest newest most voted
6

answered 2013-01-13 20:59:32 -0500

dbworth gravatar image

You can simply run a ROS Node on Linux that receives both ROS messages and messages on a standard TCP/IP socket.

Google search for TCP sockets programming for Linux, and winsock programming for VC++. You create a simple TCP socket connection and pass data back and forth. In the ROS node, you have a loop like:

while (ROS::OK) { 
   do stuff in loop 
}

So you put the sockets code in there. The system can be uni-directional (one way communication) of even bi-directional (both ways) works fine.


edit flag offensive delete link more
5

answered 2013-01-13 12:58:46 -0500

clark gravatar image

Rosbridge might be an answer for your case. Basically, you run the Rosbridge server within ROS environment, and implement web socket client within your windows program. For details, you could refer to ROSbridge documentation.

edit flag offensive delete link more

Comments

1
felix k gravatar image felix k  ( 2013-01-14 00:22:40 -0500 )edit
1

answered 2013-01-13 05:42:21 -0500

updated 2013-01-13 05:50:12 -0500

What do you want to do is not too much well explained. But in any case, here you are some important hints about using a heterogeneus network for robotic applications with/without ROS:

ROS currently has only a basic and experimental support for windows: http://www.ros.org/wiki/win_ros. You will have to test the basic examples of this package. Also make sure that the ROS_MASTER_URI variable is properly set.

Of course you an alternative is interconecting processes using standar IPC mechanism: from simple sockets to complex web services. You can also use XML-RPC++. However, if you use these mechanisms you will lose the majority of the runtime ROS benefits as Distributed System: introspection, data standarization in the comunications, parameter server, services, dynamic reconfigure. It also includes the powerful publish/subscribe (topics) that ROS provides: A ROS node/process can comunicate with other process in other machines in a decoupled way. That is, without knowing neither: the IP of the machine nor the proces PID nor the underlaying socket port.

Also many of the development and deployment ROS features like roslauch/topic remaping, etc.

edit flag offensive delete link more

Comments

Sorry but I disagree with your point that "A ROS node can communicate with other process in other machines without knowing their IP, PID or port". Please correct me @gvdhoorn and @dbworth in case my understanding needs an improvement. A ROS node (say N1) gets to communicate with another node (say N2) only when N1 needs to subscribe to messages that are actually being published by the other node N2 on a particular topic. And when N1 needs to receive the messages from this particular topic, it first and foremost communicates with Master, letting him know that it (N1) is interested in receiving messages from that topic. After this, the master sends the list of publisher nodes to N1. This list contains the IP address, port details of the publisher N2. So, now N1 uses the IP address and port of N2 to negotiate the sharing of messages.

Aakashp gravatar image Aakashp  ( 2020-11-29 13:17:06 -0500 )edit

@Aakashp: you seem to be ignoring the fact that an application (and also single nodes) always consist of multiple levels of abstraction. At many of these levels, a ROS node can communicate with others without knowing anything about the underlying network details (such as IP and port).

For all intents and purposes, those are the levels at which ROS node authors typically work: you create a subscriber by specifying a topic name and a callback. You don't enter an IP and/or port anywhere. Same for publishers.

That's what the OP of this answer describes.

If you have any further questions about this, please post a new question, as comments on questions from 2013 have almost 0 visibility.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-30 02:20:33 -0500 )edit

@gvdhoorn: Many thanks for throwing light on this. I agree with what you say. Actually, I was making the point that even though the details of connection-establishment are abstracted from the author of ROS node, still, a node does utilise such low-level details (such as IP and port number) of other node to communicate with it. I was ignoring abstraction while I commented earlier.

Ok, I will keep in mind of posting new question henceforth instead of commenting on such old questions. Thanks again!

Aakashp gravatar image Aakashp  ( 2020-11-30 11:55:52 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-01-13 05:32:33 -0500

Seen: 11,079 times

Last updated: Jan 13 '13