How do I check the state of ROS Master??
29 views (last 30 days)
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.
MathWorks Robotics and Autonomous Systems Team on 6 Dec 2017
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.