Fri, Apr 22, 22, configure and setup raspi to enable streaming on mavlink and to advance to LTE transmission
This is a draft, the content is not complete and of poor quality!

pilotpi-rpios

PilotPi with Raspberry Pi OS

Developer Quick Start

OS Image

The latest official Raspberry Pi OS Lite image is always recommended.

To install you must already have a working SSH connection to RPi.

Setting up Access (Optional)

Hostname and mDNS

mDNS helps you connect to your RasPi with hostname instead of IP address.

sudo raspi-config

Navigate to Network Options > Hostname. Set and exit. You may want to setup passwordless auth as well.

Setting up OS

config.txt

sudo nano /boot/config.txt

Replace the file with:

# enable sc16is752 overlay
dtoverlay=sc16is752-spi1
# enable I2C-1 and set the frequency to 400KHz
dtparam=i2#c_arm=on,i2c_arm_baudrate=400000
# enable spidev0.0
dtparam=spi=on
# enable RC input
enable_uart=1
# enable I2C-0
dtparam=i2c_vc=on
# switch Bluetooth to miniuart
dtoverlay=miniuart-bt

cmdline.txt

sudo raspi-config

Interfacing Options > Serial > login shell = No > hardware = Yes. Enable UART but without a login shell on it.

sudo nano /boot/cmdline.txt
```#

Append `isolcpus=2` after the last word.
The whole file would be:

```sh
console=tty1 root=PARTUUID=xxxxxxxx-xx rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait isolcpus=2

This tells the Linux kernel not to schedule any process on CPU core 2. We will manually run PX4 onto that core later.

Reboot and SSH onto your RasPi.

Check UART interface:

ls /dev/tty*

There should be /dev/ttyAMA0, /dev/ttySC0 and /dev/ttySC1.

Check I2C interface:

ls /dev/i2c*

There should be /dev/i2c-0 and /dev/i2c-1

Check SPI interface

ls /dev/spidev*

There should be /dev/spidev0.0.

rc.local

In this section we will configure the auto-start script in rc.local.

sudo nano /etc/rc.local

Append below content to the file above exit 0:

echo "25" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio25/direction
if [ $(cat /sys/class/gpio/gpio25/value) -eq 1 ] ; then
        echo "Launching PX4"
        cd /home/pi/px4 ; nohup taskset -c 2 ./bin/px4 -d -s pilotpi_mc.config 2 &> 1 > /home/pi/px4/px4.log &
fi
echo "25" > /sys/class/gpio/unexport

Save and exit.

:::note Don’t forget to turn off the switch when it is not needed. :::

CSI camera

:::note Enable CSI camera will stop anything works on I2C-0. :::

sudo raspi-config

Interfacing Options > Camera

Building the code

To get the very latest version onto your computer, enter the following command into a terminal:

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

:::note This is all you need to do just to build the latest code. :::

Cross build for Raspberry Pi OS

Set the IP (or hostname) of your RPi using:

export AUTOPILOT_HOST=192.168.X.X

or

export AUTOPILOT_HOST=pi_hostname.local

Build the executable file:

cd PX4-Autopilot
make scumaker_pilotpi_default

Then upload it with:

make scumaker_pilotpi_default upload

Connect over ssh and run it with:

cd px4
sudo taskset -c 2 ./bin/px4 -s pilotpi_mc.config

Now PX4 is started with multi-rotor configuration.

If you encountered the similar problem executing bin/px4 on your Pi as following:

bin/px4: /lib/xxxx/xxxx: version `GLIBC_2.29' not found (required by bin/px4)

Then you should compile with docker instead.

Before proceeding to next step, clear the existing building at first:

rm -rf build/scumaker_pilotpi_default

Alternative build method (using docker)

The following method can provide the same tool-sets deployed in CI.

If you are compiling for the first time with docker, please refer to the offical docs.

Execute the command in PX4-Autopilot folder:

./Tools/docker_run.sh "export AUTOPILOT_HOST=192.168.X.X; export NO_NINJA_BUILD=1; make scumaker_pilotpi_default upload"

:::note mDNS is not supported within docker. You must specify the correct IP address every time when uploading. :::

:::note If your IDE doesn’t support ninja build, NO_NINJA_BUILD=1 option will help. You can compile without uploading too. Just remove upload target. :::

It is also possible to just compile the code with command:

./Tools/docker_run.sh "make scumaker_pilotpi_default"

Post-configuration

You need to check these extra items to get your vehicle work properly.

Mixer file

Mixer file is defined in pilotpi_xx.conf:

mixer load /dev/pwm_output0 etc/mixers/quad_x.main.mix

All available mixers are stored in etc/mixers. You can create one by yourself as well.

External compass

In the startup script(*.config), you will find

# external GPS & compass
gps start -d /dev/ttySC0 -i uart -p ubx -s
#hmc5883 start -X
#ist8310 start -X

Uncomment the correct one for your case. Not sure which compass comes up with your GPS module? Execute the following commands and see the output:

sudo apt-get update
sudo apt-get install i2c-tools
i2cdetect -y 0

Sample output:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- 0e -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

1e indicates a HMC5883 based compass is mounted on external I2C bus. Similarly, IST8310 has a value of 0e.

:::note Generally you only have one of them. Other devices will also be displayed here if they are connected to external I2C bus.(/dev/i2c-0) :::

Raspberry Pi 2/3 Navio2 Autopilot

:::warning PX4 does not manufacture this (or any) autopilot. Contact the manufacturer for hardware support or compliance issues. :::

:::warning PX4 support for this flight controller is experimental. :::

This is the developer “quickstart” for Raspberry Pi 2/3 Navio2 autopilots. It allows you to build PX4 and transfer to the RasPi, or build natively.

Ra Pi Image

OS Image

Use the Emlid RT Raspbian image for Navio 2. The default image will have most of the setup procedures shown below already done.

:::warning Make sure not to upgrade the system (more specifically the kernel). By upgrading, a new kernel can get installed which lacks the necessary HW support (you can check with ls /sys/class/pwm, the directory should not be empty). :::

Setting up Access

The Raspbian image has SSH setup already. Username is “pi” and password is “raspberry”. You can connect to your RPi2/3 over a network (Ethernet is set to come up with DHCP by default) and then proceed to configure WiFi access. We assume that the username and password remain at their defaults for the purpose of this guide.

To setup the RPi2/3 to join your local wifi, follow this guide.

Find the IP address of your Pi from your network, and then you can proceed to connect to it using SSH.

ssh pi@<IP-ADDRESS>

Expand the Filesystem

After installing the OS and connecting to it, make sure to expand the Filesystem, so there is enough space on the SD Card.

Disable Navio RGB Overlay

The existing Navio RGB overlay claims GPIOs used by PX4 for RGB Led. Edit /boot/config.txt by commenting the line enabling the navio-rgb overlay.

#dtoverlay=navio-rgb

Changing Hostnames

To avoid conflicts with any other RPis on the network, we advise you to change the default hostname to something sensible. We used “px4autopilot” for our setup. Connect to the Pi via SSH and follow the below instructions.

Edit the hostname file:

sudo nano /etc/hostname

Change raspberry to whatever hostname you want (one word with limited characters apply)

Next you need to change the hosts file:

sudo nano /etc/hosts

Change the entry 127.0.1.1 raspberry to 127.0.1.1 <YOURNEWHOSTNAME>

Reboot the Pi after this step is completed to allow it to re-associate with your network.

Setting up Avahi (Zeroconf)

To make connecting to the Pi easier, we recommend setting up Avahi (Zeroconf) which allows easy access to the Pi from any network by directly specifying its hostname.

PilotPi with Ubuntu Server

:::warning Ubuntu Server on RPi 4B consumes a lot of current and generates a lot of heat. Design for better heat dissipation and high power consumption when using this hardware. :::

Developer Quick Start

OS Image

Both armhf and arm64 arch are supported.

armhf

arm64

Latest OS

Please refer to official cdimage page for any new updates.

First boot

When setting up RaPi’s WiFi for the first time we recommended using a wired Ethernet connection between your home router and RPi, and a monitor and keyboard.

Before booting

Mount the SD card onto your computer and modify the network settings. Please follow the official instruction here.

Now plug the SD card onto your Pi and boot for the first time. Make sure you have shell access to the RPi - either SSH connection over wired Ethernet, or direct accessing with keyboard and monitor.

WiFi region

First install required package:

sudo apt-get install crda

Edit the file /etc/default/crda to change the correct WiFi region. Reference List

sudo nano /etc/default/crda

Then your Pi will able to join your WiFi network after reboot.

Hostname and mDNS

Let’s set up hostname at first.

sudo nano /etc/hostname

Change the hostname to whatever you like. Then install the package required by mDNS:

sudo apt-get update
sudo apt-get install avahi-daemon

Perform a reboot. raspi

sudo reboot

Regain the accessibility through WiFi connection after the above operation.

ssh ubuntu@pi_hostname.local

Password-less Auth (Optional)

You may want to setup passwordless auth as well.

Setting up OS

config.txt

The corresponding file in Ubuntu is /boot/firmware/usercfg.txt.

sudo nano /boot/firmware/usercfg.txt

Replace the file with:

# enable sc16is752 overlay
dtoverlay=sc16is752-spi1
# enable I2C-1 and set the frequency to 400KHz
dtparam=i2c_arm=on,i2c_arm_baudrate=400000
# enable spidev0.0
dtparam=spi=on
# enable RC input
enable_uart=1
# enable I2C-0
dtparam=i2c_vc=on
# switch Bluetooth to miniuart
dtoverlay=miniuart-bt

cmdline.txt

On Ubuntu Server 20.04:

sudo nano /boot/firmware/cmdline.txt

On Ubuntu Server 18.04 or earlier, nobtcmd.txt and btcmd.txt should both be modified.

sudo nano /boot/firmware/nobtcmd.txt

Find console=/dev/ttyAMA0,115200 and remove that part to disable the login shell on serial interface.

Append isolcpus=2 after the last word. The whole file will then look like:

net.ifnames=0 dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc isolcpus=2

The above line tells the Linux kernel do not schedule any process on CPU core 2. We will manually run PX4 onto that core later.

Reboot and SSH onto your Pi.

Check UART interface:

ls /dev/tty*

There should be /dev/ttyAMA0, /dev/ttySC0 and /dev/ttySC1.

Check I2C interface:

ls /dev/i2c*

There should be /dev/i2c-0 and /dev/i2c-1

Check SPI interface:

ls /dev/spidev*

There should be /dev/spidev0.0.

rc.local

In this section we will configure the auto-start script in rc.local. Note that we need to create this file, as it is not present on a fresh Ubuntu OS.

sudo nano /etc/rc.local

Append the content below to the file:

#!/bin/sh

echo "25" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio25/direction
if [ $(cat /sys/class/gpio/gpio25/value) -eq 1 ] ; then
        echo "Launching PX4"
        cd /home/ubuntu/px4 ; nohup taskset -c 2 ./bin/px4 -d -s pilotpi_mc.config 2 &> 1 >raspi
echo "25" > /sys/class/gpio/unexport

exit 0

Save and exit. Then set the correct permissions:

sudo chmod +x /etc/rc.local

:::note Don’t forget to turn off the switch when it is not needed! :::

CSI camera

:::warning Enable CSI camera will stop anything works on I2C-0. :::

sudo nano /boot/firmware/usercfg.txt

Append the following line at the end of file:

start_x=1

Building the code

To get the very latest version onto your computer, enter the following command into a terminal:

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

:::note This is all you need to do just to build the latest code. :::

Set RPi upload target

Set the IP (or hostname) of your RPi using:

export AUTOPILOT_HOST=192.168.X.X

or

export AUTOPILOT_HOST=pi_hostname.local

Additionally, we need to set the username:

export AUTOPILOT_USER=ubuntu

Build for armhf target

Build the executable file:

cd Firmware
make scumaker_pilotpi_default

Then upload it with:

make scumaker_pilotpi_default upload

Alternative build method for armhf (using docker)

If you are compiling for the first time with docker, please refer to the offical docs.

Execute the command in firmware folder:

./Tools/docker_run.sh "export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_default upload"

:::note mDNS is not supported within docker. You must specify the correct IP address every time when uploading. :::

:::note If your IDE doesn’t support ninja build, NO_NINJA_BUILD=1 option will help. You can compile without uploading too. Just remove upload target. :::

It is also possible to just compile the code with command:

./Tools/docker_run.sh "make scumaker_pilotpi_default"

Build for arm64 target

:::note This step requires aarch64-linux-gnu tool-chain to be installed. :::

Build the executable file:

cd PX4-Autopilot
make scumaker_pilotpi_arm64

Then upload it with:

make scumaker_pilotpi_arm64 upload

Alternative build method for arm64 (using docker)

If you are compiling for the first time with docker, please refer to the offical docs.

Execute the command in PX4-Autopilot folder:

./Tools/docker_run.sh "export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_arm64 upload"

:::note mDNS is not supported within docker. You must specify the correct IP address everytime when uploading. :::

:::note If your IDE doesn’t support ninja build, NO_NINJA_BUILD=1 option will help. You can compile without uploading too - just remove the upload target. :::

It is also possible to just compile the code with command:

./Tools/docker_run.sh "make scumaker_pilotpi_arm64"

Manually run PX4

Connect over SSH and run it with:

cd px4
sudo taskset -c 2 ./bin/px4 -s pilotpi_mc.config

Now PX4 is started with multi-rotor configuration.

If you encountered the similar problem executing bin/px4 on your Pi as following:

bin/px4: /lib/xxxx/xxxx: version `GLIBC_2.29' not found (required by bin/px4)

Then you should compile with docker instead.

Before proceeding to next step, clear the existing building at first: raspi

rm -rf build/scumaker_pilotpi_*

Then go back to the corresponding chapter above.

Post-configuration

Please refer to the instructions here

sudo apt-get install avahi-daemon
sudo insserv avahi-daemon

Next, setup the Avahi configuration file

sudo nano /etc/avahi/services/multiple.service

Add this to the file :

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group># PilotPi with Ubuntu Server

:::warning
Ubuntu Server on RPi 4B consumes a lot of current and generates a lot of heat.
Design for better heat dissipation and high power consumption when using this hardware.
:::
<!--more-->

## Developer Quick Start

### OS Image

Both armhf and arm64 arch are supported.

#### armhf

- [Ubuntu Server 18.04.5 for RPi2](https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi2.img.xz)
- [Ubuntu Server 18.04.5 for RPi3](https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi3.img.xz.zsync)
- [Ubuntu Server 18.04.5 for RPi4](https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi4.img.xz)
- [Ubuntu Server 20.04.1 for RPi 2/3/4](https://cdimage.ubuntu.com/releases/20.04.1/release/ubuntu-20.04.2-preinstalled-server-arm64+raspi.img.xz)

#### arm64

- [Ubuntu Server 18.04.5 for RPi3](https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-arm64+raspi3.img.xz)
- [Ubuntu Server 18.04.5 for RPi4](https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-arm64+raspi4.img.xz)
- [Ubuntu Server 20.04.1 for RPi 3/4](https://cdimage.ubuntu.com/releases/20.04.1/release/ubuntu-20.04.2-preinstalled-server-arm64+raspi.img.xz)

#### Latest OS

Please refer to official [cdimage](https://cdimage.ubuntu.com/releases/) page for any new updates.

### First boot

When setting up RaPi's WiFi for the first time we recommended using a wired Ethernet connection between your home router and RPi, and a monitor and keyboard.

#### Before booting

Mount the SD card onto your computer and modify the network settings.
Please follow the official instruction [here](https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#3-wifi-or-ethernet).

Now plug the SD card onto your Pi and boot for the first time.
Make sure you have shell access to the RPi - either SSH connection over wired Ethernet, or direct accessing with keyboard and monitor.

#### WiFi region

First install required package:

```sh
sudo apt-get install crda

Edit the file /etc/default/crda to change the correct WiFi region. Reference List

sudo nano /etc/default/crda

Then your Pi will able to join your WiFi network after reboot.

Hostname and mDNS

Let’s set up hostname at first.

sudo nano /etc/hostname

Change the hostname to whatever you like. Then install the package required by mDNS:

sudo apt-get update
sudo apt-get install avahi-daemon

Perform a reboot. raspi

sudo reboot

Regain the accessibility through WiFi connection after the above operation.

ssh ubuntu@pi_hostname.local

Password-less Auth (Optional)

You may want to setup passwordless auth as well.

Setting up OS

config.txt

The corresponding file in Ubuntu is /boot/firmware/usercfg.txt.

sudo nano /boot/firmware/usercfg.txt

Replace the file with:

# enable sc16is752 overlay
dtoverlay=sc16is752-spi1
# enable I2C-1 and set the frequency to 400KHz
dtparam=i2c_arm=on,i2c_arm_baudrate=400000
# enable spidev0.0
dtparam=spi=on
# enable RC input
enable_uart=1
# enable I2C-0
dtparam=i2c_vc=on
# switch Bluetooth to miniuart
dtoverlay=miniuart-bt

cmdline.txt

On Ubuntu Server 20.04:

sudo nano /boot/firmware/cmdline.txt

On Ubuntu Server 18.04 or earlier, nobtcmd.txt and btcmd.txt should both be modified.

sudo nano /boot/firmware/nobtcmd.txt

Find console=/dev/ttyAMA0,115200 and remove that part to disable the login shell on serial interface.

Append isolcpus=2 after the last word. The whole file will then look like:

net.ifnames=0 dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc isolcpus=2

The above line tells the Linux kernel do not schedule any process on CPU core 2. We will manually run PX4 onto that core later.

Reboot and SSH onto your Pi.

Check UART interface:

ls /dev/tty*

There should be /dev/ttyAMA0, /dev/ttySC0 and /dev/ttySC1.

Check I2C interface:

ls /dev/i2c*

There should be /dev/i2c-0 and /dev/i2c-1

Check SPI interface:

ls /dev/spidev*

There should be /dev/spidev0.0.

rc.local

In this section we will configure the auto-start script in rc.local. Note that we need to create this file, as it is not present on a fresh Ubuntu OS.

sudo nano /etc/rc.local

Append the content below to the file:

#!/bin/sh

echo "25" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio25/direction
if [ $(cat /sys/class/gpio/gpio25/value) -eq 1 ] ; then
        echo "Launching PX4"
        cd /home/ubuntu/px4 ; nohup taskset -c 2 ./bin/px4 -d -s pilotpi_mc.config 2 &> 1 >raspi
echo "25" > /sys/class/gpio/unexport

exit 0

Save and exit. Then set the correct permissions:

sudo chmod +x /etc/rc.local

:::note Don’t forget to turn off the switch when it is not needed! :::

CSI camera

:::warning Enable CSI camera will stop anything works on I2C-0. :::

sudo nano /boot/firmware/usercfg.txt

Append the following line at the end of file:

start_x=1

Building the code

To get the very latest version onto your computer, enter the following command into a terminal:

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

:::note This is all you need to do just to build the latest code. :::

Set RPi upload target

Set the IP (or hostname) of your RPi using:

export AUTOPILOT_HOST=192.168.X.X

or

export AUTOPILOT_HOST=pi_hostname.local

Additionally, we need to set the username:

export AUTOPILOT_USER=ubuntu

Build for armhf target

Build the executable file:

cd Firmware
make scumaker_pilotpi_default

Then upload it with:

make scumaker_pilotpi_default upload

Alternative build method for armhf (using docker)

If you are compiling for the first time with docker, please refer to the offical docs.

Execute the command in firmware folder:

./Tools/docker_run.sh "export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_default upload"

:::note mDNS is not supported within docker. You must specify the correct IP address every time when uploading. :::

:::note If your IDE doesn’t support ninja build, NO_NINJA_BUILD=1 option will help. You can compile without uploading too. Just remove upload target. :::

It is also possible to just compile the code with command:

./Tools/docker_run.sh "make scumaker_pilotpi_default"

Build for arm64 target

:::note This step requires aarch64-linux-gnu tool-chain to be installed. :::

Build the executable file:

cd PX4-Autopilot
make scumaker_pilotpi_arm64

Then upload it with:

make scumaker_pilotpi_arm64 upload

Alternative build method for arm64 (using docker)

If you are compiling for the first time with docker, please refer to the offical docs.

Execute the command in PX4-Autopilot folder:

./Tools/docker_run.sh "export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_arm64 upload"

:::note mDNS is not supported within docker. You must specify the correct IP address everytime when uploading. :::

:::note If your IDE doesn’t support ninja build, NO_NINJA_BUILD=1 option will help. You can compile without uploading too - just remove the upload target. :::

It is also possible to just compile the code with command:

./Tools/docker_run.sh "make scumaker_pilotpi_arm64"

Manually run PX4

Connect over SSH and run it with:

cd px4
sudo taskset -c 2 ./bin/px4 -s pilotpi_mc.config

Now PX4 is started with multi-rotor configuration.

If you encountered the similar problem executing bin/px4 on your Pi as following:

bin/px4: /lib/xxxx/xxxx: version `GLIBC_2.29' not found (required by bin/px4)

Then you should compile with docker instead.

Before proceeding to next step, clear the existing building at first: raspi

rm -rf build/scumaker_pilotpi_*

Then go back to the corresponding chapter above.

Post-configuration

Please refer to the instructions here

    <name replace-wildcards="yes">%h</name>
    <service>
            <type>_device-info._tcp</type>
            <port>0</port>
            <txt-record>model=RackMac</txt-record>
    </service>
    <service>
            <type>_ssh._tcp</type>
            <port>22</port>
    </service>

</service-group>

Restart the daemon

```sh
sudo /etc/init.d/avahi-daemon restart

And that’s it. You should be able to access your Pi directly by its hostname from any computer on the network.

:::tip You might have to add .local to the hostname to discover it. :::

Configuring a SSH Public-Key

In order to allow the PX4 development environment to automatically push executables to your board, you need to configure passwordless access to the RPi. We use the public-key authentication method for this.

To generate new SSH keys enter the following commands (Choose a sensible hostname such as <YOURNANME>@<YOURDEVICE>. Here we have used pi@px4autopilot)

These commands need to be run on the HOST development computer!

ssh-keygen -t rsa -C pi@px4autopilot

Upon entering this command, you’ll be asked where to save the key. We suggest you save it in the default location ($HOME/.ssh/id_rsa) by just hitting Enter.

Now you should see the files id_rsa and id_rsa.pub in your .ssh directory in your home folder:

ls ~/.ssh
authorized_keys  id_rsa  id_rsa.pub  known_hosts

The id_rsa file is your private key. Keep this on the development computer. The id_rsa.pub file is your public key. This is what you put on the targets you want to connect to.

To copy your public key to your Raspberry Pi, use the following command to append the public key to your authorized_keys file on the Pi, sending it over SSH:

cat ~/.ssh/id_rsa.pub | ssh pi@px4autopilot 'cat >> .ssh/authorized_keys'

Note that this time you will have to authenticate with your password (“raspberry” by default).

Now try ssh pi@px4autopilot and you should connect without a password prompt.

If you see a message “Agent admitted failure to sign using the key.” then add your RSA or DSA identities to the authentication agent, ssh-agent and the execute the following command:

ssh-add

If this did not work, delete your keys with rm ~/.ssh/id* and follow the instructions again.

Testing file transfer

We use SCP to transfer files from the development computer to the target board over a network (WiFi or Ethernet).

To test your setup, try pushing a file from the development PC to the Pi over the network now. Make sure the Pi has network access, and you can SSH into it.

echo "Hello" > hello.txt
scp hello.txt pi@px4autopilot:/home/pi/
rm hello.txt

This should copy over a “hello.txt” file into the home folder of your RPi. Validate that the file was indeed copied, and you can proceed to the next step.

Building the Code

Either build the source code on your development computer (“cross-compiler” build) or build it on the RaPi (“native” build) as shown below.

Cross-compiler Build

First install the standard developer environment on your Ubunto development computer.

Set the IP (or hostname) of your RPi using:

export AUTOPILOT_HOST=192.168.X.X

or

export AUTOPILOT_HOST=pi_hostname.domain

:::note The value of the environment variable should be set before the build, or make upload will fail to find your RPi. :::

Build the executable file:

cd PX4-Autopilot
make emlid_navio2 # for cross-compiler build

The “px4” executable file is in the directory build/emlid_navio2_default/. Make sure you can connect to your RPi over ssh, see instructions how to access your RPi.

Then upload it with:

cd PX4-Autopilot
make emlid_navio2 upload # for cross-compiler build

Then, connect over ssh and run it with (as root):

cd ~/px4
sudo ./bin/px4 -s px4.config

Native Build

A native build is one that you run directly on the Pi (the other option is to run builds on a development computer which cross-compiles for the Pi, and pushes the PX4 executable binary directly to the Pi).

Run these commands on the Pi to setup the build system on the Pi.

sudo apt-get update
sudo apt-get install cmake python-empy

Clone the Firmware directly onto the Pi then build the native build target (emlid_navio2_native).

git clone https://github.com/PX4/PX4-Autopilot.git --recursive
cd PX4-Autopilot
make emlid_navio2_native

The “px4” executable file is in the directory build/emlid_navio2_native/. Run it directly with:

sudo ./build/emlid_navio2_native/px4 build/emlid_navio2_native/etc -s ./posix-configs/rpi/px4.config

A successful build followed by executing px4 will give you something like this:


______  __   __    ___
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.


pxh>

Autostart

To autostart px4, add the following to the file /etc/rc.local (adjust it accordingly if you use native build), right before the exit 0 line:

cd /home/pi && ./bin/px4 -d -s px4.config > px4.log

The following wiki, pages and posts are tagged with

TitleTypeExcerpt
gcs and cloud post Mon, Jan 31, 22, sample4 from sass2 product sample4
overview and initial powerup post Mon, Jan 31, 22, sample1.md of sass2 product2_sample files The most advanced hardware and software ecosystem for enterprise drones
smartAP post Mon, Jan 31, 22, sample5 from sass2 product2 sample5
smartAPLink and faq post Mon, Jan 31, 22, sample3 from sass2 product2 sample3
telemetry and advanced software post Mon, Jan 31, 22, sample2.md of sass2 product2 sample2 file
px4 docker image for jvsim simulation post 목, 2월 10, 22, docker image implmentation for docker px4 simuation
qtcreator wiki from drone guide dev-setup post 화, 2월 15, 22, planning phase research for dashboard elements using
offboard control using pixhawk raspi mavros post Wed, Feb 16, 22, hitl setup and configuraiton using pixhawk raspi mavros and px4
setup gazebo for simulation post Wed, Feb 16, 22, pixhawk ros gazebo gcs simulation
setup mavros and px4 post Wed, Feb 16, 22, setup mavros and px4
testing sitl drone post Wed, Feb 16, 22, process to launch sitl drone
ros and px4 architecture and data flow post Wed, Feb 16, 22, examine how data flows for user interface and drone control
setup ros indigo with tutlesim post Wed, Feb 16, 22, pixhawk gcs simulation series 2 with ros indigo
connecting raspi to matek f406 wing post Fri, Feb 18, 22, hardware setup with raspi 4 with matek f406 wing
px4 simulation for gazebo post Fri, Feb 18, 22, simulation instruciton from px4
Let's roll and conquer! post Monday, Third week with jdlab and first week probably for actual work
brainstorming session prior to setting out on gcs development post Mon, Feb 21, 22, pool resources and ideas into one single gcs you can develop
overview of epp and eps for airframes post Tue, Feb 22, 22, research before business call to manufactueres
connecting rpi to gcs with the use of uavmatrix on uavcast pro post Mon, Feb 28, 22, supported raspi board pinout maps and setup guide
creating custom mission points for fixed wings post Fri, Mar 18, 22, p-turn or turnaround insertion to the mission raw data for exit and entry for p-turnaround and side/front-lap coverage creation that willmod...
gStreamer vs qtAv post Wed, Mar 30, 22, qt movie qmovie phonon video player
realtime georeferencing plus imu overlay post Tue, Apr 05, 22, how to add vehicle status sensor data to georeferencing
rtk reach m2 receiver documentation post Wed, Apr 06, 22, rtk reach receiver wifi 5g lte
avionics on airfoil and frames post Thu, Apr 07, 22, airfoil materials, designs and innovations in the avionics
using openTX on radiomaster TX16s post Sun, Apr 10, 22, rc reciever transmitter opentx radiomaster configuration simulation
adding GPS and IMU data to photos post flight post Mon, Apr 11, 22, perform post processing of gps/imu data or develop camera firmware lib to infuse IMU from fc to exif metadata
BMU BMC BMS battery management post Thu, Apr 14, 22, to check the usage and health of batteries at all phases of flight cycle
viewpro custom pwm post Thu, Apr 14, 22, customize viewpro camera and gimball with mavlink
raspberrypi video streaming post Fri, Apr 22, 22, configure and setup raspi to enable streaming on mavlink and to advance to LTE transmission
lx network, airlink, gcs and data transmission on smart radio, rf mesh and quantum encryption post Tue, Apr 26, 22, all about setup and how it operates and managed