Sample Page
Lifestyle BloggerThis is an example page. It’s different from a blog post because it will stay in one place and will
Companion Computers can be used to interface and communicate with ArduPilot on a flight controller unit (FCU) using the MAVLink protocol. By doing this the companion computer gets all the MAVLink data produced by the autopilot (including GPS data) and can use it to make intelligent decisions during flight and reduce computing load over FCU. In this chapter we will configure Raspberry Pi 4 as companion computer. The Raspberry Pi 4 is the latest product in the Raspberry Pi range, boasting an updated 64-bit quad core processor running at 1.4GHz with built-in metal heatsink, USB 3 ports, dual-band 2.4GHz and 5GHz wireless LAN, faster (300 Mbps) Ethernet, and PoE capability via a separate PoE HAT. Some of the features are as below-
Step 1 Download the latest raspios-buster-armhf.img from official site. Use pi imager or any other SD card flashing software like Balena Etcher to flash SD card of 8/16/32 Gb. I am using Raspberry Pi imager and windows laptop to flash the SD card with Raspbian OS (Linux OS)
Step 2 To access Raspberry Pi on ssh (headless), after flashing SD Card, open the directory and add a .txt file and rename it ssh without any file extension.
Use this sd card to boot Raspi Pi 4
Step 1 Connect Raspberry Pi 4 on LAN through ethernet. Scan for its IP address using any IP Scanner tool to find IP allotted. Use that IP to access Raspberry Pi 4 on ssh using Putty client.
Use that IP address to access Raspberry Pi 4 through Putty application
Default username- pi
Default password- raspberry
Step 2 Now we have been able to access Raspberry Pi 4 over LAN. Now we provide it with Wifi credentials to connect over Wifi in future. We need to access raspi-config to save Wifi credentials.sudo raspi-config
Step 3 Go to system options
Step 4 Select wireless LAN
Select country to India
Enter SSID of wifi
Enter password
Select finish
Reboot system. The Raspberry Pi 4 will now connect on wifi.
Reboot the Raspberry Pi when you are done
sudo reboot
After reboot, Raspberry Pi 4 will connect to wifi. We need to find the IP Address by using any IP Scanner tool and using Putty application take remote ssh for configuring Raspberry Pi 4.
Use below mentioned commands to update and upgrade Raspi OS.
sudo apt-get update
sudo apt-get upgrade
As we want to establish MAVlink using UDP protocol over internet using 4G LTE Modem, we need VPN. To install VPN, the process is similar to the once explained above for Beagle Bone Blue in Chapter 4.
Step1 First install Open VPN application on Raspberry Pi 4
sudo apt-get install openvpn
Use WinSCP application on windows to transport the folder VPN_Folder that contains all my .ovpn files. Let me remind you that the VPN_Folder contains .ovpn files for FCU, Companion computer and Ground Control Station (GCS). I only need .ovpn file that I created for Raspberry Pi 4 from the folder. However, I am transporting the entire folder just for the ease of it. I have done the same process for Beagle Bone Blue above in Chapter 4. Please note the relevant file in VPN_Folder for me is raspi_4.ovpn which I renamed after download from OPENVPN website. The folder was first copied to location /home/pi being default directory as shown below:-
Now move the folder from /home/pi to /etc/openvpn for executionsudo mv /home/pi/VPN_Folder /etc/openvpn/
Step 2 Create systemd file for startup at bootsudo nano /etc/systemd/system/vpn.service
[Unit]
Description=VPN Service
After=networking.service
StartLimitIntervalSec=0
[Service]
Type=idle
ExecStart=/usr/sbin/openvpn /etc/openvpn/VPN_Folder/raspi_4.ovpn
Restart=on-failure
RestartSec=1
[Install]
WantedBy=multi-user.target
sudo systemctl enable vpn.service
(only to reload service incase some changes are made)
sudo systemctl start vpn.service
sudo systemctl status vpn.service
sudo systemctl daemon-reload
MAVPROXY is the command line Ground Control Station (GCS) to be installed in companion computer. In my case its Raspberry Pi 4. This MAVPROXY will receive MAVlink data (link between Ardupilot running on FCU i.e Beagle Bone Blue and companion computer) over serial interface and relay it back to the ground control station i.e Mission Planner running over laptop/PC. The MAVlink is installed over secure VPN using UDP protocol over internet connection extended by 4G LTE Modem.
Step 1 First disable SSH login on serial portsudo raspi-config
And in the utility, select “Interfacing Options”:
Step 2. Select Serial Port option
Step 3. When prompted, select no to “Would you like a login shell to be accessible over serial?”
Step 4 When prompted, select yes to “Would you like serial port hardware to be enabled?
Step 5 Reboot the system by clicking yes
sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
pip3 install PyYAML mavproxy --user
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
Incase user permission issues (optional)sudo usermod -a -G dialout <username>
To update an existing installation with the current release on Python 3 based systemspip3 install mavproxy --user –upgrade
Connectivity Diagram Raspberry Pi 4 serial interface will connect with UART1 of Beagle Bone Blue as mentioned below: –
Testing MAVlink over MAVPROXY Testing MAVlink though MAVPROXY Command Line GCS. In order to test the configuration, the below mentioned command will have to be run in Terminal window of Raspberry Pi 4. Both Beagle Bone Blue and Raspberry Pi 4 have to be configured as explained till now to be able to test it.
(a) Both Companion computer and GCS on local LAN, then usepython3 $HOME/.local/bin/mavproxy.py --master=/dev/ttyS0 –out=udp:192.168.1.7:14550
(b) VPN Command Example.python3 $HOME/.local/bin/mavproxy.py --master=/dev/serial0 --out=udp:100.96.1.34:1194
Kindly note that the Raspberry Pi’s serial port will now be usable on /dev/serial0
or dev/ttyS0
and 1194
is port for VPN while local LAN uses 14550
. The IP Address 192.168.1.7
is the IP Address of GCS on local LAN while 100.96.1.34
is IP on VPN. Replace with your own IP Addresses.