Main Content

rosnode

Retrieve information about ROS network nodes

Since R2019b

Description

example

rosnode list returns a list of all nodes registered on the ROS network. Use these nodes to exchange data between MATLAB® and the ROS network.

rosnode info nodename returns a structure containing the name, URI, publications, subscriptions, and services of a specific ROS node, nodename.

rosnode ping nodename pings a specific node, nodename, and displays the response time.

nodelist = rosnode("list") returns a cell array of character vectors containing the nodes registered on the ROS network.

example

nodeinfo = rosnode("info",nodename) returns a structure containing the name, URI, publications, subscriptions, and services of a specific ROS node, nodename.

example

rosnode("ping",nodename) pings a specific node, nodename and displays the response time.

Examples

collapse all

Note: This example requires a valid ROS network to be active with ROS nodes previously set up.

Connect to the ROS network. Specify the IP address for your specific network.

rosinit('192.168.17.128')
Initializing global node /matlab_global_node_99071 with NodeURI http://192.168.17.1:64076/

List the nodes available from the ROS master.

rosnode list
/gazebo
/laserscan_nodelet_manager
/matlab_global_node_99071
/mobile_base_nodelet_manager
/robot_state_publisher
/rosout

Shut down the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_99071 with NodeURI http://192.168.17.1:64076/

Connect to the ROS network. Specify the IP address for your specific network.

rosinit('192.168.17.128')
Initializing global node /matlab_global_node_96994 with NodeURI http://192.168.17.1:64267/

Get information on the '/robot_state_publisher' node. This node is available on the ROS master.

nodeinfo = rosnode('info','/robot_state_publisher')
nodeinfo = struct with fields:
         NodeName: '/robot_state_publisher'
              URI: 'http://192.168.17.128:43330/'
     Publications: [3×1 struct]
    Subscriptions: [2×1 struct]
         Services: [2×1 struct]

Shut down the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_96994 with NodeURI http://192.168.17.1:64267/

Connect to the ROS network. Specify the IP address for your specific network.

rosinit('192.168.17.128')
Initializing global node /matlab_global_node_59489 with NodeURI http://192.168.17.1:64471/

Ping the '/robot_state_publisher' node. This node is available on the ROS master.

nodeinfo = rosnode('info','/robot_state_publisher')
nodeinfo = struct with fields:
         NodeName: '/robot_state_publisher'
              URI: 'http://192.168.17.128:43330/'
     Publications: [3×1 struct]
    Subscriptions: [2×1 struct]
         Services: [2×1 struct]

Shut down the ROS network.

rosshutdown
Shutting down global node /matlab_global_node_59489 with NodeURI http://192.168.17.1:64471/

Input Arguments

collapse all

Name of node, specified as a string scalar or character vector. The name of the node must match the name given in ROS.

Output Arguments

collapse all

Information about ROS node, returned as a structure containing these fields: NodeName, URI, Publications, Subscriptions, and Services. Access these properties using dot syntax, for example, nodeinfo.NodeName.

List of node names available, returned as a cell array of character vectors.

Version History

Introduced in R2019b

See Also

|