ROS: runNode and stopNode within a Simulink node

1 回表示 (過去 30 日間)
Markus Krovinovitsch
Markus Krovinovitsch 2020 年 7 月 14 日
編集済み: Cam Salzberger 2020 年 7 月 14 日
Hi,
is it possible to start and stop another ROS node within my own Simulink node?

回答 (1 件)

Cam Salzberger
Cam Salzberger 2020 年 7 月 14 日
編集済み: Cam Salzberger 2020 年 7 月 14 日
Hey Markus,
Generally the best way is to have the stop condition built into the node you want to stop, and signal it from the Simulink node. You could use a publisher/subscriber pair to send a signal to the other node to stop itself. Or set a parameter that the other node checks to stop itself. Either of those would probably work better than a service call, since that requires a response from the node with the server.
If you are running in simulation (not codegen) mode, and the node you want to stopis a deployed Simulink node on other hardware, you could potentially use a MATLAB Function block to use rosdevice, to call stopNode. But that's a heck of a workaround. There are also a few workarounds to make system calls from Simulink, I believe, so you could potentially kill processes of non-MATLAB/Simulink nodes.
Starting nodes is probably similar - system calls for non-MATLAB nodes. I'm not sure if there is a way to start a Simulink model from another Simulink model - model reference wouldn't work since it is implemented as one node at the top level. There are probably options for starting another model/function without being blocking (e.g. using a single-shot timer from a MATLAB Function block), and simulation mode probably opens up more options than codegen mode.
Hope this gives you some ideas.
-Cam

カテゴリ

Help Center および File ExchangePublishers and Subscribers についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by