custom message error in ros2 with simulink

I made a custom message using the "ros2genmsg()" function in matlab and successfully made my custom message.
And when i test the message in simulink, i get an error message claiming
STD exception 'mwboost::wrapexcept<mwboost::exception_detail::current_exception_std_exception_wrapper<std::invalid_argument> >': 'Connection to process with Exchange: "5f1470ff-8f66-40e9-84fb-5f3bfd116a13 " was lost.' was caught.
I have no idea what i have missed here. When i use the provided message by matlab like "std_msgs" it works fine, but when i use my custom message, the simulink shows error shown above and likely breaks the simulink.
you can see from the picture below, my custom message "tire4_debug_msgs" is shown when i type ros2 msg list
I wanna know how i can fix this and make it right.
i'll give the the needed information for you guys if you leave a comment.
Thanks.
enviroment:
matlab R2022b
ubuntu22.04 / humble

 Akzeptierte Antwort

Prabeen Sahu
Prabeen Sahu am 4 Apr. 2023
Bearbeitet: Prabeen Sahu am 4 Apr. 2023

0 Stimmen

Hi,
Thanks for helping in investigation. This issue might be due to an incompatibility between the libstdc++ shipped with MATLAB and the libstdc++ shipped with "Ubuntu 22.04 LTS".
Please try the following workaround:
  1. Please rename libstdc++.so.6 file located in "matlabroot/sys/os/glnxa64" so that MATLAB cannot find it and is forced to use the system's version of the library. Renaming it to libstdc++.so.6.old should suffice. (where "matlabroot" is root installation directory of MATLAB).
  2. Please delete the previously generated folders during ros2genmsg() execution and run reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true); reg.refresh(true); to remove the existing ros2 custom messages.
  3. Now please regenerate the custom messages using ros2genmsg() in R2022b MATLAB and check if you still face the issues.
-Pabeen

8 Kommentare

준기 홍
준기 홍 am 4 Apr. 2023
You made my day Prabeen, it worked!
I used my tier4_debug_msgs perfectly with no errors.
But i still have one question,
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true); reg.refresh(true);
when i run the command above i can still see my custom message using "ros2 msg list".
Is this just a glitch or can it be a real problem?
Prabeen Sahu
Prabeen Sahu am 4 Apr. 2023
Hi,
Thanks for your confirmation.
To remove existing custom messages, 1st the generated folders should be deleted and then we have to run reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true); reg.refresh(true).
-Prabeen
준기 홍
준기 홍 am 5 Apr. 2023
Thanks for your enormous help,
you made my project one step ahead. Thanks again and keep up the good work!
-J.K Hong
Zalan Deutsch
Zalan Deutsch am 27 Sep. 2023
Bearbeitet: Zalan Deutsch am 27 Sep. 2023
Hi!
I’ve had the same issue with R2023a, also on Ubuntu 22.04 LTS, and this solution worked for me too. However I’ve recently upgraded to R2023b, and I’m facing the same issue, but this solution is not working anymore. Do you have any other suggestions?
Thanks, Zalan
Tobias
Tobias am 30 Jan. 2024
Hi!
I'm also still having that issue with R2023b and Ubuntu 22.04 LTS, when trying to run or compile Simulink models with ROS2 subscribers that apparently use the code generation via this library.
The solution above didn't work for me either. Has anybody found another solution?
Best regards
Tobias
Diego
Diego am 5 Jun. 2024
Hello,
I'm having this problem too, with R2023b and Ubuntu 22.04 LTS when using custom messages. The accepted answer doesn't solve it, and I couldn't find any newer solution in forum.
@Prabeen Sahu do you know why your workaround works for 2022b and 2023a, but not for 2023b?
Regards,
Diego
Mikhail
Mikhail am 21 Apr. 2025
Hello!
Using 2024b, getting that issue and workarounds dont work. Any solution?
Hi,
Please note that the workaround mentioned applies only up to R2023a.
Starting from R2023b, if there is an incompatibility between the libstdc++ shipped with MATLAB and the libstdc++ provided with Ubuntu 22.04 LTS, the ros2genmsg() process will display an error message. This message will also provide guidance on how to resolve the issue.
Please follow these steps:
  • Revert Previous Workarounds:If you have implemented this workaround in R2023b or any later version of MATLAB, kindly revert those changes.
  • Check System Requirements:Please refer to this link for the ROS Toolbox system requirements for each release.
  • Clean Up Previous Custom Messages:Delete any previously generated folders from earlier ros2genmsg() executions.Then, run the following commands in MATLAB to remove existing ROS 2 custom messages :
reg = ros.internal.CustomMessageRegistry.getInstance('ros2', true);
reg.refresh(true);
  • Retry:Try running ros2genmsg() again. If you encounter any issues during the ros2genmsg() process, please let us know.
-Prabeen

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Prabeen Sahu
Prabeen Sahu am 3 Apr. 2023

0 Stimmen

Hi,
please provide us with the following information:
  1. What is the operating system that you are running your MATLAB on?
  2. Are you experiencing this issue only with this particular custom message package or with any custom message?
  3. Could you specify the exact moment when you encounter this issue? Is it when you select the topic or when you start running the model?
  4. When you face this issue, please execute ros2 topic list in the MATLAB command window and verify if the topic appears in the list.
  5. Do you encounter this issue when both the publisher and subscriber are in R2022b MATLAB ( Publish the messages using ros2publisher and subscribe them using ros2subscriber)?
Thanks,
Prabeen

3 Kommentare

준기 홍
준기 홍 am 4 Apr. 2023
Hi Prabeen Sahu, thanks for your interest.
1. My OS is Linux
2.Unfortunately i've not yet tried any other custom message
3.I do not encounter the error when i select the topic, the error occurs when i "run" the model
At first
STD exception 'mwboost::wrapexcept<std::runtime_error>': 'Transport stopped.' was caught.
this error shows up. And whenever i press run again
STD exception 'mwboost::wrapexcept<mwboost::exception_detail::current_exception_std_exception_wrapper<std::invalid_argument> >': 'Connection to process with Exchange: "5f1470ff-8f66-40e9-84fb-5f3bfd116a13 " was lost.' was caught.
this error message repeats.
4.Yes, the topic appears using the command "ros2 topic list" when i encounter the error.
5.I didn't used publisher and subscriber at the same time. I only used the subscriber block in simulink.
I used the subscriber block to subscribe a topic called "/control/trajectory_follower/lateral/diagnostic" and the message type this topic has is "tire4_debug_msgs/Float32MultiArrayStamped".
Hi,
Please run the below mentioned commands in MATLAB to clear the existing custom messages
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true);
reg.refresh(true);
Now please regenerate the custom messages using ros2genmsg() in R2022b MATLAB and check if you still face the issues.
If you still face the issues please use below mentioned code to create both publisher and subscriber in R2022b MATLAB and publish the messages using ros2publisher and subscribe them using ros2subscriber.
nod = ros2node("/testnode");
pub = ros2publisher(nod,"/control/trajectory_follower/lateral/diagnostic","tire4_debug_msgs/Float32MultiArrayStamped");
sub = ros2subscriber(nod,"/control/trajectory_follower/lateral/diagnostic");
msg = ros2message(pub);
pub.send(msg);
msg = sub.LatestMessage
Please check and inform us if you were able to receive the message(msg) without any problems. This testing will aid us in comprehending and pinpointing the issue.
Additionally, please specify which flavor of Linux you are using to run MATLAB.
-Prabeen
준기 홍
준기 홍 am 4 Apr. 2023
First of all my linux is Ubuntu 22.04 LTS (Jammy Jellyfish)
I followed the command line and seems like nothing happend.
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true);
reg.refresh(true);
Tried checking with "ros2 msg list" command but the custom message was still existing.
After this,
nod = ros2node("/testnode");
was succesful but I got stuck at
pub = ros2publisher(nod,"/control/trajectory_follower/lateral/diagnostic","tier4_debug_msgs/Float32MultiArrayStamped");
an error occurs like the picture below.
For the first attempt
Transport stopped.
error shows up terminating the command. And whenever i try again, the same error keeps appearing.
Connection to process with Exchange: "2401ef35-46cf-4c35-90b8-ceef4f75713d " was lost.
I also tried to regenerate my custom message after clearing the message you have noticed.
But regardlessly, got the same result.
Thanks for your help, appreciate it.

Melden Sie sich an, um zu kommentieren.

Prabeen Sahu
Prabeen Sahu am 4 Apr. 2023

0 Stimmen

Hi,
Thanks for helping in investigation. This issue might be due to an incompatibility between the libstdc++ shipped with MATLAB and the libstdc++ shipped with "Ubuntu 22.04 LTS".
Please try the following workaround:
  1. Please rename libstdc++.so.6 file located in "matlabroot/sys/os/glnxa64" so that MATLAB cannot find it and is forced to use the system's version of the library. Renaming it to libstdc++.so.6.old should suffice. (where "matlabroot" is root installation directory of MATLAB).
  2. Please delete the previously generated folders during ros2genmsg() execution and run reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true); reg.refresh(true); to remove the existing ros2 custom messages.
  3. Now please regenerate the custom messages using ros2genmsg() in R2022b MATLAB and check if you still face the issues.
-Pabeen

Kategorien

Produkte

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by