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.

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 30 Jan 2023
Edited: Ryo on 30 Jan 2023
Hello Josh,
Thank you for your advice.
I already set up the environment with python3.9.13 using "ROS Toolbox Preference".
In addition, I could build the environment.
Futhermore, although I set the path without using anaconda, it did not work.
Would you have other possible solutions for this problem ?
Thank you.
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
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,
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.

Categories

Products

Release

R2022b

Asked:

Ryo
on 28 Jan 2023

Commented:

on 2 Feb 2023

Community Treasure Hunt

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

Start Hunting!