フィルターのクリア

How do I check the state of ROS Master??

13 ビュー (過去 30 日間)
Gaston Castro
Gaston Castro 2017 年 12 月 1 日
コメント済み: robotik bocholt 2020 年 5 月 13 日
Hi, I'm a bit confuse with isCoreRunning and isNodeRunning functions.
I want to do a "while(ros::ok)" loop on matlab that checks if the global node is connected and master is reachable.
After using rosinit there is no output where it tells you which is the "ros device" so I don't get how I suppose to use isCoreRunning when it asks for a ros device.
I tried this: isCoreRunning(rosdevice('http://localhost','user','password')) but doesn't work.

回答 (1 件)

MathWorks Robotics and Autonomous Systems Team
Sorry for the late response. Note: In future please select the right product (as I added Robotics System Toolbox in the product list) to get a faster response.
Please note, "rosdevice" was introduced to be able to connect and start/stop Simulink generate ROS nodes only.
Also, note, "isCoreRunning" is a check for if the Master is up and running, whereas "isNodeRunning" takes an argument of "a node name" and checks if the specific "node" is running or not.
Regd, rosinit, "rosinit" will connect your MATLAB to an existing ROS network (if you use >> rosinit('ipadd') OR create a local MATLAB ROS master and connect to it (when you do >> rosinit).
Whereas, rosdevice is a function which should be called by: >> rosd = rosdevice(IPaddress, username, password)
it does not depend on "rosinit" being called or not.
If the intention is to just connect/bring up a ROS Master from MATLAB, then "rosinit" is the command you need. To check if the core is running or not, asking for ">> rosnode list" will not error if the ROS network is connected, else will error.
  2 件のコメント
Gaston Castro
Gaston Castro 2017 年 12 月 6 日
So isCoreRunning should be only used when creating a core within Matlab?
Yes, I want to be able to check if the ROS Master is up and running inside a Matlab script. This would be the way to go?:
while true
try
rosnode list;
catch exp
break;
end
% everything ok, continue working..
end
Seems like an overkill to use 'rosnode list' for this. I understand that this is not the usual "callback-based" usage. But, I'm working with a simulated environment and I need to 'arbitrate' the rate of several concurrent events by stepping the /clock to simulate real time operation when is actually not performing in real time.
Thanks for your answer!
robotik bocholt
robotik bocholt 2020 年 5 月 13 日
Finally this simple trick works for me:
% --- Start Matlab Global Node
try
rosnode list
catch exp % Error from rosnode list
rosinit % only if error: rosinit
end
% ....
Thank you very much!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeServices and Actions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by