Aviumtechnologies Blog
  • Introduction
  • Topics
    • Initial sizing
    • Definition of axes and angles
    • Stability
      • Obtaining stability derivatives from forced oscillations
    • Equations of motion
    • PX4 Autopilot
      • Building and running PX4 Autopilot on BeagleBone® Blue
      • PX4 BeagleBone® Blue-based quadcopter
Powered by GitBook
On this page
  • Requirements
  • Setup
  • Building PX4 Autopilot v1.14.0
  • Running PX4 Autopilot v1.14.0
  • The px4.config file

Was this helpful?

  1. Topics
  2. PX4 Autopilot

Building and running PX4 Autopilot on BeagleBone® Blue

This article will explain how build and run the PX4 Autopilot on BeagleBone Blue.

PreviousPX4 AutopilotNextPX4 BeagleBone® Blue-based quadcopter

Last updated 6 months ago

Was this helpful?

Requirements

  • Windows Subsystem for Linux (WSL) - Ubuntu 20.04.5 LTS

  • BeagleBone Blue - Debian GNU/Linux 10 (buster)

  • Arm GNU Toolchain - 8.3-2019.02

  • USB to UART Bridge - Silicon Labs CP210x

  • GNSS and Compass M10Q-5883 - Mateksys (optional)

  • Digital Airspeed Sensor ASPD-4525 - Mateksys (optional)

Setup

You need to connect the USB to UART Bridge to the UART1 port of the BeagleBone Blue board. The bridge will allow you to connect to the PX4 Autopilot via QGroundControl or to perform hardware-in-the-loop simulations. The image below shows the setup.

Building PX4 Autopilot v1.14.0

  • Open a WLS window.

  • Download and unzip the Arm GNU Toolchain (gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf.tar.xz).

  • Clone the PX4 Autopilot repository. Make sure you checkout v1.14.0.

git clone --recursive https://github.com/PX4/PX4-Autopilot
cd PX4-Autopilot
git checkout v1.14.0
git submodule sync --recursive
git submodule update --init --recursive

The step below is needed ONLY for PX4 v.1.13.0! Skip if building PX4 v1.14.0 or higher.

  • Open the init.cmake file in the boards/beaglebone/blue/ folder.

The step above is needed ONLY for PX4 v1.13.30! Skip if building PX4 v1.14.0 or higher.

  • Open the default.px4board file in the boards/beaglebone/blue/ folder.

  • Add (modify) the following lines to (inside) the default.px4board file.

CONFIG_BOARD_TESTING=n
CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS2"
CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS1"
CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS5"
CONFIG_DRIVERS_MAGNETOMETER_AKM_AK8963=y
CONFIG_DRIVERS_MAGNETOMETER_QMC5883L=y
  • Go back to the PX4-autopilot folder and execute the following commands.

export PATH=$PATH:/home/<username>/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin
make beaglebone_blue_default
  • During the build process, you should observe the following output.

-- PX4 version: v1.14.0 (1.14.0)
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3")
-- PX4 config file: /home/kboychev/PX4-v1.14.0/PX4-Autopilot/boards/beaglebone/blue/default.px4board
-- PLATFORM posix
-- LINUX_TARGET y
-- TOOLCHAIN arm-linux-gnueabihf
-- ARCHITECTURE cortex-a8
-- ROMFSROOT px4fmu_common
-- ROOTFSDIR .
-- TESTING y
-- SERIAL_GPS1 /dev/ttyS2
-- SERIAL_TEL1 /dev/ttyS1
-- SERIAL_TEL2 /dev/ttyS5
-- PX4 config: beaglebone_blue_default
-- PX4 platform: posix
-- PX4 lockstep: disabled
-- The CXX compiler identification is GNU 8.3.0
-- The C compiler identification is GNU 8.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/kboychev/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working CXX compiler: /home/kboychev/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/kboychev/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/kboychev/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/kboychev/gcc-arm-8.3-2019.02-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- cmake build type: RelWithDebInfo
-- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
-- ROMFS: ROMFS/px4fmu_common
-- ROMFS:  Adding boards/beaglebone/blue/init/rc.board_defaults -> /etc/init.d/rc.board_defaults
Architecture:  amd64
==> CPACK_INSTALL_PREFIX = @DEB_INSTALL_PREFIX@
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default
[0/1002] git submodule src/modules/uxrce_dds_client/Micro-XRCE-DDS-Client
[3/1002] git submodule src/drivers/gps/devices
[8/1002] git submodule src/modules/mavlink/mavlink
[18/1002] Performing download step (git clone) for 'librobotcontrol'
-- librobotcontrol download command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/librobotcontrol-prefix/src/librobotcontrol-stamp/librobotcontrol-download-*.log
[21/1002] Performing configure step for 'librobotcontrol'
-- librobotcontrol configure command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/librobotcontrol-prefix/src/librobotcontrol-stamp/librobotcontrol-configure-*.log
[23/1002] Performing build step for 'librobotcontrol'
-- librobotcontrol build command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/librobotcontrol-prefix/src/librobotcontrol-stamp/librobotcontrol-build-*.log
[442/1002] Performing configure step for 'libmicroxrceddsclient_project'
-- libmicroxrceddsclient_project configure command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/src/modules/uxrce_dds_client/src/libmicroxrceddsclient_project-stamp/libmicroxrceddsclient_project-configure-*.log
[605/1002] Performing build step for 'libmicroxrceddsclient_project'
-- libmicroxrceddsclient_project build command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/src/modules/uxrce_dds_client/src/libmicroxrceddsclient_project-stamp/libmicroxrceddsclient_project-build-*.log
[610/1002] Performing install step for 'libmicroxrceddsclient_project'
-- libmicroxrceddsclient_project install command succeeded.  See also /home/kboychev/PX4-v1.14.0/PX4-Autopilot/build/beaglebone_blue_default/src/modules/uxrce_dds_client/src/libmicroxrceddsclient_project-stamp/libmicroxrceddsclient_project-install-*.log
[1002/1002] Linking CXX shared library src/examples/dyn_hello/examples__dyn_hello.px4mod
  • Once the build is complete, you must upload the binaries to the BeagleBone Blue board. Use the following command to upload the binaries and the configuration files.

rsync -arh --progress /home/<username>/PX4-Autopilot/build/beaglebone_blue_default/bin debian@192.168.7.2:/home/debian/px4-bbblue-v1.14.0
rsync -arh --progress /home/<username>/PX4-Autopilot/build/beaglebone_blue_default/etc debian@192.168.7.2:/home/debian/px4-bbblue-v1.14.0

Running PX4 Autopilot v1.14.0

Once the binaries and the configuration files are uploaded to the BeagleBone Blue you can SSH into the BeagleBone Blue and run the px4 binary. To SSH into the BeagleBone Blue and run the px4 binary execute the following commands:

ssh debian@192.168.7.2
cd /home/debian/px4-bbblue-v1.14.0
./bin/px4 -s px4.config

The px4.config file

The px4.config file is specific for every board. The px4.config file below is specific to the BeagleBoneBlue board only.

#!/bin/sh
# PX4 commands need the 'px4-' prefix in bash.
# (px4-alias.sh is expected to be in the PATH)
. px4-alias.sh

set REQUESTED_AUTOSTART 2100
set PARAM_FILE eeprom/parameters_"$REQUESTED_AUTOSTART"
set AUTOSTART_FILE etc/init.d/airframes/2100_standard_plane

#Circuit breakers
param set CBRK_SUPPLY_CHK 894281

#Parameters 
param select $PARAM_FILE
if [ -f $PARAM_FILE ]
then
	if param load
	then
		echo "[param] Loaded: $PARAM_FILE"
	else
		echo "[param] FAILED loading $PARAM_FILE"
	fi
else
	echo "[param] Parameter file not found, creating $PARAM_FILE"
fi

if param compare SYS_AUTOSTART $REQUESTED_AUTOSTART
then
	param set SYS_AUTOCONFIG 0
else
	param set SYS_AUTOCONFIG 1 
	param set SYS_AUTOSTART 2100
fi

. "$AUTOSTART_FILE"

if param compare SYS_AUTOCONFIG 1
then
	param set SYS_AUTOCONFIG 0
fi

# Board defaults
param set BAT1_V_CHANNEL 5
param set BAT1_V_DIV 11.0


# User-defined params 

param set SYS_HITL 0
param set SYS_CTRL_ALLOC 1

# Waypoint storage
dataman start

# Resource load monitor
load_mon start

# RC update
rc_update start
manual_control start

# Sensors

if param compare SYS_HITL 1
then
    param set COM_RC_IN_MODE 1
    sensors start -h
    commander start -h
    param set GPS_1_CONFIG 0

else

    sleep 1
    bmp280 -I -a 0x76 start
    sleep 1
    mpu9250_i2c -I -a 0x68 start
    sleep 1
    ak8963 -I -a 0xC start
    sleep 1
    qmc5883l -X -a 0x0D start
    sleep 1
    ms4525do -X -a 0x2 start
    sleep 1
    gps start -d /dev/ttyS5 -b 9600 -p nmea

    board_adc start
    battery_status start

    sensors start
    commander start
fi

# Interface (configure outputs)

if param compare SYS_HITL 1
then
    pwm_out_sim start -m hil
else
    linux_pwm_out start
fi

# FW applications (start standard fixed-wing applications)

ekf2 start &

if param compare SYS_CTRL_ALLOC 1
then
	control_allocator start
fi

fw_att_control start
fw_pos_control_l1 start
airspeed_selector start
fw_autotune_attitude_control start
land_detector start fixedwing

# Mavlink

mavlink start -d /dev/ttyS1 -b 921600 -x -Z

# RC input
rc_input start -d /dev/ttyS4

# Navigator
navigator start

# Logger

logger start -t -b 200

# Boot complete

mavlink boot_complete

Change the GIT_TAG from 1abcb0a to 290e14f and the GIT_REPOSITORY from to . This change is required for the librobotcontrol library to compile and work properly.

https://github.com/dagar/librobotcontrol.git
https://github.com/beagleboard/librobotcontrol.git
PX4 1.15.0 BBBlue pre-compiled binaries
PX4 1.14.0 BBBlue pre-compiled binaries
2KB
px4.config
ASPD-4525 Digital Airspeed Sensor and M10Q-5883 GNSS and Compass
Beagle Bone Blue and Silicon Labs CP210x USB to UART Bridge
PX4 Autopilot running on BeagleBone Blue