ros2node

Create a ROS 2 node on the specified network

Description

The ros2node object represents a ROS 2 node, and allows you to communicate with the rest of the ROS 2 network. You have to create a node before you can create publishers and subscribers.

Creation

Description

example

node = ros2node(Name) initializes a ROS 2 node with the given Name. The node will be on the network specified by the domain identification 0, unless otherwise specified by the ROS_DOMAIN_ID environment variable.

example

node = ros2node(Name,ID) will initialize the ROS 2 node with Name and connect to the network using domain ID.

Input Arguments

expand all

The name of the node on the ROS 2 network.

Note

In ROS 1, node names are unique and this is being enforced by shutting down existing nodes when a new node with the same name is started. In ROS 2, the uniqueness of node names is not enforced. When creating a new node, use ros2 function to list existing nodes.

The domain identification of the ROS 2 network.

Data Types: double

Properties

expand all

This property is read-only.

The name of the node on the ROS 2 network.

Example: "/node_1"

Data Types: char

This property is read-only.

The domain identification of the ROS 2 network, specified as a non-negative scalar integer between 0 and 232.

Example: 2

Data Types: double

Object Functions

deleteRemove reference to ROS 2 node

Examples

collapse all

Initialize the node, '/node_1', on the default ROS 2 network.

node1 = ros2node('/node_1')
node1 = 
  ros2node with properties:

    Name: '/node_1'
      ID: 0

Initialize the node, '/node_2', on the ROS 2 network identified with domain 2.

node2 = ros2node("/node_2", 2)
node2 = 
  ros2node with properties:

    Name: '/node_2'
      ID: 2

Introduced in R2019b