Configuration of ROS network communication

Keywords: ssh network sudo VPN

Part II: configuration of ROS network communication

brief introduction

This article includes two aspects:
On the one hand, it is the simplest LAN, which can be completed without too much configuration. The disadvantage is that it can only run under the same network segment. The advantage is that it has fast response speed and sensitive feedback.
On the other hand, the analog network segment is formed by the way of remote networking, which is cumbersome to configure, and the response speed is slow and delayed. However, the advantage is that as long as the industrial computer and the upper computer are networked, they can communicate directly, and can realize the function of remote operation nationwide or even globally (when 5G arrives, it can meet the accuracy requirements).
Here are two ways

Local area network configuration

This is the easiest to use. There are two configuration methods:
The first is to open a hotspot with a mobile phone, so that both the upper computer and the industrial computer can connect to the hotspot. In the hotspot configuration of the mobile phone, you can directly find the ip addresses of the two.
The second is that both are connected to a private WIFI (not the public one)
Windows opens the CMD terminal input: ipconfig to view its ip address
Ubuntu input in terminal: ifconfig to view its ip address
When you know your ip address, do the following:

1. Input the hostname of the upper computer to view the name of the upper computer
2. Open bashrc of upper computer and check the ip in it.

ROS? ip is the ip of your host computer
 ROS? Hostname is your host computer name. local
 ROS? Master? URI is the ip address of the IPC
sudo gedit ~/.bashrc		#Change it here
#export ROS_IP='hostname -I'
#export ROS_HOSTNAME = 'hostname.local' of your upper computer
#export ROS_MASTER_URI=http://xxx.xxx.xxx.xxx:11311 ා the ip in this should be replaced by the ip of the 'industrial personal computer'

After the change, save and exit, and go through the new terminal source.

source ~/.bashrc
Then enter the network configuration of IPC

3.SSH to the IPC to operate the IPC terminal. If SSH is rejected, the service may not be opened or the name may be repeated.
(1) start SSH service: https://blog.csdn.net/zh-csdn/article/details/90053018
(2) skip SSH detection repeatability:

sudo vim ~/.ssh/config
#Press i to enter edit mode
#Enter the following:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
#Then save it with vim command (press ESC to exit editing mode, and then enter ': wq!')

Then use ssh to connect the upper computer to the industrial computer remotely (since then, it can be operated remotely)

ssh  xxx@xxx.xxx.xxx     				   #xxx is the name of the industrial computer (the leftmost one of the industrial computer terminal, not the hostname), and then fill in the ip address of the industrial computer, for example, robot@192.168.43.11
#Input password
#Enter bashrc file to change
sudo vim ~/.bashrc 		#Press i to enter editing mode
#Also look for these parameters, and directly replace these three lines with mine.)
export ROS_IP=`hostname -I | awk '{print $1}'`
export ROS_HOSTNAME=`hostname -I | awk '{print $1}'`
export ROS_MASTER_URI=http://`hostname -I | awk '{print $1}'`:11311

#After the modification, it is also saved and exited (the exit method is to press ESC first, and then enter "wq!" Exit)
source ~/.bashrc    #Last source

Using dandelion VPN to realize remote networking

Dandelion VPN is a software that can integrate different Internet users into a simulated LAN. Here, you need to register an account. The upper computer and the industrial computer go to the official website to install it, and then record the account in the upper computer and the industrial computer. After the login is successful, you can find the IP address of the two in the console or the upper computer. Then you can configure the network according to the following steps:

1. Log in to dandelion VPN and enter the same account password as the IPC
2. Go to Dandelion's console, check whether the upper computer and industrial computer are connected to VPN and check whether their IP address changes: Click here to enter the console
3. Enter hostname to view the name of upper computer
4. Check the bashrc of the upper computer. If the ip changes, it needs to be changed.

ROS? ip is the ip of the host computer found in dandelion.
ROS? Hostname is the name of your host computer. local
ROS? Master? URI is the ip address of the IPC found by dandelion

sudo gedit ~/.bashrc		#Change it here
 # ROS_IP=XXX.XXX.XXX.XXX
 #ROS_HOSTNAME = 'your computer's hostname.local'    
 #ROS_MASTER_URI=http://xxx.xxx.xxx.xxx:11311

5. Then take the upper computer and use ssh to connect the industrial computer remotely.

ssh  xxx@xxx.xxx.xxx     				   #xxx is the name of the IPC (the leftmost one), followed by the ip address of the IPC
sudo vim /etc/hosts
#Find a blank row, type
XXX.XXX.XXX		XXX.local        			 #The former is the ip address of the upper computer, the latter is the name of the upper computer, and then save and exit.
#After modification, enter bashrc file for modification.
sudo vim ~/.bashrc
#Also look for these parameters, change and input the ip of the industrial computer obtained from dandelion)
# ROS_IP=xxx.xxx.xxx
# ROS_HOSTNAME=xxx.xxx.xxx
# ROS_MASTER_URI=http://xxx.xxx.xxx:11311

#Save and exit after modification
source ~/.bashrc    #Last source

Since then, the network configuration has been completed. When the industrial control computer roscore is turned on, if the upper computer turns on rviz without error, it indicates success.

Posted by jaronblake on Sun, 27 Oct 2019 23:00:33 -0700