MATLAB Answers

0

Cannot access ros services

Asked by Yaron Veksler on 10 Aug 2015
Latest activity Commented on by Robert
on 23 Apr 2019
Hi all
I'm working with the Robotics System Toolbox in Matlab and I cannot access ROS services running on a Ubuntu 12.04 virtual machine with ROS.
I open roscore on the virtual machine, and connect to it in Matlab with no problem. Then I run rosservice list in Matlab and I can see all the services that are availiable, but when I try to use: "rosservice info" or "rosservice type" I get an error saying; rosservice info: Cannot find a MATLAB message class for type Request. rosservice type: A (service name here) service does not exist. To see a list of available services, enter "rosservice list".
In the terminal of the virtual machine I can access the services with no problem.
What can be the problem here?
Thanks guys!

  0 Comments

Sign in to comment.

1 Answer

Answer by Chintan Kaur on 5 Sep 2015

I was facing a similar problem. I got "cannot find a MATLAB message class for type request" error for type and info commands. I also got "ROS failed to create service client error" when I tried creating a client for services running on some other machine.
I debugged and found that the problem for my case was serviceURI returned by getServiceURI function in NetworkIntrospection.m. It was returning named IP address which my machine was unable to resolve and Java internally was throwing unresolved address exception.
The following quick fix solved my problem: Update the network hosts file located at windows/system32/drivers/etc and manually add the IP address against the named server. You can follow some instructions to update the host file on https://support.microsoft.com/en-us/kb/972034
Hope this helps.

  2 Comments

fatima
on 20 Nov 2018
Thanks a lot. It worked for me;
for other newbies like me, the host file in the C:\Windows\System32\drivers\etc should be like this:
# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.1.4 MyMasterComputerName
Notice that the computer name is without http and the port number and you must replace the IP with the your ros master IP address.
Robert
on 23 Apr 2019
I'm using MatLab R2017a and have been getting the same connection error with services in ROS. I tried editting the host file by putting in the IP of the vm running ros with the name UBUNTUPCIP but didn't work in resolving my issue, is there something else you changed in the windows host file?

Sign in to comment.