Best way to shutdown ROS when used with MATLAB Compiler
I have a basic question regarding how to use the robotics.ros library in an application that is compiled using MATLAB Compiler.
The overall structure of my application looks like this:
rosinit(...) % Connect to an external ROS master. pub = rospublisher(...) % Declare publisher to be used in while loop. while 1 % Run this loop until user press Ctrl+C ... send(pub,msg) % Publish data in while loop. end rosshutdown % NEVER REACHED
As I have tried to illustrate in the above code, I'm entering an infinite loop where data is simply published until the user closes the application using Ctrl+C. This means that the rosshutdown command is never reached resulting in the node staying alive.
My question is: What is the best way to shutdown ROS in this scenario?
If the node is not shutdown properly, I receive the following error message:
A node called /some_node has already registered with the ROS master http://localhost:11311. Try creating a node with a different name.
robotics:ros:node:NodeNameExists
I have tried to register an onCleanup function, but that does not seem to be supported by the MATLAB Compiler.
0 Comments
Answers (1)
0 Comments
See Also
Categories
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!