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.
Navigate to Network Options > Hostname. Set and exit. You may want to setup passwordless auth as well.
Setting up OS
config.txt
Replace the file with:
cmdline.txt
Interfacing Options > Serial > login shell = No > hardware = Yes. Enable UART but without a login shell on it.
Append isolcpus=2
after the last word. The whole file would be:
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:
There should be /dev/ttyAMA0
, /dev/ttySC0
and /dev/ttySC1
.
Check I2C interface:
There should be /dev/i2c-0
and /dev/i2c-1
Check SPI interface
There should be /dev/spidev0.0
.
rc.local
In this section we will configure the auto-start script in rc.local.
Append below content to the file above exit 0
:
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. :::
Interfacing Options > Camera
Building the code
To get the very latest version onto your computer, enter the following command into a terminal:
:::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:
or
Build the executable file:
Then upload it with:
Connect over ssh and run it with:
Now PX4 is started with multi-rotor configuration.
If you encountered the similar problem executing bin/px4
on your Pi as following:
Then you should compile with docker instead.
Before proceeding to next step, clear the existing building at first:
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 official docs.
Execute the command in PX4-Autopilot folder:
:::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:
Post-configuration
You need to check these extra items to get your vehicle work properly.
Actuator Configuration
First set the CA_AIRFRAME parameter for your vehicle.
You will then be able to assign outputs using the normal Actuator Configuration configuration screen (an output tab will appear for the RasPi PWM output driver).
External Compass
In the startup script(*.config
), you will find
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:
Sample output:
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
) :::
Last updated