BeagleBone Blue is an all-in-one Linux-based computer. Although it is optimized for robotics, this compact and inexpensive board has all necessary sensors and peripherals needed by a flight controller. This topic shows how to set up the board to run PX4 with librobotcontrol robotics package.
BeagleBone Blue images can be found here:
BeagleBoard OS images come with librobotcontrol preinstalled, but it may not work properly in all OS images.
One way to check if librobotcontrol works properly is to run rc_test_drivers which comes with librobotcontrol. As shown in the following example, all tests should pass. Optionally run other tests such as rc_test_bmp, rc_test_mpu, etc.
debian@beaglebone:~$ rc_test_drivers Kernel: 4.14.56-ti-rt-r64 BeagleBoard.org Debian Image 2018-07-22 Debian: 9.5 PASSED: gpio 0 PASSED: gpio 1 PASSED: gpio 2 PASSED: gpio 3 PASSED: pwm1 PASSED: pwm2 PASSED: eqep0 PASSED: eqep1 PASSED: eqep2 PASSED: pru-rproc PASSED: uart1 PASSED: uart2 PASSED: uart4 PASSED: uart5 PASSED: i2c1 PASSED: i2c2 PASSED: spi PASSED: LED PASSED: ADC iio Currently running on a: MODEL_BB_BLUE Robot Control library Version: 1.0.0
Optionally you can update to a realtime kernel, and if you do, re-check if librobotcontrol works properly with the realtime kernel.
The latest OS images in which librobotcontrol works properly (at time of writing) is bone-debian-9.5-iot-armhf-2018-07-22-4gb.img.xz.
If you want to build PX4, there are additional setup steps for this library.
At time of writing, without modifying its build files to add cross compile support, the librobotcontrol debian package is only available on BeagleBoard products including BeagleBone Blue. Here are the ways to obtain the librobotcontrol on BeagleBone Blue:
- Use the one pre-installed in BeagleBoard images.
- Install from debian package or repository:
sudo apt update && sudo apt install librobotcontrol
- Install from source
git clone https://github.com/StrawsonDesign/librobotcontrol.git cd librobotcontrol sudo make install
After acquiring the pre-built library,
- Select the librobotcontrol installation directory, and set it in the
LIBROBOTCONTROL_INSTALL_DIRenvironment variable so that other unwanted headers will not be included
- Install robotcontrol.h and rc/* into
- Install pre-built native (ARM) version of librobotcontrol.* into
At this point the BeagleBone Blue target can be built on both cross compile host system and native build system, i.e.,
make posix_bbblue_cross [upload]
The recommended way to build PX4 for BeagleBone Blue is to compile on a development computer and upload the PX4 executable binary directly to the BeagleBone Blue.
This approach is recommended over native build due to speed of deployment and ease of use.
ARM Cross Compiler for BeagleBone Blue can be found at Linaro Toolchain Binaries site. The following is an example setup on development host.
First install the toolchain into /opt/bbblue_toolchain/gcc-arm-linux-gnueabihf. Here is an example of using soft link to select which version of the toolchain you want to use:
...@ubuntu:/opt/bbblue_toolchain$ ls -l lrwxrwxrwx 1 root root 51 Mar 22 16:10 gcc-arm-linux-gnueabihf -> gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf drwxr-xr-x 8 root root 4096 May 17 2017 gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf drwxr-xr-x 8 root root 4096 Nov 19 03:51 gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf
Add it to the PATH in ~/.profile as shown below
export PATH=$PATH:/opt/bbblue_toolchain/gcc-arm-linux-gnueabihf/bin export CrossCompiler=/opt/bbblue_toolchain/gcc-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
GCC in the toolchain should be compatible with kernel in BeagleBone Blue. General rule of thumb is to choose a toolchain where version of GCC is not higher than version of GCC which comes with the OS image on BeagleBone Blue.
- First set up rsync (this is is used to transfer files from the development computer to the target board over a network - WiFi or Ethernet).
- For rsync over SSH with key authentication, follow steps similar to those for Raspberry Pi/Navio
- On the development computer, define the BeagleBone Blue board as
- Run the following command to build and upload files:
make posix_bbblue_cross upload
To test the uploaded files, run the following commands on the BeagleBone Blue board:
cd /home/debian/px4 sudo ./bin/px4 -s px4.config
Currently librobotcontrol requires root access.
You can also natively build PX4 builds directly on the BeagleBone Blue.
Run the following commands on the BeagleBone Blue (i.e. via SSH):
- Install dependencies:
sudo apt-get update sudo apt-get install cmake python-empy
- Clone the PX4 Firmware directly onto the BeagleBone Blue.
- Continue with the standard build system installation.
Here is an example [/etc/rc.local]:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # wait for services to start up /bin/sleep 25 cd /home/debian/px4 /home/debian/px4/bin/px4 -d -s /home/debian/px4/px4.config > /home/debian/px4/PX4.log & exit 0
Below is a systemd service example [/lib/systemd/system/px4-quad-copter.service]:
[Unit] Description=PX4 Quadcopter Service After=networking.service network-online.target StartLimitIntervalSec=0 Conflicts=px4-fixed-wing.service [Service] WorkingDirectory=/home/debian/px4 User=root ExecStart=/home/debian/px4/bin/px4 -d -s /home/debian/px4/px4.config Restart=on-failure RestartSec=1 [Install] WantedBy=multi-user.target
When PX4 starts, it automatically applies power to servos.
BeagleBone Blue has some unique features such as multiple choices of WiFi interfaces and power sources. Refer to comments in /home/debian/px4/px4.config for usage of these features.
SBUS signal from receiver (e.g., FrSky X8R) is an inverted signal. UARTs on BeagleBone Blue can only work with non-inverted 3.3V level signal. This tutorial contains a SBUS signal inverter circuit.
For a quadcopter with GPS and an SBUS receiver, here are typical connections:
Connect the ESC of motor 1, 2, 3 and 4 to channel 1, 2, 3 and 4 of servo outputs on BeagleBone Blue, respectively. If your ESC connector contains a power output pin, remove it and do not connect it to the power output pin of the servo channel on the BeagleBone Blue.
Connect the above mentioned converted SBUS signal to the dsm2 port if you have the matching connector for dsm2, otherwise connect it to any other available UART port and change the corresponding port in /home/debian/px4/px4.config accordingly.
Connect the signals of GPS module to GPS port on the BeagleBone Blue. Note that the signal pins of the GPS port on the BeagleBone Blue are only 3.3V tolerant, so choose your GPS module accordingly.