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

Communicating between ROS and non-ROS (LabView) via TCP/IP

asked 2011-03-24 05:29:17 -0600

lifesayko gravatar image

updated 2014-01-28 17:09:25 -0600

ngrennan gravatar image

Hello, In our project we're using ROS running on a fit-pc for high-level and NI-sRIO and other NI components for low-level. We need to pass some signals between high-level and low-level.

LabView can read signals from an IP-address, but I can't figure out how to use ROS to simply dump data to a specific port. Can anyone help on this?

As far as I understand, the ROSTCP simply allows connecting different CPUs running ROS very easily, but is not meant for communicating between ROS and non-ROS hardware via TCP/IP.

Thanks in advance.

edit retag flag offensive close merge delete

8 Answers

Sort by ยป oldest newest most voted
10

answered 2011-03-27 08:22:03 -0600

mjcarroll gravatar image

ROSTCP is not intended to be used outside of the ROS architecture, as far as I know. So, I think that you would have to implement some minimum bit of a ROS client library in order to use ROS with labview. You probably want to read up on a few things:

You may also be able to take a look at the Orocos toolchain code to get an idea of how to build a "relay" node of sorts.

I have briefly investigated actually implementing some portion of a client library on LabVIEW, but it seemed that it would be a significant undertaking with little actual gain. If you are primarily interested in creating GUIs and control panels, most of that is successfully handled in ROS already, or easily implemented in something like QT or MatPlotLib.

edit flag offensive delete link more
7

answered 2011-03-27 09:39:41 -0600

Eric Perko gravatar image

updated 2011-03-29 06:03:23 -0600

At CWRU, we also use NI CompactRIOs for low-level control and standard x86 PCs for higher-level processing. The x86 computers run Ubuntu and ROS and are networked to the NI cRIOs.

What we did to facilitate communication between components was to write a simple UDP protocol for the interaction between the cRIO and ROS PC instead of attempting to implement a ROSTCP client on the cRIO side. In this case, all we needed to do is write a listener program on the ROS PC that translated our protocol into ROS messages - and since it's on the x86 PC, we were able to use the existing roscpp and rospy libraries.

For host PC side examples, check out crio_receiver.cpp (latest, but most complex listener node) and pose_broadcaster.py (older, but simpler Python node). These nodes listen to UDP packets from the robot's cRIO and extract information to fill a nav_msgs/Odometry with. There is also the twist_receiver.py that takes Twist messages and outputs UDP commands containing speed and spin rate to the cRIO.

For the cRIO side, you should be able to find some examples of packing and sending UDP (or TCP if you prefer) packets from LabView. We actually used C on the cRIO using the GNU toolchain available on NI's website, but, due to the unknown state of the copyright on some of the files, our cRIO code is not open-source and cannot be redistributed.

Hope that helps. I'd be happy to elaborate more on any of this if you have specific questions.

edit flag offensive delete link more

Comments

I forgot that you Case Western guys love the CompactRIOs. Have you created a ROS wiki page for this? I'm sure a lot of institutions would be very interested in this capability.
mjcarroll gravatar image mjcarroll  ( 2011-03-27 22:24:48 -0600 )edit
Ha... <sarcasm>O we love CompactRIOs alright...</sarcasm> . Nice hardware - terrible software is my experience, which is why we switched to C on the cRIO from LabView in the first place :-). There's a way longer rant in there, but I'll spare ROS Answers. What would you find useful on a wiki page?
Eric Perko gravatar image Eric Perko  ( 2011-03-28 05:36:04 -0600 )edit
7

answered 2012-05-25 11:02:09 -0600

gtr902 gravatar image

Hello. Clearpath has launched a LabVIEW ROS toolkit that links LabVIEW systems to ROS-based algorithms and hardware drivers.

ROS Toolkit for LabVIEW http://sine.ni.com/nips/cds/view/p/lang/en/nid/210716

edit flag offensive delete link more
4

answered 2012-07-05 10:26:35 -0600

Ryan gravatar image

As some people (ourselves included) have pointed out, Clearpath has released a beta of a toolkit for connecting ROS & LabVIEW. It's available here. There's also a tutorial which should be reformatted for NI's site soon - prerelease version is here.

edit flag offensive delete link more
2

answered 2011-04-12 08:33:40 -0600

Hey, we support both ROS and LabVIEW on our mobile products, so it's been occasionally convenient to have the two chat to each other. We've adopted an approach pretty similar to what lifesayko and Eric Perko are doing. In Python, though, packing up a message that LabVIEW's "Unflatten From String" block will recognize is really easy. This is really all there is to it:

class LabviewProxy:
    def __init__(self):
        rospy.init_node('labview_proxy')

        self.ip = rospy.get_param('~ip', '')
        self.port = rospy.get_param('~port', 12345)
        self.sock = socket.socket(socket.AF_INET,
                              socket.SOCK_DGRAM)

        rospy.Subscriber("cmd_vel", Twist, self.cmd_vel_handler)
        rospy.spin()

  def cmd_vel_handler(self, data):
        msg = struct.pack('!dd', data.linear.x, data.angular.z)
        self.sock.sendto(msg, (self.ip, self.port))

You can find the syntax for Python's struct.pack and struct.unpack format strings in the official documentation. From there, it's relatively simple to put together the reverse: listening on a socket and publishing messages from LabVIEW out to ROS.

In the longer run, it would be helpful to have support for the ROS messaging stack in LabVIEW itself (VIs generated from message definitions, etc), but this is a sufficient stopgap in the short term.

edit flag offensive delete link more

Comments

1
Are there actually any open-source tools for generating a VI?
Eric Perko gravatar image Eric Perko  ( 2011-04-14 10:36:07 -0600 )edit
Eric: Not that I'm aware of. Having looked into a bit further, I'm not even sure how one would go about developing it---the VIs are proprietary binary files, and it doesn't look like there's been much work done on documenting them.
mikepurvis gravatar image mikepurvis  ( 2011-04-15 02:50:48 -0600 )edit
It would be possible to generate them from within LabVIEW using VI Scripting: http://sine.ni.com/nips/cds/view/p/lang/en/nid/209110
mikepurvis gravatar image mikepurvis  ( 2011-04-15 06:14:01 -0600 )edit
0

answered 2011-03-28 21:40:00 -0600

lifesayko gravatar image

updated 2011-03-28 22:00:30 -0600

Hi guys,

thanks for the answers, it's really appreciated! Like Eric Perko, we're using the cRIO for low-level and x86 PCs for high-level. I checked out the examples you posted (without understanding much of it... :P), but ended up just making a simple hack to call a simple UDP client and server through shell from ROS (specifically from the listener.cpp from the ROS tutorials), without having ROS handling the UDP directly.

It's rather inelegant and I don't recommend it for anyone with a jot more skills, but for those interested, the relevant additional code is simply:

std::stringstream stream;
stream <<"./udp/client localhost [%s]" << msg->data.c_str();
system(stream.str().c_str());

Where msg->data.c_str() contains the message to be send, and udp/client is the standalone udp client (which needs to be built before hand). Note this is only for sending messages from high to low, but the other way is quite similar.

edit flag offensive delete link more

Comments

I had forgotten to include it, but I updated my answer to include a link to our `twist_receiver.py` node, which does the sending from x86 PC to cRIO in our system, so it's analogous to your udp/client.
Eric Perko gravatar image Eric Perko  ( 2011-03-29 06:05:14 -0600 )edit
-1

answered 2012-05-08 05:20:36 -0600

hisdudeness gravatar image

Hi everybody, I'm new with ROS and I'm successfully using it together with stage. The next step now is using a real robot but I'd like to use it on unsupported hardware. I'd like to use a robot controlled by a cRIO programmed with LabVIEW connected via ethernet to a PC with ROS. The only thing I want is to control the robot's motion but I can't figure out how the communication protocol works. I'm sure ROS will send on a port the topics cmd_vel and I should be able to intercept these topics on the cRIO side but I don't get how to identify the port, if it is configurable and if it's a problem that the robot controller (the cRIO) is not on the same machine where ROS runs. Can anybody give me a hint? Thanks in advance

edit flag offensive delete link more

Comments

2

Email support@clearpathrobotics.com, we'll give you a beta of our ROS Toolkit for LabVIEW (should be on the Tools Network soon, but we can expedite this). :)

Ryan gravatar image Ryan  ( 2012-05-08 05:35:35 -0600 )edit
-1

answered 2012-07-05 08:40:22 -0600

shuo gravatar image

So, I just downloaded the Labview ROS toolkit from clearpathrobotics. It is very new, and I couldn't find any specific information or tutorial on how to use the toolkit. Do you have some links that I can study for it? Thanks very much.

edit flag offensive delete link more

Question Tools

6 followers

Stats

Asked: 2011-03-24 05:29:17 -0600

Seen: 9,460 times

Last updated: Jul 05 '12