ROS Distributed Communications

Toss two nights, and finally out through a local ros master-slave communications, said the next need to pay attention.

First, to ensure that the master and slave in a network, can ping each other, that goes without saying.

Configuring the host name and slave name

Configuring the host name and slave name made a stupid mistake, the consequences are serious, require special attention, such as my command line looks like

redrose007@redrose007-desktop:~$

I take it for granted that the host name redrose007, after this has been used to configure, although the two machines can ping, but can not communicate with each other using the ROS.

The correct approach is through the hostname command to view the host name redrose007-desktop, configured with this in order to ensure communication.

Host Configuration

/ Etc / hosts configuration, the slave configuration can ping

192.168.3.110 redrose007-desktop           #从机
192.168.3.111 ros01-virtual-machine        #主机

ping redrose007-desktop                    #畅通

Slave Configuration

/ Etc / hosts configuration, the configuration can ping host

192.168.3.110 redrose007-desktop           #从机
192.168.3.111 ros01-virtual-machine        #主机

ping ros01-virtual-machine                 #畅通

Configuring the system environment variables

Host Configuration

~ / .Bash Configuration

export ROS_HOSTNAME=ros01-virtual-machine
export ROS_MASTER_URI=http://192.168.3.111:11311
export ROS_IP=192.168.3.110

Slave Configuration

~ / .Bash Configuration

export ROS_HOSTNAME=redrose007-desktop
export ROS_MASTER_URI=http://192.168.3.111:11311

Turn off the firewall

ubuntu system firewall turned off by default, but still make sure that both machines firewalls are closed.

Check the firewall status, if it is inactive means that the firewall is turned off.

sudo ufw status verbose

If the firewall is not turned off, use the following command to shut down.

sudo ufw disable

verification

After configuration, the host starts talker program, attention needs to use beginner_tutorials source in github for installation, installation steps at github readme reference works.

rosrun beginner_tutorials talker

Receive messages from the machine

redrose007@redrose007-desktop:~$ rostopic list
/chatter
/rosout
/rosout_agg
redrose007@redrose007-desktop:~$ rostopic echo /chatter
data: "Hi! Default Message! :\t20"

Talker to start the slave program, the host can receive the message, the completion of the master slave configuration.

Guess you like

Origin www.cnblogs.com/weiweiting/p/12578070.html