asked 2011-03-24 10:29:17 -0500lifesayko
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.
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.
answered 2012-05-25 16:02:09 -0500gtr902
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
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.
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.
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.
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.
answered 2012-05-08 10:20:36 -0500hisdudeness
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
answered 2012-07-05 13:40:22 -0500shuo
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.
Asked: 2011-03-24 10:29:17 -0500
Seen: 1,936 times
Last updated: Jul 05 '12