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 imageAlfredo 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 imageAlfredo 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 imagedbworth ( 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 imageAlfredo 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 imagedbworth ( 2013-01-17 06:50:40 -0500 )edit

3 Answers

Sort by » oldest newest most voted
5

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 imagefelix 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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 4,393 times

Last updated: Jan 13 '13