mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-28 19:20:04 +08:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2eb2b2a17f | |||
| bba589ece2 | |||
| ad827fc806 | |||
| 606cfba407 | |||
| 598e7e65b7 | |||
| c83e1eb175 | |||
| ba9b23c2d1 | |||
| 38fc86cf3b | |||
| a3d0ca9800 | |||
| 34b9dc880f | |||
| 04e08c5edb | |||
| 2668510295 | |||
| 5388f7f911 | |||
| a20483ed11 | |||
| 9ed861e0a3 | |||
| f7ff0a9961 | |||
| 38c02ea29a | |||
| 26190a7799 | |||
| e6eed43648 |
@@ -0,0 +1,14 @@
|
||||
name: docker-dev
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: file_changes
|
||||
uses: trilom/file-changes-action@v1.2.3
|
||||
- name: test
|
||||
run: |
|
||||
echo '${{ steps.file_changes.outputs.files}}'
|
||||
echo '${{ steps.file_changes.outputs.files_modified}}'
|
||||
echo '${{ steps.file_changes.outputs.files_added}}'
|
||||
echo '${{ steps.file_changes.outputs.files_removed}}'
|
||||
@@ -5,7 +5,7 @@ Tailsitter duo mixer
|
||||
This file defines a mixer for a generic duo tailsitter VTOL (eg TBS Caipirinha tailsitter edition). This vehicle
|
||||
has two motors in total, one attached to each wing. It also has two elevons which
|
||||
are located in the slipstream of the propellers. This mixer generates 4 PWM outputs
|
||||
on the main PWM ouput port, two at 400Hz for the motors, and two at 50Hz for the
|
||||
on the main PWM output port, two at 400Hz for the motors, and two at 50Hz for the
|
||||
elevon servos. Channels 1-4 are configured to run at 400Hz, while channels 5-8 run
|
||||
at the default rate of 50Hz. Note that channels 3 and 4 are assigned but not used.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Tailsitter duo mixer
|
||||
This file defines a mixer for a generic duo tailsitter VTOL (eg TBS Caipirinha tailsitter edition). This vehicle
|
||||
has two motors in total, one attached to each wing. It also has two elevons which
|
||||
are located in the slipstream of the propellers. This mixer generates 4 PWM outputs
|
||||
on the main PWM ouput port, two at 400Hz for the motors, and two at 50Hz for the
|
||||
on the main PWM output port, two at 400Hz for the motors, and two at 50Hz for the
|
||||
elevon servos. Channels 1-4 are configured to run at 400Hz, while channels 5-8 run
|
||||
at the default rate of 50Hz. Note that channels 3 and 4 are assigned but not used.
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ exec find boards msg src platforms test \
|
||||
-path src/lib/crypto/monocypher -prune -o \
|
||||
-path src/lib/events/libevents -prune -o \
|
||||
-path src/lib/parameters/uthash -prune -o \
|
||||
-path src/lib/wind_estimator/python/generated -prune -o \
|
||||
-path src/modules/ekf2/EKF -prune -o \
|
||||
-path src/modules/gyro_fft/CMSIS_5 -prune -o \
|
||||
-path src/modules/mavlink/mavlink -prune -o \
|
||||
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -z "${DOCKER_TAG}" ]]; then
|
||||
# the default tag for docker images
|
||||
# follows the pattern below, and we recommend
|
||||
# that any images pushed to the registry continue
|
||||
# to use the pattern for consistency
|
||||
TAG_NAME="`date +"%Y-%m-%d"`"
|
||||
else
|
||||
TAG_NAME="${DOCKER_TAG}"
|
||||
fi
|
||||
|
||||
PX4_DOCKER_REPO="ghcr.io/px4/px4-dev:$TAG_NAME"
|
||||
PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
SRC_DIR=$PWD/../
|
||||
|
||||
echo "[docker_build.sh]: Building [$PX4_DOCKER_REPO]"
|
||||
|
||||
docker build \
|
||||
-t ${PX4_DOCKER_REPO} \
|
||||
-f Tools/setup/Dockerfile "${SRC_DIR}"
|
||||
+19
-57
@@ -1,67 +1,29 @@
|
||||
#! /bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z ${PX4_DOCKER_REPO+x} ]; then
|
||||
echo "guessing PX4_DOCKER_REPO based on input";
|
||||
if [[ $@ =~ .*px4_fmu.* ]]; then
|
||||
# nuttx-px4fmu-v{1,2,3,4,5}
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2021-09-08"
|
||||
elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*beaglebone.* ]] || [[ $@ =~ .*pilotpi.default ]]; then
|
||||
# beaglebone_blue_default, emlid_navio2_default, px4_raspberrypi_default, scumaker_pilotpi_default
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-armhf:2021-08-18"
|
||||
elif [[ $@ =~ .*pilotpi.arm64 ]]; then
|
||||
# scumaker_pilotpi_arm64
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-aarch64:latest"
|
||||
elif [[ $@ =~ .*navio2.* ]] || [[ $@ =~ .*raspberry.* ]] || [[ $@ =~ .*bebop.* ]]; then
|
||||
# posix_rpi_cross, posix_bebop_default
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-armhf:2021-08-18"
|
||||
elif [[ $@ =~ .*clang.* ]] || [[ $@ =~ .*scan-build.* ]]; then
|
||||
# clang tools
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-clang:2021-02-04"
|
||||
elif [[ $@ =~ .*tests* ]]; then
|
||||
# run all tests with simulation
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-simulation-bionic:2021-12-11"
|
||||
fi
|
||||
if [[ -z "${DOCKER_TAG}" ]]; then
|
||||
# The default tag name should be hardcoded
|
||||
# to whatever we are currently using in CI on this branch
|
||||
TAG_NAME="2022-08-16"
|
||||
else
|
||||
echo "PX4_DOCKER_REPO is set to '$PX4_DOCKER_REPO'";
|
||||
TAG_NAME="${DOCKER_TAG}"
|
||||
fi
|
||||
|
||||
# otherwise default to nuttx
|
||||
if [ -z ${PX4_DOCKER_REPO+x} ]; then
|
||||
PX4_DOCKER_REPO="px4io/px4-dev-nuttx-focal:2021-09-08"
|
||||
fi
|
||||
PX4_DOCKER_REPO="ghcr.io/px4/px4-dev:$TAG_NAME"
|
||||
|
||||
# docker hygiene
|
||||
|
||||
#Delete all stopped containers (including data-only containers)
|
||||
#docker rm $(docker ps -a -q)
|
||||
|
||||
#Delete all 'untagged/dangling' (<none>) images
|
||||
#docker rmi $(docker images -q -f dangling=true)
|
||||
|
||||
echo "PX4_DOCKER_REPO: $PX4_DOCKER_REPO";
|
||||
echo "[docker_run.sh]: Running '$PX4_DOCKER_REPO'"
|
||||
|
||||
PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
SRC_DIR=$PWD/../
|
||||
|
||||
CCACHE_DIR=${HOME}/.ccache
|
||||
mkdir -p "${CCACHE_DIR}"
|
||||
|
||||
docker run -it --rm -w "${SRC_DIR}" \
|
||||
--env=AWS_ACCESS_KEY_ID \
|
||||
--env=AWS_SECRET_ACCESS_KEY \
|
||||
--env=BRANCH_NAME \
|
||||
--env=CCACHE_DIR="${CCACHE_DIR}" \
|
||||
--env=CI \
|
||||
--env=CODECOV_TOKEN \
|
||||
--env=COVERALLS_REPO_TOKEN \
|
||||
--env=LOCAL_USER_ID="$(id -u)" \
|
||||
--env=PX4_ASAN \
|
||||
--env=PX4_MSAN \
|
||||
--env=PX4_TSAN \
|
||||
--env=PX4_UBSAN \
|
||||
--env=TRAVIS_BRANCH \
|
||||
--env=TRAVIS_BUILD_ID \
|
||||
--publish 14556:14556/udp \
|
||||
--volume=${CCACHE_DIR}:${CCACHE_DIR}:rw \
|
||||
--volume=${SRC_DIR}:${SRC_DIR}:rw \
|
||||
${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3"
|
||||
--env=LOCAL_USER_ID="$(id -u)" \
|
||||
--env=AWS_ACCESS_KEY_ID \
|
||||
--env=AWS_SECRET_ACCESS_KEY \
|
||||
--env=BRANCH_NAME \
|
||||
--env=CCACHE_DIR="${CCACHE_DIR}" \
|
||||
--env=CI \
|
||||
--publish 14556:14556/udp \
|
||||
--volume=/tmp/.X11-unix:/tmp/.X11-unix \
|
||||
--volume=/tmp:/tmp:rw \
|
||||
--volume=${SRC_DIR}:${SRC_DIR}:rw \
|
||||
${PX4_DOCKER_REPO} /bin/bash -c "$1 $2 $3"
|
||||
|
||||
@@ -3019,7 +3019,7 @@ class MAVLink(object):
|
||||
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
|
||||
press_abs : Absolute pressure (hectopascal) (float)
|
||||
press_diff : Differential pressure 1 (hectopascal) (float)
|
||||
temperature : Temperature measurement (0.01 degrees celsius) (int16_t)
|
||||
temperature : Temperature measurement (0.01 degrees Celsius) (int16_t)
|
||||
|
||||
'''
|
||||
msg = MAVLink_scaled_pressure_message(time_boot_ms, press_abs, press_diff, temperature)
|
||||
@@ -3035,7 +3035,7 @@ class MAVLink(object):
|
||||
time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t)
|
||||
press_abs : Absolute pressure (hectopascal) (float)
|
||||
press_diff : Differential pressure 1 (hectopascal) (float)
|
||||
temperature : Temperature measurement (0.01 degrees celsius) (int16_t)
|
||||
temperature : Temperature measurement (0.01 degrees Celsius) (int16_t)
|
||||
|
||||
'''
|
||||
return self.send(self.scaled_pressure_encode(time_boot_ms, press_abs, press_diff, temperature))
|
||||
@@ -4879,7 +4879,7 @@ class MAVLink(object):
|
||||
abs_pressure : Absolute pressure in millibar (float)
|
||||
diff_pressure : Differential pressure in millibar (float)
|
||||
pressure_alt : Altitude calculated from pressure (float)
|
||||
temperature : Temperature in degrees celsius (float)
|
||||
temperature : Temperature in degrees Celsius (float)
|
||||
fields_updated : Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature (uint16_t)
|
||||
|
||||
'''
|
||||
@@ -4904,7 +4904,7 @@ class MAVLink(object):
|
||||
abs_pressure : Absolute pressure in millibar (float)
|
||||
diff_pressure : Differential pressure in millibar (float)
|
||||
pressure_alt : Altitude calculated from pressure (float)
|
||||
temperature : Temperature in degrees celsius (float)
|
||||
temperature : Temperature in degrees Celsius (float)
|
||||
fields_updated : Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature (uint16_t)
|
||||
|
||||
'''
|
||||
|
||||
@@ -14,12 +14,14 @@ class MarkdownOutput():
|
||||
|
||||
result = """
|
||||
# Modules & Commands Reference
|
||||
The following pages document the PX4 modules, drivers and commands. They
|
||||
describe the provided functionality, high-level implementation overview and how
|
||||
|
||||
The following pages document the PX4 modules, drivers and commands.
|
||||
They describe the provided functionality, high-level implementation overview and how
|
||||
to use the command-line interface.
|
||||
|
||||
> **Note** **This is auto-generated from the source code** and contains the
|
||||
> most recent modules documentation.
|
||||
:::note
|
||||
**This is auto-generated from the source code** and contains the most recent modules documentation.
|
||||
:::
|
||||
|
||||
It is not a complete list and NuttX provides some additional commands
|
||||
as well (such as `free`). Use `help` on the console to get a list of all
|
||||
@@ -29,6 +31,7 @@ Since this is generated from source, errors must be reported/fixed
|
||||
in the [PX4-Autopilot](https://github.com/PX4/PX4-Autopilot) repository.
|
||||
The documentation pages can be generated by running the following command from
|
||||
the root of the PX4-Autopilot directory:
|
||||
|
||||
```
|
||||
make module_documentation
|
||||
```
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# PX4 base development environment
|
||||
#
|
||||
|
||||
FROM ubuntu:20.04
|
||||
LABEL maintainer="Daniel Agar <daniel@agar.ca>, Ramon Roche <mrpollo@gmail.com>"
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV LANG C.UTF-8
|
||||
ENV LC_ALL C.UTF-8
|
||||
|
||||
# Installing required utilities
|
||||
RUN apt-get update && apt-get -y --quiet --no-install-recommends install \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
lsb-core \
|
||||
lsb-release \
|
||||
sudo \
|
||||
software-properties-common \
|
||||
wget \
|
||||
gosu \
|
||||
;
|
||||
|
||||
# Install PX4 Requirements
|
||||
COPY Tools/setup/requirements.txt /tmp/requirements.txt
|
||||
COPY Tools/setup/ubuntu.sh /tmp/ubuntu.sh
|
||||
# The PATH env is set within ubuntu.sh, but given how we
|
||||
# are running the image using `gosu` to avoid read-only problems
|
||||
# with the filesystem the env variable does not persist
|
||||
ENV PATH="/opt/gcc-arm-none-eabi-9-2020-q2-update/bin:$PATH"
|
||||
|
||||
RUN bash /tmp/ubuntu.sh --from-docker
|
||||
|
||||
ENV DISPLAY :99
|
||||
|
||||
ENV FASTRTPSGEN_DIR="/usr/local/bin/"
|
||||
ENV TERM=xterm
|
||||
ENV TZ=UTC
|
||||
|
||||
# SITL UDP PORTS
|
||||
EXPOSE 14556/udp
|
||||
EXPOSE 14557/udp
|
||||
|
||||
# create user with id 1001 (jenkins docker workflow default)
|
||||
RUN useradd --shell /bin/bash -u 1001 -c "" -m user && usermod -a -G dialout user
|
||||
|
||||
# create and start as LOCAL_USER_ID
|
||||
COPY Tools/setup/docker-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "[docker-entrypoint.sh] Starting entrypoint"
|
||||
# Start virtual X server in the background
|
||||
# - DISPLAY default is :99, set in dockerfile
|
||||
# - Users can override with `-e DISPLAY=` in `docker run` command to avoid
|
||||
# running Xvfb and attach their screen
|
||||
if [[ -x "$(command -v Xvfb)" && "$DISPLAY" == ":99" ]]; then
|
||||
echo "[docker-entrypoint.sh] Starting Xvfb"
|
||||
Xvfb :99 -screen 0 1600x1200x24+32 &
|
||||
fi
|
||||
|
||||
# Check if the ROS_DISTRO is passed and use it
|
||||
# to source the ROS environment
|
||||
if [ -n "${ROS_DISTRO}" ]; then
|
||||
source "/opt/ros/$ROS_DISTRO/setup.bash"
|
||||
fi
|
||||
|
||||
# Use the LOCAL_USER_ID if passed in at runtime
|
||||
if [ -n "${LOCAL_USER_ID}" ]; then
|
||||
echo "[docker-entrypoint.sh] Starting with UID : $LOCAL_USER_ID"
|
||||
# modify existing user's id
|
||||
usermod -u $LOCAL_USER_ID user
|
||||
|
||||
# run as user
|
||||
exec gosu user "$@"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
@@ -26,3 +26,5 @@ requests
|
||||
setuptools>=39.2.0
|
||||
six>=1.12.0
|
||||
toml>=0.9
|
||||
symforce>=0.5.0
|
||||
sympy>=1.10.1
|
||||
|
||||
+123
-72
@@ -2,20 +2,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
## Bash script to setup PX4 development environment on Ubuntu LTS (20.04, 18.04, 16.04).
|
||||
## Bash script to setup PX4 development environment on Ubuntu LTS (20.04, 18.04).
|
||||
## Can also be used in docker.
|
||||
##
|
||||
## Installs:
|
||||
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo
|
||||
## - Common dependencies and tools for NuttX, and Gazebo
|
||||
## - NuttX toolchain (omit with arg: --no-nuttx)
|
||||
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
|
||||
##
|
||||
## Not Installs:
|
||||
## - FastRTPS and FastCDR
|
||||
## - Gazebo simulator (omit with arg: --no-sim-tools)
|
||||
|
||||
INSTALL_NUTTX="true"
|
||||
INSTALL_SIM="true"
|
||||
INSTALL_ARCH=`uname -m`
|
||||
INSIDE_DOCKER="false"
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"
|
||||
@@ -28,19 +26,22 @@ do
|
||||
INSTALL_SIM="false"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# detect if running in docker
|
||||
if [ -f /.dockerenv ]; then
|
||||
echo "Running within docker, installing initial dependencies";
|
||||
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
lsb-core \
|
||||
sudo \
|
||||
wget \
|
||||
;
|
||||
fi
|
||||
if [[ $arg == "--from-docker" ]]; then
|
||||
INSIDE_DOCKER="true"
|
||||
fi
|
||||
|
||||
if [[ $arg == "--help" ]]; then
|
||||
echo "#⚡️ PX4 Dependency Installer for Ubuntu"
|
||||
echo "# Options:
|
||||
#
|
||||
# --no-nuttx boolean
|
||||
# --no-sim-tools boolean"
|
||||
echo "#"
|
||||
exit
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# script directory
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
@@ -69,9 +70,22 @@ elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
echo "Ubuntu 20.04"
|
||||
fi
|
||||
|
||||
VERBOSE_BAR="####################"
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "#⚡️ Starting PX4 Dependency Installer for Ubuntu ${UBUNTU_RELEASE} (${INSTALL_ARCH})"
|
||||
echo "# Options:
|
||||
#
|
||||
# - Install NuttX = ${INSTALL_NUTTX}
|
||||
# - Install Simulation = ${INSTALL_SIM}"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
echo
|
||||
echo "Installing PX4 general dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing System Dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
sudo apt-get update -y --quiet
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
@@ -85,6 +99,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
|
||||
gdb \
|
||||
git \
|
||||
lcov \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
libxml2-utils \
|
||||
make \
|
||||
@@ -100,32 +115,42 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
|
||||
zip \
|
||||
;
|
||||
|
||||
# Python3 dependencies
|
||||
# Python 3 dependencies
|
||||
echo
|
||||
echo "Installing PX4 Python3 dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing Python dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
# virtual envrionments don't allow --user option
|
||||
# virtual environments don't allow --user option
|
||||
python -m pip install -r ${DIR}/requirements.txt
|
||||
else
|
||||
# older versions of Ubuntu require --user option
|
||||
python3 -m pip install --user -r ${DIR}/requirements.txt
|
||||
if [[ $INSIDE_DOCKER == "true" ]]; then
|
||||
# when running inside a docker container we don't need to install
|
||||
# under --user since the installer user is root
|
||||
# its best to install packages globaly for any user to find
|
||||
python3 -m pip install -r /tmp/requirements.txt
|
||||
else
|
||||
python3 -m pip install --user -r ${DIR}/requirements.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
# NuttX toolchain (arm-none-eabi-gcc)
|
||||
if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
|
||||
echo
|
||||
echo "Installing NuttX dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing NuttX dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
automake \
|
||||
binutils-dev \
|
||||
bison \
|
||||
build-essential \
|
||||
flex \
|
||||
g++-multilib \
|
||||
gcc-multilib \
|
||||
gdb-multiarch \
|
||||
genromfs \
|
||||
gettext \
|
||||
gperf \
|
||||
@@ -145,7 +170,12 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
u-boot-tools \
|
||||
util-linux \
|
||||
vim-common \
|
||||
g++-arm-linux-gnueabihf \
|
||||
gcc-arm-linux-gnueabihf \
|
||||
g++-aarch64-linux-gnu \
|
||||
gcc-aarch64-linux-gnu \
|
||||
;
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
kconfig-frontends \
|
||||
@@ -158,32 +188,47 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
sudo usermod -a -G dialout $USER
|
||||
fi
|
||||
|
||||
# arm-none-eabi-gcc
|
||||
NUTTX_GCC_VERSION="9-2020-q2-update"
|
||||
NUTTX_GCC_VERSION_SHORT="9-2020q2"
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Verifying proper gcc version (${NUTTX_GCC_VERSION}), and installing if not found"
|
||||
echo
|
||||
|
||||
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}")
|
||||
GCC_VER_FOUND=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")
|
||||
fi
|
||||
|
||||
if [[ "$GCC_FOUND_VER" == "1" ]]; then
|
||||
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation"
|
||||
if [[ $(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}") == "1" ]]; then
|
||||
echo "📌 Skipping installation, the arm cross compiler was found"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
else
|
||||
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
|
||||
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}-${INSTALL_ARCH}-linux.tar.bz2 && \
|
||||
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;
|
||||
echo "📌 The arm cross compiler was not found";
|
||||
echo " * Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
|
||||
COMPILER_NAME="gcc-arm-none-eabi-${NUTTX_GCC_VERSION}"
|
||||
COMPILER_PATH="/tmp/$COMPILER_NAME-linux.tar.bz2"
|
||||
wget -O $COMPILER_PATH https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/${COMPILER_NAME}-${INSTALL_ARCH}-linux.tar.bz2
|
||||
sudo tar -jxf $COMPILER_PATH -C /opt/;
|
||||
|
||||
# add arm-none-eabi-gcc to user's PATH
|
||||
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH"
|
||||
|
||||
if grep -Fxq "$exportline" $HOME/.profile; then
|
||||
exportline="export PATH=\"/opt/${COMPILER_NAME}/bin:\$PATH\""
|
||||
if [[ $INSIDE_DOCKER == "true" ]]; then
|
||||
# when running on a docker container its best to set the environment globally
|
||||
# since we don't know which user is going to be running commands on the container
|
||||
touch /etc/profile.d/px4env.sh
|
||||
echo $exportline >> /etc/profile.d/px4env.sh
|
||||
elif grep -Fxq "$exportline" $HOME/.profile; then
|
||||
echo "${NUTTX_GCC_VERSION} path already set.";
|
||||
else
|
||||
echo $exportline >> $HOME/.profile;
|
||||
fi
|
||||
echo " * arm-none-eabi-gcc (${NUTTX_GCC_VERSION}) Installed Succesful to /opt/${COMPILER_NAME}/bin"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -191,45 +236,32 @@ fi
|
||||
if [[ $INSTALL_SIM == "true" ]]; then
|
||||
|
||||
echo
|
||||
echo "Installing PX4 simulation dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing PX4 Simulation Tools"
|
||||
echo
|
||||
|
||||
# default and Ubuntu 20.04
|
||||
gazebo_version=11
|
||||
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
gazebo_version=9
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
gazebo_version=11
|
||||
gazebo_packages="gazebo libgazebo-dev"
|
||||
fi
|
||||
|
||||
echo " * Gazebo Version $gazebo_version"
|
||||
echo $VERBOSE_BAR
|
||||
|
||||
# General simulation dependencies
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
bc \
|
||||
;
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
java_version=11
|
||||
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
java_version=13
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
java_version=11
|
||||
else
|
||||
java_version=14
|
||||
fi
|
||||
# Java (jmavsim or fastrtps)
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
ant \
|
||||
openjdk-$java_version-jre \
|
||||
openjdk-$java_version-jdk \
|
||||
libvecmath-java \
|
||||
;
|
||||
|
||||
# Set Java 11 as default
|
||||
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version")
|
||||
|
||||
# Gazebo
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
gazebo_version=9
|
||||
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
gazebo_packages="gazebo libgazebo-dev"
|
||||
else
|
||||
# default and Ubuntu 20.04
|
||||
gazebo_version=11
|
||||
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
|
||||
fi
|
||||
|
||||
# Installing Gazebo and dependencies
|
||||
# Setup OSRF Gazebo repository
|
||||
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
|
||||
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
|
||||
# Update list, since new gazebo-stable.list has been added
|
||||
@@ -257,7 +289,26 @@ if [[ $INSTALL_SIM == "true" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
echo
|
||||
echo "Relogin or reboot computer before attempting to build NuttX targets"
|
||||
if [[ $INSIDE_DOCKER == "true" ]]; then
|
||||
# cleanup installation
|
||||
rm -rf /tmp/
|
||||
fi
|
||||
|
||||
if [[ $INSIDE_DOCKER == "false" ]] && [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "💡 We recommend you relogin/reboot before attempting to build NuttX targets"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "#⚡️ PX4 Dependency Installer Ended Succesfully
|
||||
#
|
||||
# For more information on PX4 Autopilot check out our docs
|
||||
# at docs.px4.io, if you find a bug please file an issue
|
||||
# on GitHub https://github.com/px4/px4-autopilot"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
@@ -110,7 +110,7 @@ __EXPORT void board_spi_reset(int ms, int bus_mask)
|
||||
VDD_3V3_SENSORS_EN(true);
|
||||
up_mdelay(2);
|
||||
|
||||
/* Restore all the CS to ouputs inactive */
|
||||
/* Restore all the CS to outputs inactive */
|
||||
|
||||
for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) {
|
||||
if (px4_spi_buses[bus].bus == PX4_BUS_NUMBER_TO_PX4(1)) {
|
||||
|
||||
@@ -124,7 +124,7 @@ __EXPORT void board_spi_reset(int ms, int bus_mask)
|
||||
VDD_3V3_SENSORS_EN(true);
|
||||
up_mdelay(2);
|
||||
|
||||
/* Restore all the CS to ouputs inactive */
|
||||
/* Restore all the CS to outputs inactive */
|
||||
|
||||
for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) {
|
||||
if (px4_spi_buses[bus].bus == PX4_BUS_NUMBER_TO_PX4(1)) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* The FMURT1062 has 8MiB of QSPI FLASH beginning at address,
|
||||
* 0x0060:0000, Upto 512Kb of DTCM RAM beginning at 0x2000:0000, and 1MiB OCRAM
|
||||
* 0x0060:0000, Up to 512Kb of DTCM RAM beginning at 0x2000:0000, and 1MiB OCRAM
|
||||
* beginning at 0x2020:0000. Neither DTCM or SDRAM are used in this
|
||||
* configuration.
|
||||
*
|
||||
@@ -43,7 +43,7 @@
|
||||
* 256Kib to OCRRAM, 128Kib ITCM and 128Kib DTCM.
|
||||
* This can be changed by using a dcd by minipulating
|
||||
* IOMUX GPR16 and GPR17.
|
||||
* The configuartion we will use is 384Kib to OCRRAM, 0Kib ITCM and
|
||||
* The configuration we will use is 384Kib to OCRRAM, 0Kib ITCM and
|
||||
* 128Kib DTCM.
|
||||
*
|
||||
* This is the OCRAM inker script.
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* The FMURT1062 has 8MiB of QSPI FLASH beginning at address,
|
||||
* 0x0060:0000, Upto 512Kb of DTCM RAM beginning at 0x2000:0000, and 1MiB OCRAM
|
||||
* 0x0060:0000, Up to 512Kb of DTCM RAM beginning at 0x2000:0000, and 1MiB OCRAM
|
||||
* beginning at 0x2020:0000. Neither DTCM or SDRAM are used in this
|
||||
* configuratin.
|
||||
*/
|
||||
|
||||
@@ -93,7 +93,7 @@ __EXPORT void board_spi_reset(int ms, int bus_mask)
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore all the CS to ouputs inactive */
|
||||
/* Restore all the CS to outputs inactive */
|
||||
for (int bus = 0; bus < SPI_BUS_MAX_BUS_ITEMS; ++bus) {
|
||||
if (px4_spi_buses[bus].bus == PX4_BUS_NUMBER_TO_PX4(1)) {
|
||||
for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) {
|
||||
|
||||
@@ -68,7 +68,7 @@ class MavrosOffboardAttctlTest(MavrosTestCommon):
|
||||
self.att_setpoint_pub = rospy.Publisher(
|
||||
'mavros/setpoint_raw/attitude', AttitudeTarget, queue_size=1)
|
||||
|
||||
# send setpoints in seperate thread to better prevent failsafe
|
||||
# send setpoints in separate thread to better prevent failsafe
|
||||
self.att_thread = Thread(target=self.send_att, args=())
|
||||
self.att_thread.daemon = True
|
||||
self.att_thread.start()
|
||||
|
||||
@@ -73,7 +73,7 @@ class MavrosOffboardPosctlTest(MavrosTestCommon):
|
||||
self.pos_setpoint_pub = rospy.Publisher(
|
||||
'mavros/setpoint_position/local', PoseStamped, queue_size=1)
|
||||
|
||||
# send setpoints in seperate thread to better prevent failsafe
|
||||
# send setpoints in separate thread to better prevent failsafe
|
||||
self.pos_thread = Thread(target=self.send_pos, args=())
|
||||
self.pos_thread.daemon = True
|
||||
self.pos_thread.start()
|
||||
|
||||
@@ -66,7 +66,7 @@ class MavrosOffboardYawrateTest(MavrosTestCommon):
|
||||
self.att_setpoint_pub = rospy.Publisher(
|
||||
'mavros/setpoint_raw/attitude', AttitudeTarget, queue_size=1)
|
||||
|
||||
# send setpoints in seperate thread to better prevent failsafe
|
||||
# send setpoints in separate thread to better prevent failsafe
|
||||
self.att_thread = Thread(target=self.send_att, args=())
|
||||
self.att_thread.daemon = True
|
||||
self.att_thread.start()
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ float32 indicated_airspeed_m_s # indicated airspeed in m/s
|
||||
|
||||
float32 true_airspeed_m_s # true filtered airspeed in m/s
|
||||
|
||||
float32 air_temperature_celsius # air temperature in degrees celsius, -1000 if unknown
|
||||
float32 air_temperature_celsius # air temperature in degrees Celsius, -1000 if unknown
|
||||
|
||||
float32 confidence # confidence value from 0 to 1 for this sensor
|
||||
|
||||
@@ -21,7 +21,7 @@ uint16 capacity # actual capacity of the battery
|
||||
uint16 cycle_count # number of discharge cycles the battery has experienced
|
||||
uint16 average_time_to_empty # predicted remaining battery capacity based on the average rate of discharge in min
|
||||
uint16 serial_number # serial number of the battery pack
|
||||
uint16 manufacture_date # manufacture date, part of serial number of the battery pack. formated as: Day + Month×32 + (Year–1980)×512
|
||||
uint16 manufacture_date # manufacture date, part of serial number of the battery pack. Formatted as: Day + Month×32 + (Year–1980)×512
|
||||
uint16 state_of_health # state of health. FullChargeCapacity/DesignCapacity, 0-100%.
|
||||
uint16 max_error # max error, expected margin of error in % in the state-of-charge calculation with a range of 1 to 100%
|
||||
uint8 id # ID number of a battery. Should be unique and consistent for the lifetime of a vehicle. 1-indexed.
|
||||
|
||||
@@ -17,7 +17,7 @@ uint8 CELLULAR_STATUS_FLAG_CONNECTED=12 # One or more packet data bearers is ac
|
||||
uint8 CELLULAR_NETWORK_FAILED_REASON_NONE=0 # No error
|
||||
uint8 CELLULAR_NETWORK_FAILED_REASON_UNKNOWN=1 # Error state is unknown
|
||||
uint8 CELLULAR_NETWORK_FAILED_REASON_SIM_MISSING=2 # SIM is required for the modem but missing
|
||||
uint8 CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR=3 # SIM is available, but not usuable for connection
|
||||
uint8 CELLULAR_NETWORK_FAILED_REASON_SIM_ERROR=3 # SIM is available, but not usable for connection
|
||||
|
||||
uint16 status # Status bitmap 1: Roaming is active
|
||||
uint8 failure_reason #Failure reason when status in in CELLUAR_STATUS_FAILED
|
||||
|
||||
@@ -5,6 +5,6 @@ uint32 device_id # unique device ID for the sensor that does
|
||||
|
||||
float32 differential_pressure_pa # differential pressure reading in Pascals (may be negative)
|
||||
|
||||
float32 temperature # Temperature provided by sensor in celcius, NAN if unknown
|
||||
float32 temperature # Temperature provided by sensor in degrees Celsius, NAN if unknown
|
||||
|
||||
uint32 error_count # Number of errors detected by driver
|
||||
|
||||
@@ -30,7 +30,7 @@ bool gps_data_stopped_using_alternate # 3 - true when the gps data has stoppe
|
||||
bool height_sensor_timeout # 4 - true when the height sensor has not been used to correct the state estimates for a significant time period
|
||||
bool stopping_navigation # 5 - true when the filter has insufficient data to estimate velocity and position and is falling back to an attitude, height and height rate mode of operation
|
||||
bool invalid_accel_bias_cov_reset # 6 - true when the filter has detected bad acceerometer bias state esitmstes and has reset the corresponding covariance matrix elements
|
||||
bool bad_yaw_using_gps_course # 7 - true when the fiter has detected an invalid yaw esitmate and has reset the yaw angle to the GPS ground course
|
||||
bool bad_yaw_using_gps_course # 7 - true when the filter has detected an invalid yaw estimate and has reset the yaw angle to the GPS ground course
|
||||
bool stopping_mag_use # 8 - true when the filter has detected bad magnetometer data and is stopping further use of the magnetomer data
|
||||
bool vision_data_stopped # 9 - true when the vision system data has stopped for a significant time period
|
||||
bool emergency_yaw_reset_mag_stopped # 10 - true when the filter has detected bad magnetometer data, has reset the yaw to anothter source of data and has stopped further use of the magnetomer data
|
||||
|
||||
@@ -18,8 +18,8 @@ float32 rng_vpos # range sensor height innovation (m) and innovation variance (m
|
||||
float32 baro_vpos # barometer height innovation (m) and innovation variance (m**2)
|
||||
|
||||
# Auxiliary velocity
|
||||
float32[2] aux_hvel # horizontal auxiliar velocity innovation from landing target measurement (m/sec) and innovation variance ((m/sec)**2)
|
||||
float32 aux_vvel # vertical auxiliar velocity innovation from landing target measurement (m/sec) and innovation variance ((m/sec)**2)
|
||||
float32[2] aux_hvel # horizontal auxiliary velocity innovation from landing target measurement (m/sec) and innovation variance ((m/sec)**2)
|
||||
float32 aux_vvel # vertical auxiliary velocity innovation from landing target measurement (m/sec) and innovation variance ((m/sec)**2)
|
||||
|
||||
# Optical flow
|
||||
float32[2] flow # flow innvoation (rad/sec) and innovation variance ((rad/sec)**2)
|
||||
|
||||
@@ -9,7 +9,7 @@ bool cs_yaw_align # 1 - true if the filter yaw alignment is complet
|
||||
bool cs_gps # 2 - true if GPS measurement fusion is intended
|
||||
bool cs_opt_flow # 3 - true if optical flow measurements fusion is intended
|
||||
bool cs_mag_hdg # 4 - true if a simple magnetic yaw heading fusion is intended
|
||||
bool cs_mag_3d # 5 - true if 3-axis magnetometer measurement fusion is inteded
|
||||
bool cs_mag_3d # 5 - true if 3-axis magnetometer measurement fusion is intended
|
||||
bool cs_mag_dec # 6 - true if synthetic magnetic declination measurements fusion is intended
|
||||
bool cs_in_air # 7 - true when the vehicle is airborne
|
||||
bool cs_wind # 8 - true when wind velocity is being estimated
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
uint8 instance # Instance of GNSS reciever
|
||||
uint8 instance # Instance of GNSS receiver
|
||||
|
||||
uint8 len # length of data, MSB bit set = message to the gps device,
|
||||
# clear = message from the device
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ int32 rssi # receive signal strength indicator (RSSI): < 0: Undefined, 0: no
|
||||
bool rc_failsafe # explicit failsafe flag: true on TX failure or TX out of range , false otherwise. Only the true state is reliable, as there are some (PPM) receivers on the market going into failsafe without telling us explicitly.
|
||||
bool rc_lost # RC receiver connection status: True,if no frame has arrived in the expected time, false otherwise. True usually means that the receiver has been disconnected, but can also indicate a radio link loss on "stupid" systems. Will remain false, if a RX with failsafe option continues to transmit frames after a link loss.
|
||||
|
||||
uint16 rc_lost_frame_count # Number of lost RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike funtionality.
|
||||
uint16 rc_total_frame_count # Number of total RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike funtionality.
|
||||
uint16 rc_lost_frame_count # Number of lost RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality.
|
||||
uint16 rc_total_frame_count # Number of total RC frames. Note: intended purpose: observe the radio link quality if RSSI is not available. This value must not be used to trigger any failsafe-alike functionality.
|
||||
uint16 rc_ppm_frame_length # Length of a single PPM frame. Zero for non-PPM systems
|
||||
|
||||
uint8 input_source # Input source
|
||||
|
||||
@@ -4,7 +4,7 @@ uint16 tx_buf_write_index # current size of the tx buffer
|
||||
uint16 rx_buf_read_index # the rx buffer is parsed up to that index
|
||||
uint16 rx_buf_end_index # current size of the rx buffer
|
||||
uint16 failed_sbd_sessions # number of failed sbd sessions
|
||||
uint16 successful_sbd_sessions # number of successfull sbd sessions
|
||||
uint16 successful_sbd_sessions # number of successful sbd sessions
|
||||
uint16 num_tx_buf_reset # number of times the tx buffer was reset
|
||||
uint8 signal_quality # current signal quality, 0 is no signal, 5 the best
|
||||
uint8 state # current state of the driver, see the satcom_state of IridiumSBD.h for the definition
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ uint8 MODE_BLINK_FAST = 5
|
||||
uint8 MODE_BREATHE = 6 # continuously increase & decrease brightness (solid color if driver does not support it)
|
||||
uint8 MODE_FLASH = 7 # two fast blinks (on/off) with timing as in MODE_BLINK_FAST and then off for a while
|
||||
|
||||
uint8 MAX_PRIORITY = 2 # maxium priority (minimum is 0)
|
||||
uint8 MAX_PRIORITY = 2 # maximum priority (minimum is 0)
|
||||
|
||||
|
||||
uint8 led_mask # bitmask which LED(s) to control, set to 0xff for all
|
||||
|
||||
@@ -9,8 +9,8 @@ uint8 abort_status
|
||||
|
||||
# abort reasons
|
||||
# after the manual operator abort, corresponds to individual bits of param FW_LND_ABORT
|
||||
uint8 kNotAborted = 0
|
||||
uint8 kAbortedByOperator = 1
|
||||
uint8 kTerrainNotFound = 2 # FW_LND_ABORT (1 << 0)
|
||||
uint8 kTerrainTimeout = 3 # FW_LND_ABORT (1 << 1)
|
||||
uint8 kUnknownAbortCriterion = 4
|
||||
uint8 NOT_ABORTED = 0
|
||||
uint8 ABORTED_BY_OPERATOR = 1
|
||||
uint8 TERRAIN_NOT_FOUND = 2 # FW_LND_ABORT (1 << 0)
|
||||
uint8 TERRAIN_TIMEOUT = 3 # FW_LND_ABORT (1 << 1)
|
||||
uint8 UNKNOWN_ABORT_CRITERION = 4
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
float32 indicated_frequency_rpm # indicated rotor Frequency in Revolution per minute
|
||||
float32 estimated_accurancy_rpm # estimated accurancy in Revolution per minute
|
||||
float32 estimated_accurancy_rpm # estimated accuracy in Revolution per minute
|
||||
|
||||
@@ -3,6 +3,6 @@ uint64 timestamp_sample
|
||||
|
||||
uint32 device_id # unique device ID for the sensor that does not change between power cycles
|
||||
|
||||
float32 temperature # Temperature provided by sensor (Celcius)
|
||||
float32 temperature # Temperature provided by sensor (Celsius)
|
||||
|
||||
float32 humidity # Humidity provided by sensor
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Status of the takeoff state machine currently just availble for multicopters
|
||||
# Status of the takeoff state machine currently just available for multicopters
|
||||
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
@@ -11,4 +11,4 @@ uint8 TAKEOFF_STATE_FLIGHT = 5
|
||||
|
||||
uint8 takeoff_state
|
||||
|
||||
float32 tilt_limit # limited tilt feasability during takeoff, contains maximum tilt otherwise
|
||||
float32 tilt_limit # limited tilt feasibility during takeoff, contains maximum tilt otherwise
|
||||
|
||||
@@ -413,7 +413,7 @@ def convert_dir(format_idx, inputdir, outputdir, package, templatedir):
|
||||
def copy_changed(inputdir, outputdir, prefix='', quiet=False):
|
||||
"""
|
||||
Copies files from inputdir to outputdir if they don't exist in
|
||||
ouputdir or if their content changed
|
||||
outputdir or if their content changed
|
||||
"""
|
||||
|
||||
# Make sure output directory exists:
|
||||
|
||||
@@ -8,8 +8,8 @@ uint32 sessionid # UWB SessionID
|
||||
uint32 time_offset # Time between Ranging Rounds in ms
|
||||
uint16 status # status feedback #
|
||||
|
||||
uint16[12] anchor_distance # distance in cm to each UWB Anchor (UWB Device wich takes part in Ranging)
|
||||
uint16[12] anchor_distance # distance in cm to each UWB Anchor (UWB Device which takes part in Ranging)
|
||||
bool[12] nlos # Visual line of sight yes/no
|
||||
float32[12] aoafirst # Angle of arrival of first incomming RX msg
|
||||
float32[12] aoafirst # Angle of arrival of first incoming RX msg
|
||||
|
||||
float32[3] position # Position of the Landing point in relation to the Drone (x,y,z in Meters NED)
|
||||
|
||||
@@ -99,7 +99,7 @@ uint16 VEHICLE_CMD_FIXED_MAG_CAL_YAW = 42006 # Magnetometer calibrati
|
||||
|
||||
# PX4 vehicle commands (beyond 16 bit mavlink commands)
|
||||
uint32 VEHICLE_CMD_PX4_INTERNAL_START = 65537 # start of PX4 internal only vehicle commands (> UINT16_MAX)
|
||||
uint32 VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN = 100000 # Sets the GPS co-ordinates of the vehicle local origin (0,0,0) position. |Empty|Empty|Empty|Empty|Latitude|Longitude|Altitude|
|
||||
uint32 VEHICLE_CMD_SET_GPS_GLOBAL_ORIGIN = 100000 # Sets the GPS coordinates of the vehicle local origin (0,0,0) position. |Empty|Empty|Empty|Empty|Latitude|Longitude|Altitude|
|
||||
|
||||
uint8 VEHICLE_MOUNT_MODE_RETRACT = 0 # Load and keep safe position (Roll,Pitch,Yaw) from permanent memory and stop stabilization |
|
||||
uint8 VEHICLE_MOUNT_MODE_NEUTRAL = 1 # Load and keep neutral position (Roll,Pitch,Yaw) from permanent memory. |
|
||||
|
||||
@@ -32,7 +32,7 @@ float32 y # East position
|
||||
float32 z # Down position
|
||||
|
||||
# Orientation quaternion. First value NaN if invalid/unknown
|
||||
float32[4] q # Quaternion rotation from FRD body frame to refernce frame
|
||||
float32[4] q # Quaternion rotation from FRD body frame to reference frame
|
||||
float32[4] q_offset # Quaternion rotation from odometry reference frame to navigation frame
|
||||
|
||||
# Row-major representation of 6x6 pose cross-covariance matrix URT.
|
||||
|
||||
@@ -854,7 +854,7 @@ __EXPORT void board_get_uuid32(uuid_uint32_t uuid_words); // DEPRICATED use boar
|
||||
*
|
||||
* Input Parameters:
|
||||
* format_buffer - A pointer to a bufferer of at least PX4_CPU_UUID_WORD32_FORMAT_SIZE
|
||||
* that will contain a 0 terminated string formated as described
|
||||
* that will contain a 0 terminated string formatted as described
|
||||
* the format string and optional separator.
|
||||
* size - The size of the buffer (should be atleaset PX4_CPU_UUID_WORD32_FORMAT_SIZE)
|
||||
* format - The fort mat specifier for the hex digit see CPU_UUID_FORMAT
|
||||
@@ -870,7 +870,7 @@ __EXPORT void board_get_uuid32(uuid_uint32_t uuid_words); // DEPRICATED use boar
|
||||
* 3238333641203833355110
|
||||
*
|
||||
* Returned Value:
|
||||
* The format buffer is populated with a 0 terminated string formated as described.
|
||||
* The format buffer is populated with a 0 terminated string formatted as described.
|
||||
* Zero (OK) is returned on success;
|
||||
*
|
||||
************************************************************************************/
|
||||
@@ -907,7 +907,7 @@ int board_get_mfguid(mfguid_t mfgid);
|
||||
*
|
||||
* Input Parameters:
|
||||
* format_buffer - A pointer to a bufferer of at least PX4_CPU_MFGUID_FORMAT_SIZE
|
||||
* that will contain a 0 terminated string formated as 0 prefixed
|
||||
* that will contain a 0 terminated string formatted as 0 prefixed
|
||||
* lowercase hex. 2 charaters per digit of the mfguid_t.
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -964,7 +964,7 @@ int board_get_px4_guid(px4_guid_t guid);
|
||||
* manufactures Unique ID or define BOARD_OVERRIDE_PX4_GUID
|
||||
*
|
||||
* Input Parameters:
|
||||
* format_buffer - A buffer to receive the 0 terminated formated px4
|
||||
* format_buffer - A buffer to receive the 0 terminated formatted px4
|
||||
* guid string.
|
||||
* size - Size of the buffer provided. Normally this would
|
||||
* be PX4_GUID_FORMAT_SIZE.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
/**
|
||||
* @file log.h
|
||||
* Platform dependant logging/debug implementation
|
||||
* Platform dependent logging/debug implementation
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -541,7 +541,7 @@ int run_startup_script(const std::string &commands_file, const std::string &abso
|
||||
void wait_to_exit()
|
||||
{
|
||||
while (!_exit_requested) {
|
||||
// needs to be a regular sleep not dependant on lockstep (not px4_usleep)
|
||||
// needs to be a regular sleep not dependent on lockstep (not px4_usleep)
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ $ batt_smbus -X write_flash 19069 2 27 0
|
||||
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("man_info", "Prints manufacturer info.");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("unseal", "Unseals the devices flash memory to enable write_flash commands.");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("seal", "Seals the devices flash memory to disbale write_flash commands.");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("seal", "Seals the devices flash memory to disable write_flash commands.");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("suspend", "Suspends the driver from rescheduling the cycle.");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("resume", "Resumes the driver from suspension.");
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* @file camera_trigger.cpp
|
||||
*
|
||||
* External camera-IMU synchronisation and triggering, and support for
|
||||
* camera manipulation using PWM signals over FMU auxillary pins.
|
||||
* camera manipulation using PWM signals over FMU auxiliary pins.
|
||||
*
|
||||
* @author Mohammed Kabir <kabir@uasys.io>
|
||||
* @author Kelly Steich <kelly.steich@wingtra.com>
|
||||
|
||||
@@ -123,7 +123,7 @@ PARAM_DEFINE_INT32(UCAN1_BMS_BS_SUB, -1);
|
||||
PARAM_DEFINE_INT32(UCAN1_BMS_BP_SUB, -1);
|
||||
|
||||
/**
|
||||
* Cyphal leagcy battery port ID.
|
||||
* Cyphal legacy battery port ID.
|
||||
*
|
||||
* @min -1
|
||||
* @max 6143
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "api/argus_def.h"
|
||||
|
||||
/*!***************************************************************************
|
||||
* @brief A printf-like function to print formated data to an debugging interface.
|
||||
* @brief A printf-like function to print formatted data to an debugging interface.
|
||||
*
|
||||
* @details Writes the C string pointed by fmt_t to an output. If format
|
||||
* includes format specifiers (subsequences beginning with %), the
|
||||
|
||||
@@ -482,10 +482,12 @@ int PGA460::print_usage(const char *reason)
|
||||
PRINT_MODULE_DESCRIPTION(
|
||||
R"DESCR_STR(
|
||||
### Description
|
||||
|
||||
Ultrasonic range finder driver that handles the communication with the device and publishes the distance via uORB.
|
||||
|
||||
### Implementation
|
||||
This driver is implented as a NuttX task. This Implementation was chosen due to the need for polling on a message
|
||||
|
||||
This driver is implemented as a NuttX task. This Implementation was chosen due to the need for polling on a message
|
||||
via UART, which is not supported in the work_queue. This driver continuously takes range measurements while it is
|
||||
running. A simple algorithm to detect false readings is implemented at the driver levelin an attemptto improve
|
||||
the quality of data that is being published. The driver will not publish data at all if it deems the sensor data
|
||||
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
int read_eeprom();
|
||||
|
||||
/**
|
||||
* @brief Writes the user defined paramaters to device EEPROM.
|
||||
* @brief Writes the user defined parameters to device EEPROM.
|
||||
* @return Returns true if the EEPROM was successfully written to.
|
||||
*/
|
||||
int write_eeprom();
|
||||
@@ -341,7 +341,7 @@ private:
|
||||
int initialize_device_settings();
|
||||
|
||||
/**
|
||||
* @brief Writes the user defined paramaters to device register map.
|
||||
* @brief Writes the user defined parameters to device register map.
|
||||
* @return Returns true if the thresholds were successfully written.
|
||||
*/
|
||||
int initialize_thresholds();
|
||||
|
||||
@@ -71,7 +71,7 @@ using namespace time_literals;
|
||||
|
||||
/**
|
||||
* Assume standard deviation to be equal to sensor resolution.
|
||||
* Static bench tests have shown that the sensor ouput does
|
||||
* Static bench tests have shown that the sensor output does
|
||||
* not vary if the unit is not moved.
|
||||
*/
|
||||
#define SENS_VARIANCE 0.045f * 0.045f
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#include <board_config.h>
|
||||
|
||||
// allow the board to override the number (or maxiumum number) of LED's it has
|
||||
// allow the board to override the number (or maximum number) of LED's it has
|
||||
#ifndef BOARD_MAX_LEDS
|
||||
#define BOARD_MAX_LEDS 4
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define FXAS21002C_MAX_RATE 800
|
||||
#define FXAS21002C_DEFAULT_RATE FXAS21002C_MAX_RATE
|
||||
#define FXAS21002C_DEFAULT_RANGE_DPS 2000
|
||||
#define FXAS21002C_DEFAULT_ONCHIP_FILTER_FREQ 64 // ODR dependant
|
||||
#define FXAS21002C_DEFAULT_ONCHIP_FILTER_FREQ 64 // ODR dependent
|
||||
|
||||
/*
|
||||
we set the timer interrupt to run a bit faster than the desired
|
||||
|
||||
@@ -96,7 +96,7 @@ VOXLPM::init()
|
||||
ret = init_ina231();
|
||||
|
||||
} else {
|
||||
PX4_ERR("Unkown device address");
|
||||
PX4_ERR("Unknown device address");
|
||||
ret = PX4_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,8 @@ static void usage()
|
||||
This driver communicates over UART with the [Roboclaw motor driver](http://downloads.basicmicro.com/docs/roboclaw_user_manual.pdf).
|
||||
It performs two tasks:
|
||||
|
||||
- Control the motors based on the `actuator_controls_0` UOrb topic.
|
||||
- Read the wheel encoders and publish the raw data in the `wheel_encoders` UOrb topic
|
||||
- Control the motors based on the `actuator_controls_0` UOrb topic.
|
||||
- Read the wheel encoders and publish the raw data in the `wheel_encoders` UOrb topic
|
||||
|
||||
In order to use this driver, the Roboclaw should be put into Packet Serial mode (see the linked documentation), and
|
||||
your flight controller's UART port should be connected to the Roboclaw as shown in the documentation. For Pixhawk 4,
|
||||
@@ -109,16 +109,18 @@ the driver terminates immediately.
|
||||
|
||||
The command to start this driver is:
|
||||
|
||||
$ roboclaw start <device> <baud>
|
||||
```
|
||||
$ roboclaw start <device> <baud>
|
||||
```
|
||||
|
||||
`<device>` is the name of the UART port. On the Pixhawk 4, this is `/dev/ttyS3`.
|
||||
`<baud>` is te baud rate.
|
||||
- `<device>` is the name of the UART port. On the Pixhawk 4, this is `/dev/ttyS3`.
|
||||
- `<baud>` is the baud rate.
|
||||
|
||||
All available commands are:
|
||||
|
||||
- `$ roboclaw start <device> <baud>`
|
||||
- `$ roboclaw status`
|
||||
- `$ roboclaw stop`
|
||||
- `$ roboclaw start <device> <baud>`
|
||||
- `$ roboclaw status`
|
||||
- `$ roboclaw stop`
|
||||
)DESCR_STR");
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ PARAM_DEFINE_INT32(PCF8583_POOL, 1000000);
|
||||
/**
|
||||
* PCF8583 rotorfreq (i2c) pulse reset value
|
||||
*
|
||||
* Internal device counter is reset to 0 when overun this value,
|
||||
* counter is able to store upto 6 digits
|
||||
* reset of counter takes some time - measurement with reset has worse accurancy.
|
||||
* Internal device counter is reset to 0 when overrun this value,
|
||||
* counter is able to store up to 6 digits
|
||||
* reset of counter takes some time - measurement with reset has worse accuracy.
|
||||
* 0 means reset counter after every measurement.
|
||||
*
|
||||
* @reboot_required true
|
||||
|
||||
@@ -511,17 +511,22 @@ int TAP_ESC::print_usage(const char *reason)
|
||||
PRINT_MODULE_DESCRIPTION(
|
||||
R"DESCR_STR(
|
||||
### Description
|
||||
|
||||
This module controls the TAP_ESC hardware via UART. It listens on the
|
||||
actuator_controls topics, does the mixing and writes the PWM outputs.
|
||||
|
||||
### Implementation
|
||||
Currently the module is implementd as a threaded version only, meaning that it
|
||||
|
||||
Currently the module is implemented as a threaded version only, meaning that it
|
||||
runs in its own thread instead of on the work queue.
|
||||
|
||||
### Example
|
||||
The module is typically started with:
|
||||
tap_esc start -d /dev/ttyS2 -n <1-8>
|
||||
|
||||
The module is typically started with:
|
||||
|
||||
```
|
||||
tap_esc start -d /dev/ttyS2 -n <1-8>
|
||||
```
|
||||
)DESCR_STR");
|
||||
|
||||
PRINT_MODULE_USAGE_NAME("tap_esc", "driver");
|
||||
|
||||
@@ -107,7 +107,7 @@ typedef struct {
|
||||
uint16_t current; // 0.0 - 200.0 A
|
||||
#endif
|
||||
#if defined(ESC_HAVE_TEMPERATURE_SENSOR)
|
||||
uint8_t temperature; // 0 - 256 degree celsius
|
||||
uint8_t temperature; // 0 - 256 degrees Celsius
|
||||
#endif
|
||||
} RunInfoRepsonse;
|
||||
/****** Run ***********/
|
||||
@@ -232,7 +232,7 @@ typedef struct {
|
||||
*
|
||||
* speed: -32767 - 32767 rpm
|
||||
*
|
||||
* temperature: 0 - 256 celsius degree (if available)
|
||||
* temperature: 0 - 256 degrees Celsius (if available)
|
||||
* voltage: 0.00 - 100.00 V (if available)
|
||||
* current: 0.0 - 200.0 A (if available)
|
||||
*/
|
||||
|
||||
@@ -115,7 +115,7 @@ UavcanBatteryBridge::battery_sub_cb(const uavcan::ReceivedDataStructure<uavcan::
|
||||
|
||||
_battery_status[instance].remaining = msg.state_of_charge_pct / 100.0f; // between 0 and 1
|
||||
// _battery_status[instance].scale = msg.; // Power scaling factor, >= 1, or -1 if unknown
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celcius
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celsius
|
||||
// _battery_status[instance].cell_count = msg.;
|
||||
_battery_status[instance].connected = true;
|
||||
_battery_status[instance].source = msg.status_flags & uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE;
|
||||
@@ -238,7 +238,7 @@ UavcanBatteryBridge::filterData(const uavcan::ReceivedDataStructure<uavcan::equi
|
||||
|
||||
/* Override data that is expected to arrive from UAVCAN msg*/
|
||||
_battery_status[instance] = _battery[instance]->getBatteryStatus();
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celcius
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celsius
|
||||
_battery_status[instance].serial_number = msg.model_instance_id;
|
||||
_battery_status[instance].id = msg.getSrcNodeID().get(); // overwrite zeroed index from _battery
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ and the following commandline defines:
|
||||
|UAVCAN_KINETIS_TIMER_NUMBER | - {0..3} Sets the Periodic Interrupt Timer (PITn) channel |
|
||||
|
||||
Things that could be improved:
|
||||
1. Build time command line configuartion of Mailbox/FIFO and filters
|
||||
2. Build time command line configuartion clock source
|
||||
- Curently the driver use `const uavcan::uint8_t CLOCKSEL = 0;` To Select OSCERCLK
|
||||
1. Build time command line configuration of Mailbox/FIFO and filters
|
||||
2. Build time command line configuration clock source
|
||||
- Currently the driver use `const uavcan::uint8_t CLOCKSEL = 0;` To Select OSCERCLK
|
||||
3. Dynamic filter disable. There are no filter enable bits on the FlexCAN, just the number of Filters
|
||||
can be set. But this changes the memory map. So the configuration show below has been chosen.
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ PARAM_DEFINE_INT32(UAVCAN_SUB_HYGRO, 0);
|
||||
/**
|
||||
* subscription ICE
|
||||
*
|
||||
* Enable UAVCAN internal combusion engine (ICE) subscription.
|
||||
* Enable UAVCAN internal combustion engine (ICE) subscription.
|
||||
* uavcan::equipment::ice::reciprocating::Status
|
||||
*
|
||||
* @boolean
|
||||
|
||||
@@ -13,7 +13,7 @@ parameters:
|
||||
UWB_INIT_OFF_X:
|
||||
description:
|
||||
short: UWB sensor X offset in body frame
|
||||
long: UWB sensor positioning in relation to Drone in NED. X offset. A Positiv offset results in a Position o
|
||||
long: UWB sensor positioning in relation to Drone in NED. X offset. A Positive offset results in a Position o
|
||||
type: float
|
||||
unit: m
|
||||
decimal: 2
|
||||
|
||||
@@ -394,7 +394,7 @@ int UWB_SR150::distance()
|
||||
break;
|
||||
|
||||
case UWB_LIN_DEP_FOR_THREE:
|
||||
PX4_INFO("UWB localization: linear dependant with 3 Anchors");
|
||||
PX4_INFO("UWB localization: linear dependent with 3 Anchors");
|
||||
break;
|
||||
|
||||
case UWB_ANC_ON_ONE_LEVEL:
|
||||
@@ -402,7 +402,7 @@ int UWB_SR150::distance()
|
||||
break;
|
||||
|
||||
case UWB_LIN_DEP_FOR_FOUR:
|
||||
PX4_INFO("UWB localization: linear dependant with four or more Anchors");
|
||||
PX4_INFO("UWB localization: linear dependent with four or more Anchors");
|
||||
break;
|
||||
|
||||
case UWB_RANK_ZERO:
|
||||
|
||||
@@ -49,7 +49,7 @@ float calc_IAS_corrected(enum AIRSPEED_COMPENSATION_MODEL pmodel, enum AIRSPEED_
|
||||
float tube_len, float tube_dia_mm, float differential_pressure, float pressure_ambient, float temperature_celsius)
|
||||
{
|
||||
if (!PX4_ISFINITE(temperature_celsius)) {
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees celcius
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees Celsius
|
||||
}
|
||||
|
||||
// air density in kg/m3
|
||||
@@ -189,7 +189,7 @@ float calc_IAS(float differential_pressure)
|
||||
float calc_TAS_from_CAS(float speed_calibrated, float pressure_ambient, float temperature_celsius)
|
||||
{
|
||||
if (!PX4_ISFINITE(temperature_celsius)) {
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees celcius
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees Celsius
|
||||
}
|
||||
|
||||
return speed_calibrated * sqrtf(CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C / get_air_density(pressure_ambient,
|
||||
@@ -222,7 +222,7 @@ float calc_TAS(float total_pressure, float static_pressure, float temperature_ce
|
||||
float get_air_density(float static_pressure, float temperature_celsius)
|
||||
{
|
||||
if (!PX4_ISFINITE(temperature_celsius)) {
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees celcius
|
||||
temperature_celsius = 15.f; // ICAO Standard Atmosphere 15 degrees Celsius
|
||||
}
|
||||
|
||||
return static_pressure / (CONSTANTS_AIR_GAS_CONST * (temperature_celsius - CONSTANTS_ABSOLUTE_NULL_CELSIUS));
|
||||
|
||||
@@ -92,7 +92,7 @@ __EXPORT float calc_IAS(float differential_pressure);
|
||||
*
|
||||
* @param speed_equivalent current calibrated airspeed
|
||||
* @param pressure_ambient pressure at the side of the tube/airplane
|
||||
* @param temperature_celsius air temperature in degrees celcius
|
||||
* @param temperature_celsius air temperature in degrees Celsius
|
||||
* @return TAS in m/s
|
||||
*/
|
||||
__EXPORT float calc_TAS_from_CAS(float speed_indicated, float pressure_ambient,
|
||||
@@ -116,7 +116,7 @@ __EXPORT float calc_CAS_from_IAS(float speed_indicated, float scale);
|
||||
*
|
||||
* @param total_pressure pressure inside the pitot/prandtl tube
|
||||
* @param static_pressure pressure at the side of the tube/airplane
|
||||
* @param temperature_celsius air temperature in degrees celcius
|
||||
* @param temperature_celsius air temperature in degrees Celsius
|
||||
* @return true airspeed in m/s
|
||||
*/
|
||||
__EXPORT float calc_TAS(float total_pressure, float static_pressure, float temperature_celsius);
|
||||
@@ -125,7 +125,7 @@ __EXPORT float calc_TAS(float total_pressure, float static_pressure, float tempe
|
||||
* Calculates air density.
|
||||
*
|
||||
* @param static_pressure ambient pressure in millibar
|
||||
* @param temperature_celcius air / ambient temperature in celcius
|
||||
* @param temperature_celcius air / ambient temperature in Celsius
|
||||
*/
|
||||
__EXPORT float get_air_density(float static_pressure, float temperature_celsius);
|
||||
|
||||
@@ -135,7 +135,7 @@ __EXPORT float get_air_density(float static_pressure, float temperature_celsius)
|
||||
*
|
||||
* @param speed_true current true airspeed
|
||||
* @param pressure_ambient pressure at the side of the tube/airplane
|
||||
* @param temperature_celsius air temperature in degrees celcius
|
||||
* @param temperature_celsius air temperature in degrees Celsius
|
||||
* @return CAS in m/s
|
||||
*/
|
||||
__EXPORT float calc_CAS_from_TAS(float speed_true, float pressure_ambient,
|
||||
|
||||
@@ -43,7 +43,7 @@ parameters:
|
||||
description:
|
||||
short: Voltage drop per cell on full throttle
|
||||
long: |
|
||||
This implicitely defines the internal resistance
|
||||
This implicitly defines the internal resistance
|
||||
to maximum current ratio for battery 1 and assumes linearity.
|
||||
A good value to use is the difference between the
|
||||
5C and 20-25C load. Not used if BAT${i}_R_INTERNAL is
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
int populate_smbus_data(battery_status_s &msg);
|
||||
|
||||
virtual void RunImpl(); // Can be overriden by derived implimentation
|
||||
virtual void RunImpl(); // Can be overridden by derived implimentation
|
||||
|
||||
virtual void custom_method(const BusCLIArguments &cli) = 0; //Has be overriden by derived implimentation
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Read info from battery on startup.
|
||||
* @return Returns PX4_OK on success, PX4_ERROR on failure. Can be overriden by derived implimentation
|
||||
* @return Returns PX4_OK on success, PX4_ERROR on failure. Can be overridden by derived implimentation
|
||||
*/
|
||||
virtual int get_startup_info();
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* get maxium time between two consecutive calls to update() in us.
|
||||
* get maximum time between two consecutive calls to update() in us.
|
||||
*/
|
||||
int maximum_update_interval() const
|
||||
{
|
||||
|
||||
@@ -44,14 +44,25 @@ add_custom_command(OUTPUT ${functions_header}
|
||||
add_custom_target(output_functions_header DEPENDS ${functions_header})
|
||||
|
||||
px4_add_library(mixer_module
|
||||
functions/FunctionActuatorSet.hpp
|
||||
functions/FunctionConstantMax.hpp
|
||||
functions/FunctionConstantMin.hpp
|
||||
functions/FunctionGimbal.hpp
|
||||
functions/FunctionLandingGear.hpp
|
||||
functions/FunctionManualRC.hpp
|
||||
functions/FunctionMotors.hpp
|
||||
functions/FunctionParachute.hpp
|
||||
functions/FunctionServos.hpp
|
||||
|
||||
actuator_test.cpp
|
||||
actuator_test.hpp
|
||||
mixer_module.cpp
|
||||
functions.cpp
|
||||
mixer_module.hpp
|
||||
)
|
||||
|
||||
add_dependencies(mixer_module output_functions_header)
|
||||
target_compile_options(mixer_module PRIVATE ${MAX_CUSTOM_OPT_LEVEL})
|
||||
|
||||
target_include_directories(mixer_module PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
px4_add_functional_gtest(SRC mixer_module_tests.cpp LINKLIBS mixer_module mixer)
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "actuator_test.hpp"
|
||||
|
||||
#include "functions/FunctionMotors.hpp"
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
ActuatorTest::ActuatorTest(const OutputFunction function_assignments[MAX_ACTUATORS])
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "functions.hpp"
|
||||
#include <mixer_module/output_functions.hpp>
|
||||
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <uORB/topics/actuator_test.h>
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
FunctionMotors::FunctionMotors(const Context &context)
|
||||
: _topic(&context.work_item, ORB_ID(actuator_motors)),
|
||||
_thrust_factor(context.thrust_factor)
|
||||
{
|
||||
for (int i = 0; i < actuator_motors_s::NUM_CONTROLS; ++i) {
|
||||
_data.control[i] = NAN;
|
||||
}
|
||||
}
|
||||
void FunctionMotors::update()
|
||||
{
|
||||
if (_topic.update(&_data)) {
|
||||
updateValues(_data.reversible_flags, _thrust_factor, _data.control, actuator_motors_s::NUM_CONTROLS);
|
||||
}
|
||||
}
|
||||
|
||||
FunctionServos::FunctionServos(const Context &context)
|
||||
: _topic(&context.work_item, ORB_ID(actuator_servos))
|
||||
{
|
||||
for (int i = 0; i < actuator_servos_s::NUM_CONTROLS; ++i) {
|
||||
_data.control[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
FunctionActuatorSet::FunctionActuatorSet()
|
||||
{
|
||||
for (int i = 0; i < max_num_actuators; ++i) {
|
||||
_data[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionActuatorSet::update()
|
||||
{
|
||||
vehicle_command_s vehicle_command;
|
||||
|
||||
while (_topic.update(&vehicle_command)) {
|
||||
if (vehicle_command.command == vehicle_command_s::VEHICLE_CMD_DO_SET_ACTUATOR) {
|
||||
int index = (int)(vehicle_command.param7 + 0.5f);
|
||||
|
||||
if (index == 0) {
|
||||
_data[0] = vehicle_command.param1;
|
||||
_data[1] = vehicle_command.param2;
|
||||
_data[2] = vehicle_command.param3;
|
||||
_data[3] = vehicle_command.param4;
|
||||
_data[4] = vehicle_command.param5;
|
||||
_data[5] = vehicle_command.param6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionLandingGear::update()
|
||||
{
|
||||
landing_gear_s landing_gear;
|
||||
|
||||
if (_topic.update(&landing_gear)) {
|
||||
if (landing_gear.landing_gear == landing_gear_s::GEAR_DOWN) {
|
||||
_data = -1.f;
|
||||
|
||||
} else if (landing_gear.landing_gear == landing_gear_s::GEAR_UP) {
|
||||
_data = 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FunctionManualRC::FunctionManualRC()
|
||||
{
|
||||
for (int i = 0; i < num_data_points; ++i) {
|
||||
_data[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionManualRC::update()
|
||||
{
|
||||
manual_control_setpoint_s manual_control_setpoint;
|
||||
|
||||
if (_topic.update(&manual_control_setpoint)) {
|
||||
_data[0] = manual_control_setpoint.y; // roll
|
||||
_data[1] = manual_control_setpoint.x; // pitch
|
||||
_data[2] = manual_control_setpoint.z * 2.f - 1.f; // throttle
|
||||
_data[3] = manual_control_setpoint.r; // yaw
|
||||
_data[4] = manual_control_setpoint.flaps;
|
||||
_data[5] = manual_control_setpoint.aux1;
|
||||
_data[6] = manual_control_setpoint.aux2;
|
||||
_data[7] = manual_control_setpoint.aux3;
|
||||
_data[8] = manual_control_setpoint.aux4;
|
||||
_data[9] = manual_control_setpoint.aux5;
|
||||
_data[10] = manual_control_setpoint.aux6;
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionGimbal::update()
|
||||
{
|
||||
actuator_controls_s actuator_controls;
|
||||
|
||||
if (_topic.update(&actuator_controls)) {
|
||||
_data[0] = actuator_controls.control[0];
|
||||
_data[1] = actuator_controls.control[1];
|
||||
_data[2] = actuator_controls.control[2];
|
||||
}
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <mixer_module/output_functions.hpp>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/actuator_motors.h>
|
||||
#include <uORB/topics/actuator_servos.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/landing_gear.h>
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
|
||||
class FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
struct Context {
|
||||
px4::WorkItem &work_item;
|
||||
const float &thrust_factor;
|
||||
};
|
||||
|
||||
FunctionProviderBase() = default;
|
||||
virtual ~FunctionProviderBase() = default;
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
/**
|
||||
* Get the current output value for a given function
|
||||
* @return NAN (=disarmed) or value in range [-1, 1]
|
||||
*/
|
||||
virtual float value(OutputFunction func) = 0;
|
||||
|
||||
virtual float defaultFailsafeValue(OutputFunction func) const { return NAN; }
|
||||
virtual bool allowPrearmControl() const { return true; }
|
||||
|
||||
virtual uORB::SubscriptionCallbackWorkItem *subscriptionCallback() { return nullptr; }
|
||||
|
||||
virtual bool getLatestSampleTimestamp(hrt_abstime &t) const { return false; }
|
||||
|
||||
/**
|
||||
* Check whether the output (motor) is configured to be reversible
|
||||
*/
|
||||
virtual bool reversible(OutputFunction func) const { return false; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Constant_Min
|
||||
*/
|
||||
class FunctionConstantMin : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionConstantMin(); }
|
||||
|
||||
float value(OutputFunction func) override { return -1.f; }
|
||||
void update() override { }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return -1.f; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Constant_Max
|
||||
*/
|
||||
class FunctionConstantMax : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionConstantMax(); }
|
||||
|
||||
float value(OutputFunction func) override { return 1.f; }
|
||||
void update() override { }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 1.f; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Motor1 ... MotorMax
|
||||
*/
|
||||
class FunctionMotors : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static_assert(actuator_motors_s::NUM_CONTROLS == (int)OutputFunction::MotorMax - (int)OutputFunction::Motor1 + 1,
|
||||
"Unexpected num motors");
|
||||
|
||||
static_assert(actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1 == (int)OutputFunction::Motor1, "Unexpected motor idx");
|
||||
|
||||
FunctionMotors(const Context &context);
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionMotors(context); }
|
||||
|
||||
void update() override;
|
||||
float value(OutputFunction func) override { return _data.control[(int)func - (int)OutputFunction::Motor1]; }
|
||||
|
||||
bool allowPrearmControl() const override { return false; }
|
||||
|
||||
uORB::SubscriptionCallbackWorkItem *subscriptionCallback() override { return &_topic; }
|
||||
|
||||
bool getLatestSampleTimestamp(hrt_abstime &t) const override { t = _data.timestamp_sample; return t != 0; }
|
||||
|
||||
static inline void updateValues(uint32_t reversible, float thrust_factor, float *values, int num_values);
|
||||
|
||||
bool reversible(OutputFunction func) const override
|
||||
{ return _data.reversible_flags & (1u << ((int)func - (int)OutputFunction::Motor1)); }
|
||||
private:
|
||||
uORB::SubscriptionCallbackWorkItem _topic;
|
||||
actuator_motors_s _data{};
|
||||
const float &_thrust_factor;
|
||||
};
|
||||
|
||||
void FunctionMotors::updateValues(uint32_t reversible, float thrust_factor, float *values, int num_values)
|
||||
{
|
||||
if (thrust_factor > 0.f && thrust_factor <= 1.f) {
|
||||
// thrust factor
|
||||
// rel_thrust = factor * x^2 + (1-factor) * x,
|
||||
const float a = thrust_factor;
|
||||
const float b = (1.f - thrust_factor);
|
||||
|
||||
// don't recompute for all values (ax^2+bx+c=0)
|
||||
const float tmp1 = b / (2.f * a);
|
||||
const float tmp2 = b * b / (4.f * a * a);
|
||||
|
||||
for (int i = 0; i < num_values; ++i) {
|
||||
float control = values[i];
|
||||
|
||||
if (control > 0.f) {
|
||||
values[i] = -tmp1 + sqrtf(tmp2 + (control / a));
|
||||
|
||||
} else if (control < -0.f) {
|
||||
values[i] = tmp1 - sqrtf(tmp2 - (control / a));
|
||||
|
||||
} else {
|
||||
values[i] = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_values; ++i) {
|
||||
if ((reversible & (1u << i)) == 0) {
|
||||
if (values[i] < -FLT_EPSILON) {
|
||||
values[i] = NAN;
|
||||
|
||||
} else {
|
||||
// remap from [0, 1] to [-1, 1]
|
||||
values[i] = values[i] * 2.f - 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Functions: Servo1 ... ServoMax
|
||||
*/
|
||||
class FunctionServos : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static_assert(actuator_servos_s::NUM_CONTROLS == (int)OutputFunction::ServoMax - (int)OutputFunction::Servo1 + 1,
|
||||
"Unexpected num servos");
|
||||
|
||||
FunctionServos(const Context &context);
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionServos(context); }
|
||||
|
||||
void update() override { _topic.update(&_data); }
|
||||
float value(OutputFunction func) override { return _data.control[(int)func - (int)OutputFunction::Servo1]; }
|
||||
|
||||
uORB::SubscriptionCallbackWorkItem *subscriptionCallback() override { return &_topic; }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 0.f; }
|
||||
private:
|
||||
uORB::SubscriptionCallbackWorkItem _topic;
|
||||
actuator_servos_s _data{};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Functions: Offboard_Actuator_Set1 ... Offboard_Actuator_Set6
|
||||
*/
|
||||
class FunctionActuatorSet : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionActuatorSet();
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionActuatorSet(); }
|
||||
|
||||
void update() override;
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::Offboard_Actuator_Set1]; }
|
||||
|
||||
private:
|
||||
static constexpr int max_num_actuators = 6;
|
||||
|
||||
uORB::Subscription _topic{ORB_ID(vehicle_command)};
|
||||
float _data[max_num_actuators];
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Landing_Gear
|
||||
*/
|
||||
class FunctionLandingGear : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionLandingGear() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionLandingGear(); }
|
||||
|
||||
void update() override;
|
||||
float value(OutputFunction func) override { return _data; }
|
||||
|
||||
private:
|
||||
uORB::Subscription _topic{ORB_ID(landing_gear)};
|
||||
float _data{-1.f};
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Parachute
|
||||
*/
|
||||
class FunctionParachute : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionParachute() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionParachute(); }
|
||||
|
||||
void update() override {}
|
||||
float value(OutputFunction func) override { return -1.f; }
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 1.f; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: RC_Roll .. RCAUX_Max
|
||||
*/
|
||||
class FunctionManualRC : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionManualRC();
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionManualRC(); }
|
||||
|
||||
void update() override;
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::RC_Roll]; }
|
||||
|
||||
private:
|
||||
static constexpr int num_data_points = 11;
|
||||
|
||||
static_assert(num_data_points == (int)OutputFunction::RC_AUXMax - (int)OutputFunction::RC_Roll + 1,
|
||||
"number of functions mismatch");
|
||||
|
||||
uORB::Subscription _topic{ORB_ID(manual_control_setpoint)};
|
||||
float _data[num_data_points];
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions: Gimbal_Roll .. Gimbal_Yaw
|
||||
*/
|
||||
class FunctionGimbal : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionGimbal() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionGimbal(); }
|
||||
|
||||
void update() override;
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::Gimbal_Roll]; }
|
||||
|
||||
private:
|
||||
uORB::Subscription _topic{ORB_ID(actuator_controls_2)};
|
||||
float _data[3] { NAN, NAN, NAN };
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
|
||||
/**
|
||||
* Functions: Offboard_Actuator_Set1 ... Offboard_Actuator_Set6
|
||||
*/
|
||||
class FunctionActuatorSet : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionActuatorSet()
|
||||
{
|
||||
for (int i = 0; i < max_num_actuators; ++i) {
|
||||
_data[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionActuatorSet(); }
|
||||
|
||||
void update() override
|
||||
{
|
||||
vehicle_command_s vehicle_command;
|
||||
|
||||
while (_topic.update(&vehicle_command)) {
|
||||
if (vehicle_command.command == vehicle_command_s::VEHICLE_CMD_DO_SET_ACTUATOR) {
|
||||
int index = (int)(vehicle_command.param7 + 0.5f);
|
||||
|
||||
if (index == 0) {
|
||||
_data[0] = vehicle_command.param1;
|
||||
_data[1] = vehicle_command.param2;
|
||||
_data[2] = vehicle_command.param3;
|
||||
_data[3] = vehicle_command.param4;
|
||||
_data[4] = vehicle_command.param5;
|
||||
_data[5] = vehicle_command.param6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::Offboard_Actuator_Set1]; }
|
||||
|
||||
private:
|
||||
static constexpr int max_num_actuators = 6;
|
||||
|
||||
uORB::Subscription _topic{ORB_ID(vehicle_command)};
|
||||
float _data[max_num_actuators] {};
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
/**
|
||||
* Functions: Constant_Max
|
||||
*/
|
||||
class FunctionConstantMax : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionConstantMax(); }
|
||||
|
||||
float value(OutputFunction func) override { return 1.f; }
|
||||
void update() override { }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 1.f; }
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
/**
|
||||
* Functions: Constant_Min
|
||||
*/
|
||||
class FunctionConstantMin : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionConstantMin(); }
|
||||
|
||||
float value(OutputFunction func) override { return -1.f; }
|
||||
void update() override { }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return -1.f; }
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
|
||||
/**
|
||||
* Functions: Gimbal_Roll .. Gimbal_Yaw
|
||||
*/
|
||||
class FunctionGimbal : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionGimbal() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionGimbal(); }
|
||||
|
||||
void update() override
|
||||
{
|
||||
actuator_controls_s actuator_controls;
|
||||
|
||||
if (_topic.update(&actuator_controls)) {
|
||||
_data[0] = actuator_controls.control[0];
|
||||
_data[1] = actuator_controls.control[1];
|
||||
_data[2] = actuator_controls.control[2];
|
||||
}
|
||||
}
|
||||
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::Gimbal_Roll]; }
|
||||
|
||||
private:
|
||||
uORB::Subscription _topic{ORB_ID(actuator_controls_2)};
|
||||
float _data[3] { NAN, NAN, NAN };
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/landing_gear.h>
|
||||
|
||||
/**
|
||||
* Functions: Landing_Gear
|
||||
*/
|
||||
class FunctionLandingGear : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionLandingGear() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionLandingGear(); }
|
||||
|
||||
void update() override
|
||||
{
|
||||
landing_gear_s landing_gear;
|
||||
|
||||
if (_topic.update(&landing_gear)) {
|
||||
if (landing_gear.landing_gear == landing_gear_s::GEAR_DOWN) {
|
||||
_data = -1.f;
|
||||
|
||||
} else if (landing_gear.landing_gear == landing_gear_s::GEAR_UP) {
|
||||
_data = 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float value(OutputFunction func) override { return _data; }
|
||||
|
||||
private:
|
||||
uORB::Subscription _topic{ORB_ID(landing_gear)};
|
||||
float _data{-1.f};
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
|
||||
/**
|
||||
* Functions: RC_Roll .. RCAUX_Max
|
||||
*/
|
||||
class FunctionManualRC : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionManualRC()
|
||||
{
|
||||
for (int i = 0; i < num_data_points; ++i) {
|
||||
_data[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionManualRC(); }
|
||||
|
||||
void update() override
|
||||
{
|
||||
manual_control_setpoint_s manual_control_setpoint;
|
||||
|
||||
if (_topic.update(&manual_control_setpoint)) {
|
||||
_data[0] = manual_control_setpoint.y; // roll
|
||||
_data[1] = manual_control_setpoint.x; // pitch
|
||||
_data[2] = manual_control_setpoint.z * 2.f - 1.f; // throttle
|
||||
_data[3] = manual_control_setpoint.r; // yaw
|
||||
_data[4] = manual_control_setpoint.flaps;
|
||||
_data[5] = manual_control_setpoint.aux1;
|
||||
_data[6] = manual_control_setpoint.aux2;
|
||||
_data[7] = manual_control_setpoint.aux3;
|
||||
_data[8] = manual_control_setpoint.aux4;
|
||||
_data[9] = manual_control_setpoint.aux5;
|
||||
_data[10] = manual_control_setpoint.aux6;
|
||||
}
|
||||
}
|
||||
|
||||
float value(OutputFunction func) override { return _data[(int)func - (int)OutputFunction::RC_Roll]; }
|
||||
|
||||
private:
|
||||
static constexpr int num_data_points = 11;
|
||||
|
||||
static_assert(num_data_points == (int)OutputFunction::RC_AUXMax - (int)OutputFunction::RC_Roll + 1,
|
||||
"number of functions mismatch");
|
||||
|
||||
uORB::Subscription _topic{ORB_ID(manual_control_setpoint)};
|
||||
float _data[num_data_points] {};
|
||||
};
|
||||
@@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/actuator_servos.h>
|
||||
|
||||
/**
|
||||
* Functions: Motor1 ... MotorMax
|
||||
*/
|
||||
class FunctionMotors : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static_assert(actuator_motors_s::NUM_CONTROLS == (int)OutputFunction::MotorMax - (int)OutputFunction::Motor1 + 1,
|
||||
"Unexpected num motors");
|
||||
|
||||
static_assert(actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1 == (int)OutputFunction::Motor1, "Unexpected motor idx");
|
||||
|
||||
FunctionMotors(const Context &context) :
|
||||
_topic(&context.work_item, ORB_ID(actuator_motors)),
|
||||
_thrust_factor(context.thrust_factor)
|
||||
{
|
||||
for (int i = 0; i < actuator_motors_s::NUM_CONTROLS; ++i) {
|
||||
_data.control[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionMotors(context); }
|
||||
|
||||
void update() override
|
||||
{
|
||||
if (_topic.update(&_data)) {
|
||||
updateValues(_data.reversible_flags, _thrust_factor, _data.control, actuator_motors_s::NUM_CONTROLS);
|
||||
}
|
||||
}
|
||||
|
||||
float value(OutputFunction func) override { return _data.control[(int)func - (int)OutputFunction::Motor1]; }
|
||||
|
||||
bool allowPrearmControl() const override { return false; }
|
||||
|
||||
uORB::SubscriptionCallbackWorkItem *subscriptionCallback() override { return &_topic; }
|
||||
|
||||
bool getLatestSampleTimestamp(hrt_abstime &t) const override { t = _data.timestamp_sample; return t != 0; }
|
||||
|
||||
static inline void updateValues(uint32_t reversible, float thrust_factor, float *values, int num_values)
|
||||
{
|
||||
if (thrust_factor > 0.f && thrust_factor <= 1.f) {
|
||||
// thrust factor
|
||||
// rel_thrust = factor * x^2 + (1-factor) * x,
|
||||
const float a = thrust_factor;
|
||||
const float b = (1.f - thrust_factor);
|
||||
|
||||
// don't recompute for all values (ax^2+bx+c=0)
|
||||
const float tmp1 = b / (2.f * a);
|
||||
const float tmp2 = b * b / (4.f * a * a);
|
||||
|
||||
for (int i = 0; i < num_values; ++i) {
|
||||
float control = values[i];
|
||||
|
||||
if (control > 0.f) {
|
||||
values[i] = -tmp1 + sqrtf(tmp2 + (control / a));
|
||||
|
||||
} else if (control < -0.f) {
|
||||
values[i] = tmp1 - sqrtf(tmp2 - (control / a));
|
||||
|
||||
} else {
|
||||
values[i] = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_values; ++i) {
|
||||
if ((reversible & (1u << i)) == 0) {
|
||||
if (values[i] < -FLT_EPSILON) {
|
||||
values[i] = NAN;
|
||||
|
||||
} else {
|
||||
// remap from [0, 1] to [-1, 1]
|
||||
values[i] = values[i] * 2.f - 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool reversible(OutputFunction func) const override { return _data.reversible_flags & (1u << ((int)func - (int)OutputFunction::Motor1)); }
|
||||
|
||||
private:
|
||||
uORB::SubscriptionCallbackWorkItem _topic;
|
||||
actuator_motors_s _data{};
|
||||
const float &_thrust_factor;
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
/**
|
||||
* Functions: Parachute
|
||||
*/
|
||||
class FunctionParachute : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
FunctionParachute() = default;
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionParachute(); }
|
||||
|
||||
void update() override {}
|
||||
float value(OutputFunction func) override { return -1.f; }
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 1.f; }
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <mixer_module/output_functions.hpp>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
|
||||
class FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
struct Context {
|
||||
px4::WorkItem &work_item;
|
||||
const float &thrust_factor;
|
||||
};
|
||||
|
||||
FunctionProviderBase() = default;
|
||||
virtual ~FunctionProviderBase() = default;
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
/**
|
||||
* Get the current output value for a given function
|
||||
* @return NAN (=disarmed) or value in range [-1, 1]
|
||||
*/
|
||||
virtual float value(OutputFunction func) = 0;
|
||||
|
||||
virtual float defaultFailsafeValue(OutputFunction func) const { return NAN; }
|
||||
virtual bool allowPrearmControl() const { return true; }
|
||||
|
||||
virtual uORB::SubscriptionCallbackWorkItem *subscriptionCallback() { return nullptr; }
|
||||
|
||||
virtual bool getLatestSampleTimestamp(hrt_abstime &t) const { return false; }
|
||||
|
||||
/**
|
||||
* Check whether the output (motor) is configured to be reversible
|
||||
*/
|
||||
virtual bool reversible(OutputFunction func) const { return false; }
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionProviderBase.hpp"
|
||||
|
||||
#include <uORB/topics/actuator_servos.h>
|
||||
|
||||
/**
|
||||
* Functions: Servo1 ... ServoMax
|
||||
*/
|
||||
class FunctionServos : public FunctionProviderBase
|
||||
{
|
||||
public:
|
||||
static_assert(actuator_servos_s::NUM_CONTROLS == (int)OutputFunction::ServoMax - (int)OutputFunction::Servo1 + 1,
|
||||
"Unexpected num servos");
|
||||
|
||||
FunctionServos(const Context &context) :
|
||||
_topic(&context.work_item, ORB_ID(actuator_servos))
|
||||
{
|
||||
for (int i = 0; i < actuator_servos_s::NUM_CONTROLS; ++i) {
|
||||
_data.control[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
static FunctionProviderBase *allocate(const Context &context) { return new FunctionServos(context); }
|
||||
|
||||
void update() override { _topic.update(&_data); }
|
||||
float value(OutputFunction func) override { return _data.control[(int)func - (int)OutputFunction::Servo1]; }
|
||||
|
||||
uORB::SubscriptionCallbackWorkItem *subscriptionCallback() override { return &_topic; }
|
||||
|
||||
float defaultFailsafeValue(OutputFunction func) const override { return 0.f; }
|
||||
|
||||
private:
|
||||
uORB::SubscriptionCallbackWorkItem _topic;
|
||||
actuator_servos_s _data{};
|
||||
};
|
||||
@@ -34,7 +34,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "actuator_test.hpp"
|
||||
#include "functions.hpp"
|
||||
|
||||
#include "functions/FunctionActuatorSet.hpp"
|
||||
#include "functions/FunctionConstantMax.hpp"
|
||||
#include "functions/FunctionConstantMin.hpp"
|
||||
#include "functions/FunctionGimbal.hpp"
|
||||
#include "functions/FunctionLandingGear.hpp"
|
||||
#include "functions/FunctionManualRC.hpp"
|
||||
#include "functions/FunctionMotors.hpp"
|
||||
#include "functions/FunctionParachute.hpp"
|
||||
#include "functions/FunctionServos.hpp"
|
||||
|
||||
#include <board_config.h>
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
|
||||
@@ -1048,7 +1048,7 @@ int parameter_flashfs_init(sector_descriptor_t *fconfig, uint8_t *buffer, uint16
|
||||
|
||||
flash_entry_header_t *pf = find_entry(parameters_token);
|
||||
|
||||
/* No paramaters */
|
||||
/* No parameters */
|
||||
|
||||
if (pf == NULL) {
|
||||
size_t total_size = size + sizeof(flash_entry_header_t);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
############################################################################
|
||||
|
||||
#
|
||||
# PX4 paramaters processor (main executable file)
|
||||
# PX4 parameters processor (main executable file)
|
||||
#
|
||||
# This tool scans the PX4 source code for declarations of tunable parameters
|
||||
# and outputs the list in various formats.
|
||||
|
||||
@@ -146,7 +146,7 @@ PARAM_DEFINE_INT32(SYS_CAL_BARO, 0);
|
||||
* Required temperature rise during thermal calibration
|
||||
*
|
||||
* A temperature increase greater than this value is required during calibration.
|
||||
* Calibration will complete for each sensor when the temperature increase above the starting temeprature exceeds the value set by SYS_CAL_TDEL.
|
||||
* Calibration will complete for each sensor when the temperature increase above the starting temperature exceeds the value set by SYS_CAL_TDEL.
|
||||
* If the temperature rise is insufficient, the calibration will continue indefinitely and the board will need to be repowered to exit.
|
||||
*
|
||||
* @unit celcius
|
||||
@@ -223,7 +223,7 @@ PARAM_DEFINE_INT32(SYS_HAS_BARO, 1);
|
||||
*
|
||||
* If set to the number of distance sensors, the preflight check will check
|
||||
* for their presence and valid data publication. Disable with 0 if no distance
|
||||
* sensor present or to disbale the preflight check.
|
||||
* sensor present or to disable the preflight check.
|
||||
*
|
||||
* @reboot_required true
|
||||
*
|
||||
|
||||
@@ -83,8 +83,8 @@
|
||||
*/
|
||||
|
||||
|
||||
// ordinal name tune interruptable* hint
|
||||
// * Repeated tunes should always be defined as interruptable, if not an explict 'tone_control stop' is needed
|
||||
// ordinal name tune interruptible* hint
|
||||
// * Repeated tunes should always be defined as interruptible, if not an explicit 'tone_control stop' is needed
|
||||
PX4_DEFINE_TUNE(0, CUSTOM, "", true /* empty to align with the index */)
|
||||
PX4_DEFINE_TUNE(1, STARTUP, "MFT240L8 O4aO5dc O4aO5dc O4aO5dc L16dcdcdcdc", true /* startup tune */)
|
||||
PX4_DEFINE_TUNE(2, ERROR_TUNE, "MBT200a8a8a8PaaaP", true /* ERROR tone */)
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* or the tune being already played is a repeated tune.
|
||||
* @param tune_control struct containig the uORB message
|
||||
* @return return ControlResult::InvalidTune if the default tune does not exist,
|
||||
* ControlResult::WouldInterrupt if tune was already playing and not interruptable,
|
||||
* ControlResult::WouldInterrupt if tune was already playing and not interruptible,
|
||||
* ControlResult::AlreadyPlaying if same tune was already playing,
|
||||
* ControlResult::Success if new tune was set.
|
||||
*/
|
||||
|
||||
@@ -36,3 +36,14 @@ add_library(wind_estimator
|
||||
WindEstimator.hpp
|
||||
)
|
||||
add_dependencies(wind_estimator prebuild_targets)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
add_custom_target(wind_estimator_generate_airspeed_fusion
|
||||
COMMAND ${PYTHON_EXECUTABLE} derivation.py
|
||||
#DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/python/derivation.py
|
||||
#BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/python/generated/fuse_airspeed.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python
|
||||
COMMENT "Generating fuse_airspeed"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
@@ -141,37 +141,11 @@ WindEstimator::fuse_airspeed(uint64_t time_now, const float true_airspeed, const
|
||||
|
||||
_time_last_airspeed_fuse = time_now;
|
||||
|
||||
// assign helper variables
|
||||
const float v_n = velI(0);
|
||||
const float v_e = velI(1);
|
||||
const float v_d = velI(2);
|
||||
|
||||
// calculate airspeed from ground speed and wind states (without scale)
|
||||
const float airspeed_predicted_raw = sqrtf((v_n - _state(INDEX_W_N)) * (v_n - _state(INDEX_W_N)) +
|
||||
(v_e - _state(INDEX_W_E)) * (v_e - _state(INDEX_W_E)) + v_d * v_d);
|
||||
|
||||
// compute state observation matrix H
|
||||
const float HH0 = airspeed_predicted_raw;
|
||||
const float HH1 = _state(INDEX_TAS_SCALE) / math::max(HH0, 0.1f);
|
||||
|
||||
matrix::Matrix<float, 1, 3> H_tas;
|
||||
H_tas(0, 0) = HH1 * (-v_n + _state(INDEX_W_N));
|
||||
H_tas(0, 1) = HH1 * (-v_e + _state(INDEX_W_E));
|
||||
H_tas(0, 2) = HH0;
|
||||
matrix::Matrix<float, 3, 1> K;
|
||||
|
||||
// compute innovation covariance S
|
||||
const matrix::Matrix<float, 1, 1> S = H_tas * _P * H_tas.transpose() + _tas_var;
|
||||
|
||||
// compute Kalman gain
|
||||
matrix::Matrix<float, 3, 1> K = _P * H_tas.transpose();
|
||||
K /= S(0, 0);
|
||||
|
||||
// compute innovation
|
||||
const float airspeed_pred = _state(INDEX_TAS_SCALE) * airspeed_predicted_raw;
|
||||
_tas_innov = true_airspeed - airspeed_pred;
|
||||
|
||||
// innovation variance
|
||||
_tas_innov_var = S(0, 0);
|
||||
sym::FuseAirspeed(velI, _state, _P, true_airspeed, _tas_var, FLT_EPSILON,
|
||||
&H_tas, &K, &_tas_innov_var, &_tas_innov);
|
||||
|
||||
bool reinit_filter = false;
|
||||
bool meas_is_rejected = false;
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
#include "python/generated/fuse_airspeed.h"
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
class WindEstimator
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import os
|
||||
from symforce import symbolic as sm
|
||||
from symforce import geo
|
||||
from symforce import typing as T
|
||||
|
||||
def fuse_airspeed(
|
||||
v_local: geo.V3,
|
||||
state: geo.V3,
|
||||
P: geo.M33,
|
||||
airspeed: T.Scalar,
|
||||
R: T.Scalar,
|
||||
epsilon: T.Scalar
|
||||
) -> geo.V3:
|
||||
|
||||
vel_rel = geo.V3(v_local[0] - state[0], v_local[1] - state[1], v_local[2])
|
||||
airspeed_pred = vel_rel.norm(epsilon=epsilon) * state[2]
|
||||
|
||||
innov = airspeed - airspeed_pred
|
||||
|
||||
H = geo.V1(airspeed_pred).jacobian(state)
|
||||
innov_var = (H * P * H.transpose() + R)[0,0]
|
||||
|
||||
K = P * H.transpose() / sm.Max(innov_var, epsilon)
|
||||
|
||||
return (geo.V3(H), K, innov_var, innov)
|
||||
|
||||
from symforce.codegen import Codegen, CppConfig
|
||||
|
||||
codegen = Codegen.function(
|
||||
fuse_airspeed,
|
||||
output_names=["H", "K", "innov_var", "innov"],
|
||||
config=CppConfig())
|
||||
metadata = codegen.generate_function(
|
||||
output_dir="generated",
|
||||
skip_directory_nesting=True)
|
||||
|
||||
print("Files generated in {}:\n".format(metadata.output_dir))
|
||||
for f in metadata.generated_files:
|
||||
print(" |- {}".format(os.path.relpath(f, metadata.output_dir)))
|
||||
|
||||
# Replace cstdlib and Eigen functions by PX4 equivalents
|
||||
import fileinput
|
||||
|
||||
with fileinput.FileInput(os.path.abspath(metadata.generated_files[0]), inplace=True, backup='.bak') as file:
|
||||
for line in file:
|
||||
line = line.replace("std::max", "math::max")
|
||||
line = line.replace("Eigen", "matrix")
|
||||
line = line.replace("matrix/Dense", "matrix/math.hpp")
|
||||
print(line, end='')
|
||||
@@ -0,0 +1 @@
|
||||
*.bak
|
||||
@@ -0,0 +1,90 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// This file was autogenerated by symforce from template:
|
||||
// backends/cpp/templates/function/FUNCTION.h.jinja
|
||||
// Do NOT modify by hand.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
namespace sym {
|
||||
|
||||
/**
|
||||
* This function was autogenerated from a symbolic function. Do not modify by hand.
|
||||
*
|
||||
* Symbolic function: fuse_airspeed
|
||||
*
|
||||
* Args:
|
||||
* v_local: Matrix31
|
||||
* state: Matrix31
|
||||
* P: Matrix33
|
||||
* airspeed: Scalar
|
||||
* R: Scalar
|
||||
* epsilon: Scalar
|
||||
*
|
||||
* Outputs:
|
||||
* H: Matrix13
|
||||
* K: Matrix31
|
||||
* innov_var: Scalar
|
||||
* innov: Scalar
|
||||
*/
|
||||
template <typename Scalar>
|
||||
void FuseAirspeed(const matrix::Matrix<Scalar, 3, 1>& v_local,
|
||||
const matrix::Matrix<Scalar, 3, 1>& state, const matrix::Matrix<Scalar, 3, 3>& P,
|
||||
const Scalar airspeed, const Scalar R, const Scalar epsilon,
|
||||
matrix::Matrix<Scalar, 1, 3>* const H = nullptr,
|
||||
matrix::Matrix<Scalar, 3, 1>* const K = nullptr, Scalar* const innov_var = nullptr,
|
||||
Scalar* const innov = nullptr) {
|
||||
// Total ops: 56
|
||||
|
||||
// Input arrays
|
||||
|
||||
// Intermediate terms (11)
|
||||
const Scalar _tmp0 = -state(0, 0) + v_local(0, 0);
|
||||
const Scalar _tmp1 = -state(1, 0) + v_local(1, 0);
|
||||
const Scalar _tmp2 = std::sqrt(Scalar(std::pow(_tmp0, Scalar(2)) + std::pow(_tmp1, Scalar(2)) +
|
||||
epsilon + std::pow(v_local(2, 0), Scalar(2))));
|
||||
const Scalar _tmp3 = state(2, 0) / _tmp2;
|
||||
const Scalar _tmp4 = _tmp0 * _tmp3;
|
||||
const Scalar _tmp5 = _tmp1 * _tmp3;
|
||||
const Scalar _tmp6 = -P(0, 0) * _tmp4;
|
||||
const Scalar _tmp7 = -P(1, 1) * _tmp5;
|
||||
const Scalar _tmp8 = P(2, 2) * _tmp2;
|
||||
const Scalar _tmp9 = R + _tmp2 * (-P(0, 2) * _tmp4 - P(1, 2) * _tmp5 + _tmp8) -
|
||||
_tmp4 * (-P(1, 0) * _tmp5 + P(2, 0) * _tmp2 + _tmp6) -
|
||||
_tmp5 * (-P(0, 1) * _tmp4 + P(2, 1) * _tmp2 + _tmp7);
|
||||
const Scalar _tmp10 = Scalar(1.0) / (math::max<Scalar>(_tmp9, epsilon));
|
||||
|
||||
// Output terms (4)
|
||||
if (H != nullptr) {
|
||||
matrix::Matrix<Scalar, 1, 3>& _H = (*H);
|
||||
|
||||
_H(0, 0) = -_tmp4;
|
||||
_H(0, 1) = -_tmp5;
|
||||
_H(0, 2) = _tmp2;
|
||||
}
|
||||
|
||||
if (K != nullptr) {
|
||||
matrix::Matrix<Scalar, 3, 1>& _K = (*K);
|
||||
|
||||
_K(0, 0) = _tmp10 * (-P(0, 1) * _tmp5 + P(0, 2) * _tmp2 + _tmp6);
|
||||
_K(1, 0) = _tmp10 * (-P(1, 0) * _tmp4 + P(1, 2) * _tmp2 + _tmp7);
|
||||
_K(2, 0) = _tmp10 * (-P(2, 0) * _tmp4 - P(2, 1) * _tmp5 + _tmp8);
|
||||
}
|
||||
|
||||
if (innov_var != nullptr) {
|
||||
Scalar& _innov_var = (*innov_var);
|
||||
|
||||
_innov_var = _tmp9;
|
||||
}
|
||||
|
||||
if (innov != nullptr) {
|
||||
Scalar& _innov = (*innov);
|
||||
|
||||
_innov = -_tmp2 * state(2, 0) + airspeed;
|
||||
}
|
||||
} // NOLINT(readability/fn_size)
|
||||
|
||||
// NOLINTNEXTLINE(readability/fn_size)
|
||||
} // namespace sym
|
||||
@@ -0,0 +1,36 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2022 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
px4_add_unit_gtest(SRC test_airspeed_fusion.cpp)
|
||||
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* Run this test only using make tests TESTFILTER=unit-test_airspeed_fusion
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <matrix/math.hpp>
|
||||
#include <mathlib/math/Functions.hpp>
|
||||
#include "../python/generated/fuse_airspeed.h"
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
TEST(TestAirspeedFusion, SingularityHandling)
|
||||
{
|
||||
// GIVEN: all inputs set to zero (singularity point)
|
||||
const float true_airspeed = 0.f;
|
||||
const Vector3f vel_i{0.f, 0.f, 0.f};
|
||||
const Vector3f state{0.f, 0.f, 0.f};
|
||||
const Matrix<float, 3, 3> P;
|
||||
const float tas_var = 0.f;
|
||||
|
||||
matrix::Matrix<float, 1, 3> H;
|
||||
matrix::Matrix<float, 3, 1> K;
|
||||
float innov_var;
|
||||
float innov;
|
||||
|
||||
// WHEN: no singularity handling is done
|
||||
float epsilon = 0.f;
|
||||
sym::FuseAirspeed(vel_i, state, P, true_airspeed, tas_var, epsilon,
|
||||
&H, &K, &innov_var, &innov);
|
||||
|
||||
// THEN: some of the returned values are not finite
|
||||
EXPECT_TRUE(std::isnan(H(0, 0))) << H(0, 0);
|
||||
EXPECT_TRUE(std::isnan(H(0, 1))) << H(0, 1);
|
||||
EXPECT_FLOAT_EQ(H(0, 2), 0.f) << H(0, 2);
|
||||
EXPECT_TRUE(std::isnan(K(0, 0))) << K(0, 0);
|
||||
EXPECT_TRUE(std::isnan(K(1, 0))) << K(1, 0);
|
||||
EXPECT_TRUE(std::isnan(K(2, 0))) << K(2, 0);
|
||||
EXPECT_TRUE(std::isnan(innov_var));
|
||||
EXPECT_FLOAT_EQ(innov, 0.f);
|
||||
|
||||
// BUT WHEN: singularity is avoided by addind a small constant
|
||||
epsilon = FLT_EPSILON;
|
||||
sym::FuseAirspeed(vel_i, state, P, true_airspeed, tas_var, epsilon,
|
||||
&H, &K, &innov_var, &innov);
|
||||
|
||||
// THEN: the returned values are finite and the Kalman gain is null
|
||||
EXPECT_FLOAT_EQ(H(0, 0), 0.f) << H(0, 0);
|
||||
EXPECT_FLOAT_EQ(H(0, 1), 0.f) << H(0, 1);
|
||||
EXPECT_FLOAT_EQ(H(0, 2), std::sqrt(FLT_EPSILON)) << H(0, 2);
|
||||
EXPECT_TRUE(isEqual(K, Vector3f()));
|
||||
EXPECT_FLOAT_EQ(innov_var, tas_var);
|
||||
EXPECT_FLOAT_EQ(innov, 0.f);
|
||||
}
|
||||
@@ -131,10 +131,7 @@ PARAM_DEFINE_INT32(COM_HLDL_REG_T, 0);
|
||||
/**
|
||||
* RC loss time threshold
|
||||
*
|
||||
* If the RC signal does not update for this number of seconds the RC connection is considered lost
|
||||
* (during this interval data from the last RC update is still used).
|
||||
* If the connection is lost, PX4 will enter Hold mode and wait for COM_RCL_ACT_T seconds
|
||||
* to recover the connection before triggering the failsafe action (COM_RCL_ACT_T).
|
||||
* After this amount of seconds without RC connection it's considered lost and not used anymore
|
||||
*
|
||||
* @group Commander
|
||||
* @unit s
|
||||
@@ -146,13 +143,11 @@ PARAM_DEFINE_INT32(COM_HLDL_REG_T, 0);
|
||||
PARAM_DEFINE_FLOAT(COM_RC_LOSS_T, 0.5f);
|
||||
|
||||
/**
|
||||
* Delay between RC loss and configured action
|
||||
* Delay between RC loss and configured reaction
|
||||
*
|
||||
* If the RC signal does not update for COM_RC_LOSS_T seconds the RC connection is considered lost
|
||||
* (during this interval data from the last RC update is still used).
|
||||
* If the connection is lost, PX4 will enter Hold mode and wait for COM_RCL_ACT_T seconds
|
||||
* to recover the connection before triggering the failsafe action (NAV_RCL_ACT).
|
||||
* If the signal is regained PX4 will return to the previous mode.
|
||||
* RC signal not updated -> still use data for COM_RC_LOSS_T seconds
|
||||
* Consider RC signal lost -> wait COM_RCL_ACT_T seconds in Hold mode to regain signal
|
||||
* React with failsafe action NAV_RCL_ACT
|
||||
*
|
||||
* A zero value disables the delay.
|
||||
*
|
||||
@@ -823,12 +818,11 @@ PARAM_DEFINE_INT32(COM_TAKEOFF_ACT, 0);
|
||||
PARAM_DEFINE_INT32(NAV_DLL_ACT, 0);
|
||||
|
||||
/**
|
||||
* Set RC loss failsafe action (mode).
|
||||
* Set RC loss failsafe mode
|
||||
*
|
||||
* The RC loss failsafe will only be entered if the RC connection is not recovered before first the
|
||||
* RC signal loss theshold timeout (COM_RC_LOSS_T) and then the RC connection lost timeout (NAV_RCL_ACT) have triggered.
|
||||
* The action will not be triggered if RC input checks have been disabled (COM_RC_IN_MODE)
|
||||
* or if RC loss exceptions are disabled for the current mode (COM_RCL_EXCEPT).
|
||||
* The RC loss failsafe will only be entered after a timeout,
|
||||
* set by COM_RC_LOSS_T in seconds. If RC input checks have been disabled
|
||||
* by setting the COM_RC_IN_MODE param it will not be triggered.
|
||||
*
|
||||
* @value 1 Hold mode
|
||||
* @value 2 Return mode
|
||||
@@ -1069,7 +1063,7 @@ PARAM_DEFINE_FLOAT(COM_WIND_WARN, -1.f);
|
||||
* the time since takeoff is above this value. It is not possible to resume the
|
||||
* mission or switch to any mode other than RTL or Land.
|
||||
*
|
||||
* Set a nagative value to disable.
|
||||
* Set a negative value to disable.
|
||||
*
|
||||
*
|
||||
* @unit s
|
||||
|
||||
@@ -479,7 +479,7 @@ union filter_control_status_u {
|
||||
uint32_t gps : 1; ///< 2 - true if GPS measurement fusion is intended
|
||||
uint32_t opt_flow : 1; ///< 3 - true if optical flow measurements fusion is intended
|
||||
uint32_t mag_hdg : 1; ///< 4 - true if a simple magnetic yaw heading fusion is intended
|
||||
uint32_t mag_3D : 1; ///< 5 - true if 3-axis magnetometer measurement fusion is inteded
|
||||
uint32_t mag_3D : 1; ///< 5 - true if 3-axis magnetometer measurement fusion is intended
|
||||
uint32_t mag_dec : 1; ///< 6 - true if synthetic magnetic declination measurements fusion is intended
|
||||
uint32_t in_air : 1; ///< 7 - true when the vehicle is airborne
|
||||
uint32_t wind : 1; ///< 8 - true when wind velocity is being estimated
|
||||
@@ -571,7 +571,7 @@ union warning_event_status_u {
|
||||
bool height_sensor_timeout : 1; ///< 4 - true when the height sensor has not been used to correct the state estimates for a significant time period
|
||||
bool stopping_navigation : 1; ///< 5 - true when the filter has insufficient data to estimate velocity and position and is falling back to an attitude, height and height rate mode of operation
|
||||
bool invalid_accel_bias_cov_reset : 1; ///< 6 - true when the filter has detected bad acceerometer bias state estimates and has reset the corresponding covariance matrix elements
|
||||
bool bad_yaw_using_gps_course : 1; ///< 7 - true when the fiter has detected an invalid yaw esitmate and has reset the yaw angle to the GPS ground course
|
||||
bool bad_yaw_using_gps_course : 1; ///< 7 - true when the filter has detected an invalid yaw estimate and has reset the yaw angle to the GPS ground course
|
||||
bool stopping_mag_use : 1; ///< 8 - true when the filter has detected bad magnetometer data and is stopping further use of the magnetomer data
|
||||
bool vision_data_stopped : 1; ///< 9 - true when the vision system data has stopped for a significant time period
|
||||
bool emergency_yaw_reset_mag_stopped : 1; ///< 10 - true when the filter has detected bad magnetometer data, has reset the yaw to anothter source of data and has stopped further use of the magnetomer data
|
||||
|
||||
@@ -1539,7 +1539,7 @@ void EKF2::UpdateAirspeedSample(ekf2_timestamps_s &ekf2_timestamps)
|
||||
|
||||
void EKF2::UpdateAuxVelSample(ekf2_timestamps_s &ekf2_timestamps)
|
||||
{
|
||||
// EKF auxillary velocity sample
|
||||
// EKF auxiliary velocity sample
|
||||
// - use the landing target pose estimate as another source of velocity data
|
||||
const unsigned last_generation = _landing_target_pose_sub.get_last_generation();
|
||||
landing_target_pose_s landing_target_pose;
|
||||
|
||||
@@ -358,7 +358,7 @@ private:
|
||||
(ParamExtFloat<px4::params::EKF2_EV_DELAY>)
|
||||
_param_ekf2_ev_delay, ///< off-board vision measurement delay relative to the IMU (mSec)
|
||||
(ParamExtFloat<px4::params::EKF2_AVEL_DELAY>)
|
||||
_param_ekf2_avel_delay, ///< auxillary velocity measurement delay relative to the IMU (mSec)
|
||||
_param_ekf2_avel_delay, ///< auxiliary velocity measurement delay relative to the IMU (mSec)
|
||||
|
||||
(ParamExtFloat<px4::params::EKF2_GYR_NOISE>)
|
||||
_param_ekf2_gyr_noise, ///< IMU angular rate noise used for covariance prediction (rad/sec)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user