Error occurs when executing 'rosinit'

4 views (last 30 days)
Ryo
Ryo on 28 Jan 2023
Commented: Josh Chen on 2 Feb 2023
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.

Answers (1)

Josh Chen
Josh Chen on 30 Jan 2023
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 Comments
Ryo
Ryo on 1 Feb 2023
Hi Josh,
When I tried step 1, I got an error. Whould you tell me what the issue is ?
Traceback (most recent call last):
File "/usr/bin/roscore", line 72, in <module>
import roslaunch
File "/usr/lib/python3/dist-packages/roslaunch/__init__.py", line 62, in <module>
from .scriptapi import ROSLaunch
File "/usr/lib/python3/dist-packages/roslaunch/scriptapi.py", line 42, in <module>
import roslaunch.parent
File "/usr/lib/python3/dist-packages/roslaunch/parent.py", line 54, in <module>
import roslaunch.server
File "/usr/lib/python3/dist-packages/roslaunch/server.py", line 79, in <module>
from rosgraph_msgs.msg import Log
ImportError: cannot import name 'Log' from 'rosgraph_msgs.msg' (/home/ryo/ros2_humble/install/rosgraph_msgs/lib/python3.8/site-packages/rosgraph_msgs/msg/__init__.py)
When I ran step 2, I got information below.
> roscorecmd = 'rosmaster --core -p 11311 -w 3';
>> [a, b] = ros.internal.runroscmd(roscorecmd)
a =
1
b =
'Traceback (most recent call last):
File "/usr/local/MATLAB/R2022b/sys/ros1/glnxa64/ros1/bin/rosmaster", line 34, in <module>
import rosmaster
ModuleNotFoundError: No module named 'rosmaster'
'
Thank you,
Josh Chen
Josh Chen on 2 Feb 2023
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

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!