ROS Network Setup

Introduction

Setting up a ROS network allows for communication between different devices. Different participants or nodes all register with a ROS master to share information. The ROS master is unique and each ROS network only has one master. Each node is usually a separate device, although one device can have multiple nodes running. MATLAB® acts as one of these nodes when using it to communicate with ROS.

All devices must be connected to the same actual or virtual network for ROS connections to work. You can create a new ROS master in MATLAB, or you can connect to an existing ROS master that is running on a different device. If you connect to an external master, you have to know the IP address or hostname of the device. The initial ROS master connection is done by calling rosinit. For more information on setting up and using the ROS network, see Network Connection and Exploration.

Data communication is achieved by sending messages using entities called publishers, subscribers, and services. Publishers send data via topic names, which subscribers then receive over the network. Services use clients to request information from a server. For more information on sending messages, see Publishers and Subscribers

Network Connection Layout

The ROS network is a collection of nodes that are all connected to the ROS master. The number of nodes can be quite large depending on your application and devices. When nodes get registered with the master, communication with all other nodes becomes possible. Each node registers different publishers, subscribers, and services on the ROS master to send and receive information between nodes. Even though all nodes in the ROS network are registered with the master, data is exchanged directly between nodes. The following figure shows the layout of a ROS network with two ROS nodes. It is important that all nodes have bidirectional connectivity to share data across the network. Verifying these connections is important during setup.

Each node registers its own Node URI with the master. Other participants in the ROS network will use this URI to contact the node. Again, this URI must be reachable by every other node in the ROS network. To create a node in MATLAB, call rosinit. If a ROS master is already set up, MATLAB detects it and sets the Node URI appropriately. Otherwise, it creates both a ROS master and node that are connected.

By default, each MATLAB instance has a single “global” node. The node has a randomly-generated name assigned to it for uniqueness. All publishers, subscribers, service clients, and service servers will operate on this global node.

See Also

| |

Related Topics