ROS initiate in MATLAB

Hey guys,
I'm trying to play with ROS interface to MATLAB. I tried the communication between MATLAB and an external ROS master (another computer) and let matlab playing as a node. It works perfectly but the system has a certain amout of delay. According to the description of rosinit in the MATLAB support, it could initalize a local ros master by simply using rosinit without any address. But this doesn't works for me and here are the errors MATLAB showing me.
And a command window jump out showing this:
Does anyone have any idea what's going on? Or is there any prerequsite for running ROS using MATLAB besides python?

4 Comments

Hi,
Based on the snapshot that you shared looks like rosmaster is launced but failed to detect that rosmaster is running by MATLAB.
Yes, you are right. The rosinit requires Python.
Please provide me the following information to debug further.
  • What version of MATLAB that you are using ?
  • Provide me the output of the following commands after you run rosinit in MATLAB command window.
>> cmd = 'tasklist /FI "WINDOWTITLE eq rosmaster - rosmaster --core -p 11311 -w 3" /FO TABLE /NH';
>> [status, result] = system(cmd);
  • Please run the following command to Generate basic diagnostic information in rossupport.txt . Please share the generated file with us.
>> ros.internal.generateSupportFile
Thanks and regards,
Jagadeesh K.
Jagadeesh,
Thanks for your reply! I tried with the command you provided. Nothing shows in the MATLAB command window. The variable "result" has a 1x97 char value as:
'tasklist' is not recognized as an internal or external command,operable program or batch file.
And the variable "status" is 1.
I also attached the rossupport.txt in this reply. The MATLAB I'm using is R2021a education version.
Let me know if there is anyother info you need to help me and thanks again!
Best,
Zihui
Hi Zihui,
The tasklist program of windows is present in the folder C:\WINDOWS\system32. This path is missing from your windows PATH environement variable. Can you please add C:\WINDOWS\system32 to windows PATH enviornement variable and then restart the MATLAB. It should work.
Thanks,
Jagadeesh K.
Jagadeesh,
It works! Really appriciate your help!

Sign in to comment.

 Accepted Answer

Jagadeesh Konakalla
Jagadeesh Konakalla on 29 Nov 2021

0 votes

Good to know that your problem solved.
For others who run into similar issue, the solution is to add C:\WINDOWS\system32 to windows PATH enviornement variable and then restart the MATLAB.

2 Comments

Jagadeesh,
A similar problem shows up and probably related to the previous one. When I'm using "rosinit" without a IP address, it could start the rosmaster in MATLAB and creat a ros global node.
But when I'm using "rosnode list" to check the global nodes, it failed and returning me: Could not retrieve the system state of the ROS master.
And when I'm calling "rosshutdown", it also can't shutdown the roscore service. Error messages are:
>> rosshutdown
Shutting down global node /matlab_global_node_24304 with NodeURI http://DESKTOP-DK9K3V6:50081/
Shutting down ROS master on http://10.228.242.93:11311.
Warning: Error shutting down the ROS master.
> In ros/Core/stop (line 238)
In ros/Core/delete (line 141)
In ros.internal.Global.coreInstance/clearCore (line 243)
In ros.internal/Global/coreInstance (line 228)
In ros.internal/Global/core (line 43)
In rosshutdown (line 23)
I believe it is a problem that the rosmaster wasn't actually being initialized in MATLAB. Is there anyway to fix it?
Best,
Zihui
Hi Zihui,
It is not very clear about the issue that you are facing with rosnode list.
As per the roshsutdown warning, i guess that rosmaster window is closed.
The rosinit command launches a Windows command window. Please do not close the window. You need to keep the window open. The rosshutdown command closes this window automatically.
Please provide more details on the issue that you are facing with rosnode list if you not accidentally closed the window.
Thanks,
Jagadeesh K.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!