Anyone been using Ros for LabVIEW toolkit? I have an issue I could use some help resolving...

asked 2020-10-08 09:10:35 -0600

jimc91 gravatar image

updated 2020-10-16 04:58:57 -0600

Has anyone else experience in working with the ROS for LabVIEW toolkit in LabVIEW?

I am having issues and am finding it difficult to get these answered on other forums (NI & GitHUB, both labview related).

I am using;

  • LabVIEW 2018 (operating on Windows 10)
  • 'LabVIEW for ROS' add on
  • ROS kinetic
  • Ubuntu 16.04LTS

I am running Linux & Ubuntu on VMware Workstation 15 Player).

So, I have 2 VIs (one named Publisher and one named Subscriber).

I have 2 python files (one named talker.py and one name listener.py).

The problem: I am able to send data from ROS publisher (talker.py) to my LabVIEW VI subscriber. However, I am unable to send data from LabVIEW publisher VI to ROS subscriber (listener.py).

The 2 python files are below.

I cannot attach the VI`s so I have attached images of them below too, hopefully that is ok.. I followed this tutorial to create both VIs (https://forums.ni.com/t5/ROS-for-LabV...).

talker.py

#!/usr/bin/env python

## Simple talker demo that published std_msgs/Strings messages

## to the 'chatter' topic

import rospy

from std_msgs.msg import String

def talker():

    pub = rospy.Publisher('chatter', String, queue_size=10)

    rospy.init_node('talker', anonymous=True)

    rate = rospy.Rate(10) # 10hz

    while not rospy.is_shutdown():

        hello_str = "hello world %s" % rospy.get_time()

        rospy.loginfo(hello_str)

        pub.publish(hello_str)

        rate.sleep()

if __name__ == '__main__':
    try:

        talker()
except rospy.ROSInterruptException:

    pass

listener.py

#!/usr/bin/env python

## Simple talker demo that listens to std_msgs/Strings published 

## to the 'chatter' topic

import rospy

from std_msgs.msg import String

def callback(data):

    rospy.loginfo(rospy.get_caller_id() + 'I heard %s', data.data)

def listener():

     rospy.init_node('listener', anonymous=True)

    rospy.Subscriber('chatter', String, callback)

    # spin() simply keeps python from exiting until this node is stopped

    rospy.spin()

if __name__ == '__main__':

    listener()

Image of publisher VI

C:\fakepath\publisher vi image.JPG

Image of subscriber VI

C:\fakepath\subscriber vi image.JPG

edit retag flag offensive close merge delete

Comments

Has anyone had this issue?

Which issue? Having to use Labview? ;)

You don't appear to actually describe the issue you have.

As a guess: your Labview publishers and subscribers cannot communicate with your rospy scripts.

If that's the case, you'll want to carefully review your ROS network configuration (ROS_IP, ROS_MASTER_URI, etc). Running (some) things in a VM essentially makes your setup a multi-machine setup, which requires some special configuration.

Labview tends to want to use hostnames, so you'll have to make sure you have a working DNS (ie: can resolve hostnames to IP addresses and vice-versa for all hosts involved in your setup).

Additionally: check firewall settings. ROS nodes use "random ports".

Finally: if your VM is configured to use NAT, you're going to have problems. Try using Host only or Bridged. It is possible to get things to work with NAT, but it's ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2020-10-09 03:43:46 -0600 )edit

Apologies, I have edited the post to include the problem I am having. The issue is being unable to send data from LabVIEW to ROS subscriber, but I can send data from ROS to LabVIEW subscriber VI. My VM is using bridged connection. It is strange that I can send data to LabVIEW, but cannot send data from LabVIEW..

jimc91 gravatar image jimc91  ( 2020-10-16 05:00:54 -0600 )edit

It's likely either a firewall issue or a DNS issue.

As a test, try to use IPs everwhere.

It is strange that I can send data to LabVIEW, but cannot send data from LabVIEW..

No, that's not as strange as you seem to believe it is. There's two separate connections being used, and one side is not playing nice. What you describe is a typical failure mode of these kinds of setups.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-16 05:04:38 -0600 )edit

As a test, try to use IPs everywhere.

What is meant by this? Do I need to have IPs included in my code? My plan is to use another system/laptop and download LabVIEW etc. and try again, maybe it is just an issue with my current system...

jimc91 gravatar image jimc91  ( 2020-10-21 06:18:48 -0600 )edit

As a test, try to use IPs everywhere.

What is meant by this?

don't use hostnames in ROS_MASTER_URI (even Labview uses this). Only IP addresses.

If the Labview integration allows you, configure the ROS_IP setting, instead of ROS_HOSTNAME.

It's been a while since I've done this, but it really almost always came down to a firewall blocking traffic (try disabling it completely just for a test) or either Labview trying to resolve the hostname of your Linux machine or Linux trying to resolve the hostname of your Windows machine, and any of those failing.

If you can ping the Windows machine from your Linux machine by name, and your Linux machine from your Windows machine by name, at least the DNS part should work sufficiently.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-21 07:29:36 -0600 )edit