Skip to content

Latest commit

 

History

History
146 lines (110 loc) · 5.45 KB

4_Experiment_ROS_Communication_Pi_BaseStation.md

File metadata and controls

146 lines (110 loc) · 5.45 KB

ROS communication through WIFI between onboard computer and base station

1 Install ROS and ROS pkgs for onboard computer

1.1 Install ROS

1.2 Install mavros

  • for team members, please skip this step
  • for others, please ref to Section Simulation_ROS.

2 Enable WIFI communication between onboard computer and base station

2.1 Set static IP address for onboard computer and base station

Connect to WIFI and open Internet settings.

Find Tap IPv4, then choose Manual instead of DHCP.

Then, input an address like 192.168.31.191 where the router's address is 192.168.31.1. Note here, the first three parts must be the same with your router's. Netmask usually should be 255.255.255.0. More details can be found at Subnets of Linux Journey.

2.2 Set ssh for remote login

Install ssh on both machines

    sudo apt install openssh-client openssh-server

and we ca check the installation by

On base station, we can connect to Raspberry Pi with

    ssh username@servername

where servername can be IP address like 192.168.31.171 and site address like example.com

Lets say our username is drone1 and its pws is 123456.

From base station to connect.

  1. We start ssh request

and entre yes then

drawing

  1. We entre the pwd of the user of sever, i.e. drone1, which should be 123456.

drawing

  1. We are now in the server as the user drone1, as you can see a new user name and a new machine name in the terminal.

  2. It is not surprised that we dont want to type ip address every time. Since we know the ip address of the Raspberry Pi wont change, it is nature to think can we type something meaningful as long as my machine can understand my input and link that to the correct ip address.

    Here, we can modify /etc/hosts to enable our machine to do that.

    We give a name for our Raspberry Pi as dronepi1, as

  1. Now, we can connect to the Raspberry Pi with drone1@dronepi1

References on ssh:

  1. How to use SSH (to connect to another computer), Youtube

  2. Running ROS across multiple machines

  3. How to enable SSH on Linux Ubuntu (Easy step by step guide), Youtube

  4. SSH in Chinese

3 Set ROS communication through WIFI between onboard computer and base station

3.1 time synchronisation with ntp

We are going to use ntp service for time synchronisation such that time of onboard computer is based on that of base station.

First of all, install ntp by running

sudo apt install ntp

Check if ntp service is on or not

service --status-all

drawing

Ntp service is on and check its status
sudo systemctl status ntp.service

drawing

Check all the servers

    ntpq -p

3.2 time synchronisation with chrony (todo)

3.2 ROS communication between Raspberry Pi and base station

Once we can ensure Internet connection between the onboard computer and our base station, we can process ROS communication between them.

We only need to specify the IP addresses of onboard computer and base station into ROS.

  1. for the onboard computer, open .bashrc and add
    export ROS_MASTER_URI=http://IP_base_station:11311
    export ROS_IP=IP_onboard_computer
  1. for the base station, open .bashrc and add
    #export ROS_MASTER_URI=http://master:11311

    export ROS_MASTER_URI=http://IP_base_station:11311
    export ROS_IP=IP_base_station

Note: this configuration only works for THE WLAN. We may need to modify the IP addresses for different WLANs.

Also, we need to comment the two commands below and uncomment the one above in order to do local simulation and experiments.

More details can be found at Running ROS on multiple machines.