Error creating global node using rosinit

Hello I am trying to ron Ros Noetic with Matlab 2022a on Ubuntu 20.04. After some other fixed errors I get the following error when trying to run rosinit and I don't find the solution anywhere.
>> rosinit
The value of the ROS_MASTER_URI environment variable, http://localhost:11311, will be used to connect to the ROS master.
Launching ROS Core...
Adding required Python packages to virtual environment..Done.
Error using ROSException
Expected identifier to be nonempty.
Error in ros.internal.ROSException (line 55)
validateattributes(varargin{1}, {'char'}, {'nonempty'}, ...
Error in ros.internal.ROSException.fromException (line 206)
rosex = ros.internal.ROSException(ex.identifier, ex.message);
Error in rosinit (line 103)
rosex = ros.internal.ROSException.fromException(ex);
>>
Maybe someone has a idea where the error is coming from and can help me.
Thanks in advance and cheers,
Lukas

8 comentarios

Hello Lukas,
There seem to be two errors happening here. The first is that rosinit tries to start the ROS core and global node, and gets some kind of error. It then attempts to put that error into a ROSException, but the format is messed up, so it is unable to do so. That should be impossible, so I'm not sure how it's happening.
You're only seeing the second error, which is masking the fundamental issue. To get the first error, I'd suggest opening rosinit and putting in a breakpoint at line 103. Then re-run rosinit. Once the breakpoint is hit, run this code:
disp(ex)
getReport(ex)
-Cam
Hi Cam,
Thank you for the fast response. I am actually able to get to the first error but I am still not sure how to solve it.
I put the breakpoint and ran disp(ex) which reveales that a activate file is missing. I checked the folder and only 3 python files are inside but no activate file. I dont know however which format the file needs to have to include it. Following the command window display
K>> rosinit
The value of the ROS_MASTER_URI environment variable, http://localhost:11311, will be used to connect to the ROS master.
Launching ROS Core...
Adding required Python packages to virtual environment..Done.
103 rosex = ros.internal.ROSException.fromException(ex);
K>> disp(ex)
MException with properties:
identifier: ''
message: 'chmod: cannot access '/home/lukas/.matlab/R2022a/ros1/glnxa64/venv/bin/activate': No such file or directory↵'
cause: {}
stack: [10×1 struct]
Correction: []
K>> getReport(ex)
ans =
'Error using ros.internal.createOrGetLocalPython
chmod: cannot access '/home/lukas/.matlab/R2022a/ros1/glnxa64/venv/bin/activate': No such file or directory
Error in ros.internal.runroscmd (line 21)
[~,~,pyenvDir] = ros.internal.createOrGetLocalPython;
Error in ros.Core/start (line 203)
[~, ~] = ros.internal.runroscmd(roscorecmd);
Error in ros.Core/launchCore (line 166)
start(obj);
Error in ros.Core (line 118)
obj.launchCore(isMasterCheckDone);
Error in ros.internal.Global/coreInstance/initCore (line 250)
core = ros.Core(port,'IsMasterCheckDone',true);
Error in ros.internal.Global/coreInstance (line 224)
initCore(port);
Error in ros.internal.Global.core (line 52)
core = ros.internal.Global.coreInstance('init', ...
Error in rosinit>initGlobalCore (line 135)
masterURI = ros.internal.Global.core('init', []);
Error in rosinit (line 92)
args.MasterURI = initGlobalCore(args.MasterURI);'
Hmm, looks like the Python virtual environment didn't get created correctly. Try running this command to force recreation of it:
ros.internal.createOrGetLocalPython(true)
Hi Cam, thank you for your patients and replies. I figured out what was missing. In my case I had to also install the -dev package of python 3.9. This solved one major issue however it is still working with a warning which I dont know if its critical or not.
When I run the mentioned line my output is the following:
Removing previous version of Python virtual environment..Done.
Creating a Python virtual environment...Done.
Adding required Python packages to virtual environment....Done.
Warning: Could not locate 'libpython*.so' library.
> In ros.internal.createOrGetLocalPython (line 254)
ans =
'/home/lukas/.matlab/R2022a/ros1/glnxa64/venv/bin/python3'
So matlab does not find the libpython*.so library. I searched for it and found it in my /usr/lib/x86_64-linux-gnu/ folder. I tried to make it findable using the answere of this thread but can't get it to work properly.
When I run rosinit now it seems to work with warnings and I get the following output:
>> rosinit
The value of the ROS_MASTER_URI environment variable, http://localhost:11311, will be used to connect to the ROS master.
Launching ROS Core...
Warning: Could not locate 'libpython*.so' library.
> In ros.internal.createOrGetLocalPython (line 254)
In ros.internal.runroscmd (line 21)
In ros/Core/start (line 203)
In ros/Core/launchCore (line 166)
In ros.Core (line 118)
In ros.internal.Global.coreInstance/initCore (line 250)
In ros.internal/Global/coreInstance (line 224)
In ros.internal/Global/core (line 52)
In rosinit>initGlobalCore (line 135)
In rosinit (line 92)
Done in 0.28458 seconds.
Initializing ROS master on http://134.28.177.142:11311.
Initializing global node /matlab_global_node_18524 with NodeURI http://lukas-Hansung:37415/ and MasterURI http://localhost:11311.
>>
The command window where matlab is run changes to the following:
lukas@lukas-Hansung:~$ matlab22a
Gtk-Message: 10:28:50.442: Failed to load module "canberra-gtk-module"
Server: (argc: 5) (argv[0]: /usr/local/MATLAB/R2022a/toolbox/ros/bin/glnxa64/libmwros1server) started (pid: 15798)
Current directory: "/home/lukas"
It seems to work with this warningof not finding the libpython*.so file. Do you know wether this is a major issue or if I can work with ros and matlab despite the warning? If not do you maybe have a idea where the error lies? Thanks in advance for the reply
Cam Salzberger
Cam Salzberger el 16 de Mayo de 2022
I haven't seen that issue before, I'm afraid. I'm generally of the opinion of "as long as it works...".
The real test will be if you can generate custom messages, I think. The ROS core uses a small amount of Python (because the core is only developed in Python), but it's a different set of functions from the catkin and colcon build tools that ROS and ROS 2 use for generating custom messages.
Try getting a basic message definition and follow the instructions here to test it out.
-Cam
Hello,
I tried the suggested procedure and unfortunately it did not work. I was able to generate a new message with a lot of warnings but it does not show up in the rosmsg list and I can not use it. I don't know whats the problem and it's really frustrating. At this point I might just try to work with the standard messages or switch to older versions. Just for completion here is the command window output:
>> rosgenmsg('Documents/MATLAB/custom_msgs/')
Identifying message files in folder '/home/lukas/Documents/MATLAB/custom_msgs'..Done.
Warning: Could not locate 'libpython*.so' library.
> In ros.internal.createOrGetLocalPython (line 254)
In rosgenmsg (line 88)
Validating message files in folder '/home/lukas/Documents/MATLAB/custom_msgs'..Done.
[0/1] Generating MATLAB interfaces for custom message packages... 0%Warning: Could not locate 'libpython*.so' library.
> In ros.internal.createOrGetLocalPython (line 254)
In ros.internal/CatkinBuilder/setupPythonAndCmakeTools (line 67)
In ros.internal/ROSProjectBuilder (line 41[1/1] Generating MATLAB interfaces for custom message packages... Done.
Running catkin build in folder '/home/lukas/Documents/MATLAB/custom_msgs/matlab_msg_gen_ros1/glnxa64'.
Build in progress. This may take several minutes...Warning: Could not locate 'libpython*.so' library.
> In ros.internal.createOrGetLocalPython (line 254)
In ros.internal.runroscmd (line 21)
In ros.internal/CatkinBuilder/runBuildSystemCommand (line 53)
In ros.internal/ROSProjectBuilder/runCommand (line 94)
In ros.internal/ROSProjectBuilder/buildPackage (line 555)
In rosgenmsg (line 480)
Build succeeded.build log
To use the custom messages, follow these steps:
1. Add the custom message folder to the MATLAB path by executing:
addpath('/home/lukas/Documents/MATLAB/custom_msgs/matlab_msg_gen_ros1/glnxa64/install/m')
savepath
2. Refresh all message class definitions, which requires clearing the workspace, by executing:
clear classes
rehash toolboxcache
3. Verify that you can use the custom messages.
Enter "rosmsg list" and ensure that the output contains the generated
custom message types.
>> addpath('/home/lukas/Documents/MATLAB/custom_msgs/matlab_msg_gen_ros1/glnxa64/install/m')
>> savepath
>> clear classes
>> rehash toolboxcache
>> rosmsg list
Either way thanks for the help
Lukas
Cam Salzberger
Cam Salzberger el 19 de Mayo de 2022
That is certainly odd to see - that it would finish the build with apparent success, but not allow you to use the custom messages. You could take a look at (and attach) the build log that gets generated (should be linked in the output), but I suspect it won't be entirely helpful.
I've asked my colleague with more experience i the custom message area to take a look at this issue.
-Cam
Lukas Hildebrand
Lukas Hildebrand el 23 de Mayo de 2022
Hello Cam,
thank you for your continuous support. Apparently I was wrong in not beeing able to find the custom messages. I just looked for the wrong entry. I can find the messages I create in the rosmsg list under packages/"messagename". I am able to use the custom messages as well, so I am not hindered by the fact that tie library still can't be found (at least for now). If something else comes up I will mention it in this thread.
Thank you again for all your answeres!
Lukas

Iniciar sesión para comentar.

Respuestas (1)

Juan Andres
Juan Andres el 11 de Oct. de 2022

0 votos

Hello Lukas, I wanted to know if you could solve the problem. Right now I am new to ubuntu and ROS, and I am having exactly the same issue you had. I was able to reach to the point where you get the error report by:
disp(ex)
getReport(ex)
Then you continue to mention you had to install the -dev package, but I can't seem to find this package. How should I install this in order to solve the problem? Thank you very much.

2 comentarios

Cameron
Cameron el 11 de Oct. de 2022
Editada: Cameron el 11 de Oct. de 2022
Hey so I had the exact problem too, and installing the -dev package didn't solve the problem for me. What my problem was is that it was calling the wrong version of python for virtual environments. I installed the correct version of python that it was expecting by using the command
pyenv('Version', '/bin/python3.9')
before running rosinit. I also had to delete everything in the ~/.matlab/R2022a/ros1/glnxa64/venv directory and run the program again to get it to be happy. I hope this helps.
Lukas Hildebrand
Lukas Hildebrand el 12 de Oct. de 2022
Hi Juan,
Try to not only install the -dev package but all of it by using python3.9-full. This solved the issue for me once again when I ran into it again.
Hope it helps!

Iniciar sesión para comentar.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 12 de Mayo de 2022

Comentada:

el 12 de Oct. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by