Contents
  1. Preparation
  2. ROS Communication

Two Ubuntu systems (such as a desktop PC and a robot), connected via Ethernet cable, sharing ROS nodes.

Preparation

For example, I use my desktop Ubuntu as Computer A and the robot’s onboard Ubuntu as Computer B.

To enable multi-machine communication, both computers must first be on the same local network (Wi-Fi or Ethernet). Then open a terminal on each and check the corresponding IP address with ifconfig.

If a computer is connected to multiple networks, make sure you confirm the IP on the LAN shared by both systems. For example:

# 电脑A IP
ifconfig
# enp4s0: 169.254.128.255

# 电脑B IP
ifconfig
# eth0: 169.254.128.20

ROS Communication

(1) Test connectivity

Test whether the two machines can communicate over IP.

  • Computer A: ping [ip_B]
  • Computer B: ping [ip_A]

(2) Set ROS_MASTER_URI

Choose one of the two computers as the master (e.g., the desktop PC) and run the ROS master there; on the slave (e.g., the robot’s onboard computer), set ROS_MASTER_URI.

Open .bashrc on both computers:

sudo gedit ~/.bashrc

On the master (Computer A), set:

export ROS_HOSTNAME=ip_A
export ROS_MASTER_URI=http://ip_A:11311

# 例如
# export ROS_HOSTNAME=169.254.128.66
# export ROS_MASTER_URI=http://169.254.128.66:11311

On the slave (Computer B), set:

export ROS_HOSTNAME=ip_B
export ROS_MASTER_URI=http://ip_A:11311

# 例如
# export ROS_HOSTNAME=169.254.128.20
# export ROS_MASTER_URI=http://169.254.128.66:11311

Done.

(3) Test

On the master, run the turtlesim simulation:

roscore

rosrun turtlesim turtlesim_node

On the slave, run the keyboard teleop to control the turtle on the master:

rosrun turtlesim  turtle_teleop_key