Main Content


Determine if ROS or ROS 2 node is running

Since R2019b



running = isNodeRunning(device,modelName) determines if the ROS or ROS 2 node associated with the specified Simulink® model is running on the specified rosdevice or ros2device, device.


collapse all

Connect to a remote ROS device and start a ROS node. Run a ROS core so that ROS nodes can communicate via a ROS network. You can run and stop a ROS core or node and check their status using a rosdevice object.

Create a connection to a ROS device. Specify the address, user name, and password of your specific ROS device. The device already contains the available ROS nodes that can be run using runNode.

ipaddress = '';
d = rosdevice(ipaddress,'user','password');
d.ROSFolder = '/opt/ros/indigo';
d.CatkinWorkspace = '~/catkin_ws_test'
d = 
  rosdevice with properties:

      DeviceAddress: ''
           Username: 'user'
          ROSFolder: '/opt/ros/indigo'
    CatkinWorkspace: '~/catkin_ws_test'
     AvailableNodes: {'robotcontroller'  'robotcontroller2'}

Run a ROS core. Connect MATLAB® to the ROS master using rosinit. This core enables you to run ROS nodes on your ROS device.

Initializing global node /matlab_global_node_84497 with NodeURI

Check the available ROS nodes on the connected ROS device. These nodes listed were generated from Simulink® models following the process in the Get Started with ROS in Simulink example.

ans = 1×2 cell
    {'robotcontroller'}    {'robotcontroller2'}

Run a ROS node and specify the node name. Check if the node is running.

running = isNodeRunning(d,'RobotController')
running = logical

Stop the ROS node. Disconnect from the ROS network. Stop the ROS core.

Shutting down global node /matlab_global_node_84497 with NodeURI

Input Arguments

collapse all

ROS or ROS 2 device, specified as a rosdevice or ros2device object, respectively.

Name of the deployed Simulink model, specified as a character vector. If the model name is not valid, the function returns false.

Output Arguments

collapse all

Status of whether the ROS or ROS 2 node is running, returned as true or false.

Version History

Introduced in R2019b