Error occurs when executing 'rosinit'
显示 更早的评论
Hi, I ran 'rosinit' command on R2022b with Ubuntu 20.04.5 LTS and got the error shown in the image below.

The cause of this error appears to be a timeout. However, I do not know how to resolve it.
Also, I had a problem with the python path before, so maybe there is still a problem with the python path.
I set the python path as shown in the image below.

I also tried to run 'rosinit' on a different port, but it did not work.
Thank you for your help.
回答(1 个)
Josh Chen
2023-1-30
0 个投票
Hello Ryo,
Before running "rosinit", have you used "ROS Toolbox Preference" to setup the environment? In there, if there is any conflict or incompatibility regarding environment, you can see more information. You can open "ROS Toolbox Preference" by navigating to "HOME tab>Environment>Preferences>ROS Toolbox>Open ROS Toolbox Preferences"

Another thing to quickly check is the version of python. As an issue in R2022b, please use python 3.9.13.
Hope this helps,
Josh
4 个评论
Josh Chen
2023-1-31
Hi Ryo,
Thanks for the additional information.
In that case, I think there are two more quick troubleshooting steps we can try out.
1. Launch ROS without MATLAB: could you try and see if it is possible to launch a ROS core on the same Ubuntu without MATLAB? After installing ROS, you can run the following command on terminal to launch a ROS core:
$ source /opt/ros/<distro>/setup.bash
$ roscore
2. If step 1 works, could you try the following command on your MATLAB Command window? This should give you more clear information if there is any error while trying to launch a roscore in MATLAB:
>> roscorecmd = 'rosmaster --core -p 11311 -w 3';
>> [a, b] = ros.internal.runroscmd(roscorecmd)
Thanks,
Josh
Ryo
2023-2-1
Josh Chen
2023-2-2
Hi Ryo,
This issue looks pretty strange. "roscore" is only required by ROS, however, in the error message, it points to something inside ros2_humble (i.e. ROS 2). Based on this error message, I assume you have both ROS and ROS 2 installed?
I am suspecting some environment variables setup got messed up between ROS and ROS 2 on this device. Which could also be the reason why you are not able to launch ros core through MATLAB.
Note that MATLAB does not require you to have ROS installed on your device. You may consider to either dig deeper to see which enviorment variables are causing this issue, delete both ROS and ROS 2, or do a clean reinstallation for ROS.
Best,
Josh
类别
在 帮助中心 和 File Exchange 中查找有关 Publishers and Subscribers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

