2019-10-10 03:59:11 -03:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
## Bash script to setup PX4 development environment on Arch Linux.
|
2021-01-16 21:31:44 -04:00
|
|
|
## Tested on Manjaro 20.2.1.
|
2019-10-10 03:59:11 -03:00
|
|
|
##
|
|
|
|
## Installs:
|
|
|
|
## - Common dependencies and tools for nuttx, jMAVSim
|
|
|
|
## - NuttX toolchain (omit with arg: --no-nuttx)
|
|
|
|
## - jMAVSim simulator (omit with arg: --no-sim-tools)
|
2019-10-11 06:51:51 -03:00
|
|
|
## - Gazebo simulator (not by default, use --gazebo)
|
2019-10-10 03:59:11 -03:00
|
|
|
##
|
|
|
|
## Not Installs:
|
|
|
|
## - FastRTPS and FastCDR
|
|
|
|
|
|
|
|
INSTALL_NUTTX="true"
|
|
|
|
INSTALL_SIM="true"
|
2019-10-11 06:51:51 -03:00
|
|
|
INSTALL_GAZEBO="false"
|
2019-10-10 03:59:11 -03:00
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
for arg in "$@"
|
|
|
|
do
|
|
|
|
if [[ $arg == "--no-nuttx" ]]; then
|
|
|
|
INSTALL_NUTTX="false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $arg == "--no-sim-tools" ]]; then
|
|
|
|
INSTALL_SIM="false"
|
|
|
|
fi
|
|
|
|
|
2019-10-11 06:51:51 -03:00
|
|
|
if [[ $arg == "--gazebo" ]]; then
|
|
|
|
INSTALL_GAZEBO="true"
|
|
|
|
fi
|
2019-10-10 03:59:11 -03:00
|
|
|
done
|
|
|
|
|
|
|
|
# script directory
|
2021-01-16 21:31:44 -04:00
|
|
|
DIR=$(dirname $0)
|
2019-10-10 03:59:11 -03:00
|
|
|
|
|
|
|
# check requirements.txt exists (script not run in source tree)
|
|
|
|
REQUIREMENTS_FILE="requirements.txt"
|
|
|
|
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
|
|
|
|
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as arch.sh (${DIR})."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Installing PX4 general dependencies"
|
|
|
|
|
|
|
|
sudo pacman -Sy --noconfirm --needed \
|
|
|
|
astyle \
|
|
|
|
base-devel \
|
|
|
|
clang \
|
|
|
|
cmake \
|
|
|
|
cppcheck \
|
|
|
|
doxygen \
|
|
|
|
gdb \
|
|
|
|
git \
|
|
|
|
gnutls \
|
|
|
|
nettle \
|
|
|
|
ninja \
|
|
|
|
python-pip \
|
|
|
|
rsync \
|
|
|
|
shellcheck \
|
|
|
|
tar \
|
|
|
|
unzip \
|
|
|
|
wget \
|
|
|
|
zip \
|
|
|
|
;
|
|
|
|
|
|
|
|
# Python dependencies
|
|
|
|
echo "Installing PX4 Python3 dependencies"
|
2019-10-14 06:23:01 -03:00
|
|
|
pip install --user -r ${DIR}/requirements.txt
|
2019-10-10 03:59:11 -03:00
|
|
|
|
|
|
|
# NuttX toolchain (arm-none-eabi-gcc)
|
|
|
|
if [[ $INSTALL_NUTTX == "true" ]]; then
|
|
|
|
echo
|
|
|
|
echo "Installing NuttX dependencies"
|
|
|
|
|
|
|
|
sudo pacman -S --noconfirm --needed \
|
|
|
|
gperf \
|
|
|
|
vim \
|
|
|
|
;
|
|
|
|
|
2020-04-03 08:31:53 -03:00
|
|
|
if [ ! -z "$USER" ]; then
|
|
|
|
# add user to dialout group (serial port access)
|
|
|
|
sudo usermod -aG uucp $USER
|
|
|
|
fi
|
2019-10-10 03:59:11 -03:00
|
|
|
|
2019-10-14 06:23:01 -03:00
|
|
|
# remove modem manager (interferes with PX4 serial port usage)
|
2019-10-10 03:59:11 -03:00
|
|
|
sudo pacman -R modemmanager --noconfirm
|
|
|
|
|
|
|
|
# arm-none-eabi-gcc
|
2021-01-16 21:31:44 -04:00
|
|
|
NUTTX_GCC_VERSION="10-2020-q4-major"
|
|
|
|
NUTTX_GCC_VERSION_SHORT="10-2020q4"
|
2019-10-10 03:59:11 -03:00
|
|
|
|
2021-01-16 21:31:44 -04:00
|
|
|
source $HOME/.profile # load changed path for the case the script is reran before relogin
|
|
|
|
if [ $(which arm-none-eabi-gcc) ]; then
|
|
|
|
GCC_VER_STR=$(arm-none-eabi-gcc --version)
|
|
|
|
GCC_FOUND_VER=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$GCC_FOUND_VER" == "1" ]]; then
|
2019-10-10 03:59:11 -03:00
|
|
|
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation"
|
2021-01-16 21:31:44 -04:00
|
|
|
|
2019-10-10 03:59:11 -03:00
|
|
|
else
|
|
|
|
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
|
2021-01-16 21:31:44 -04:00
|
|
|
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-x86_64-linux.tar.bz2 && \
|
2019-10-10 03:59:11 -03:00
|
|
|
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;
|
|
|
|
|
|
|
|
# add arm-none-eabi-gcc to user's PATH
|
|
|
|
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH"
|
|
|
|
|
2021-01-16 21:31:44 -04:00
|
|
|
if grep -Fxq "$exportline" $HOME/.profile; then
|
2019-10-10 03:59:11 -03:00
|
|
|
echo "${NUTTX_GCC_VERSION} path already set.";
|
|
|
|
else
|
|
|
|
echo $exportline >> $HOME/.profile;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Simulation tools
|
|
|
|
if [[ $INSTALL_SIM == "true" ]]; then
|
|
|
|
echo
|
|
|
|
echo "Installing PX4 simulation dependencies"
|
|
|
|
|
|
|
|
# java (jmavsim or fastrtps)
|
|
|
|
sudo pacman -S --noconfirm --needed \
|
|
|
|
ant \
|
2020-07-15 05:58:31 -03:00
|
|
|
jdk-openjdk \
|
2019-10-10 03:59:11 -03:00
|
|
|
;
|
2019-10-11 06:51:51 -03:00
|
|
|
|
2019-10-11 07:46:58 -03:00
|
|
|
# Gazebo setup
|
2019-10-11 06:51:51 -03:00
|
|
|
if [[ $INSTALL_GAZEBO == "true" ]]; then
|
|
|
|
echo
|
2019-10-23 11:46:39 -03:00
|
|
|
echo "Installing gazebo and dependencies for PX4 gazebo simulation"
|
2019-10-11 06:51:51 -03:00
|
|
|
|
2019-10-11 07:46:58 -03:00
|
|
|
# PX4 gazebo simulation dependencies
|
2019-10-11 06:51:51 -03:00
|
|
|
sudo pacman -S --noconfirm --needed \
|
2020-07-21 04:11:09 -03:00
|
|
|
dmidecode \
|
2021-01-16 21:31:44 -04:00
|
|
|
eigen \
|
2019-10-11 06:51:51 -03:00
|
|
|
hdf5 \
|
|
|
|
opencv \
|
|
|
|
protobuf \
|
|
|
|
vtk \
|
2021-01-16 21:31:44 -04:00
|
|
|
yay \
|
2019-10-11 06:51:51 -03:00
|
|
|
;
|
|
|
|
|
2021-01-16 21:31:44 -04:00
|
|
|
# enable multicore gazebo compilation
|
|
|
|
sudo sed -i '/MAKEFLAGS=/c\MAKEFLAGS="-j4"' /etc/makepkg.conf
|
2019-10-11 07:06:01 -03:00
|
|
|
|
2021-01-16 21:31:44 -04:00
|
|
|
# install gazebo from AUR
|
|
|
|
yay -S gazebo --noconfirm
|
2019-10-11 07:46:58 -03:00
|
|
|
|
2019-10-11 06:51:51 -03:00
|
|
|
if sudo dmidecode -t system | grep -q "Manufacturer: VMware, Inc." ; then
|
|
|
|
# fix VMWare 3D graphics acceleration for gazebo
|
2021-01-16 21:31:44 -04:00
|
|
|
exportline="export SVGA_VGPU10=0"
|
|
|
|
|
2021-05-03 20:21:33 -03:00
|
|
|
if !grep -Fxq "$exportline" $HOME/.profile; then
|
2021-01-16 21:31:44 -04:00
|
|
|
echo $exportline >> $HOME/.profile;
|
|
|
|
fi
|
2019-10-11 06:51:51 -03:00
|
|
|
fi
|
|
|
|
fi
|
2019-10-10 03:59:11 -03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $INSTALL_NUTTX == "true" ]]; then
|
|
|
|
echo
|
|
|
|
echo "Reboot or logout, login computer before attempting to build NuttX targets"
|
|
|
|
fi
|