MATLAB Answers

How can I run rosgenmsg from Linux system prompt with -nodisplay option?

1 view (last 30 days)
Andreas Hansen
Andreas Hansen on 7 Sep 2018
Commented: Suvansh Sanjeev on 28 Oct 2020
Hi all.
I would like to make a small script that can generate custom ROS messages using the rosgenmsg function. The script is to be executed on a server that has no displays hooked up, i.e. in a Linux system prompt.
The problem that I'm facing is that it seems not to be possible to run the command with the -nodisplay option without producing a bunch of warnings.
If I run:
matlab -nodisplay -nodesktop -nosplash -r "rosgenmsg('$MSGS_PATH');"
The following warnings are generated:
...
Generating MATLAB code for my_msgs/MyMessageResponse message type.
[Warning: Could not generate MATLAB code for my_msgs/MyMessageResponse.]
[> In robotics.ros.custommsg.internal.CustomMessageLoader/generateMessages (line 267)
In robotics.ros.custommsg.internal.CustomMessageLoader/loadMessages (line 128)
In rosgenmsg (line 46)]
...
If I run the same command without the -nodisplay option on a machine with a display, it works.
Do you have any ideas as to what I can do to fix this issue?
Best Regards, Andreas

Answers (1)

Cam Salzberger
Cam Salzberger on 28 Oct 2020
Hello Andreas, Suvansh,
If you do the -nodisplay option on the machine that it did work on, did it work then? There are two possible general reasons for this issue, and the answer to that question can help determine which it is.
If, on the same machine, it works without -nodisplay and does not work with -nodisplay, then that option is turning off an essential feature needed for custom message generation. If that is the case, I'd suspect that it's interfering with the use of Java, which was used to generate custom ROS messages up through R2020a. I would normally only think that -nojvm would cause that issue, but it's possible -nodisplay would too.
Another possibility is that the -nodisplay is causing some other environment difference that is throwing off the use of rosgenmsg. It may not be starting up in the same directory, or it may have different environment variables set that are causing an issue. Rather than using the -r option, try starting MATLAB interactively in nodisplay mode, and see if you can determine the difference.
If, on the machine with the display, rosgenmsg works with and without -nodisplay, then it's probably a difference between machines. Check that the path is correct to the folder containing the message package folders (using an absolute path is probably safest). Also check that the ROS Custom Message support package is installed for your user on that other machine. Finally, ensure that you have write permissions from MATLAB for that folder path location. You can test that with a simple fopen('test.txt','w') command, or something similar.
The way that ROS is used, and the custom messages are generated, has fundamentally changed in R2020b. If it's an option, you might try upgrading and seeing if that resolves the issue.
Debugging tips:
If you follow the code in robotics.ros.custommsg.internal.CustomMessageLoader/generateMessages, you can see that the warning is appearing as a generic error if something happens when attempting to generate files for each message type. You could insert a breakpoint within the "try" block (even from the command line, though I've not tested with -nodisplay), and run each line on the command line to try to get more information about the fundamental cause of the error.
-Cam
  1 Comment
Suvansh Sanjeev
Suvansh Sanjeev on 28 Oct 2020
Thanks so much for the reply, I appreciate the help Cam! I will try these tips out, and otherwise use a machine with a display.

Sign in to comment.

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!