This README briefly describes how a UAV with a Pixhawk flight computer is setup at the Control of Networked Systems Group (CNS) at the University of Klagenfurt. This setup also provides the essential steps for the base setup of the CNS flight stack. The only settings which might need to be adapted for another vehicle (besides the TWINS flight platform) are the assignments of the Mavlink serial ports within the settings file described below.
-
This Repository provides all settings files and the extras.txt file, which will be copied to the SD card.
-
Minimal instructions on how to setup and modify a catkin workspace with CNS modified packages are provided by px4_firmware_catkin_ws_build.md.
-
A short manual on how the Optitrack-System at the Dronehall is configured is shown by optitrack.md
- Download QGroundControl from here
- Note: We are using version 3.5.6 because it still provides the "Widgets"
- Start QGroundControl, in the
Vehicle Setup, select theFirmwaretab - Now connect the Pixhawk via USB to the PC
- Select
PX4 Flight Stack Stable Releaseon the top right and press OK (see image below) - This will take a moment, and the Pixhawk will beep after the flashing is completed
Known issues: Ensure the USB provides enough power; some devices (in power saving mode) do not provide enough power during the flashing process, and the flashing process might stop before completion.
The extras.txt file allows to define the port on which the Mavlink data is streamed and the specification of the rates for specific messages (IMU, GPS, etc.).
- In the settings bar, choose Widgets -> On-board Files
- Navigate to (
fs/microsd/etc), selectetc, and press theUpload Filebutton (see image below) - Choose the attached file
./sd_cfg/extras.txt - Restart the PX4 (Tools -> Reboot Vehicle)
NOTE: If you can not remove the SD card from the Pixhawk and you have to make changes to the files (move, remove etc.), you can use the "Mavlink Console" which provides rudimentary shell commands (cd, ls, mv, rm).
Load the prepared PX4 configuration using QGroundControl. Choose the Parameters tab, then click the Tools button on the top right and select Load from file....
Locate the file within this folder ./parameter/2020_07_28_twins_one_internal_ekf2.params and load it.
Note: You might see warnings because some parameters were renamed or do not exist between different firmware versions.
After this, restart the PX4 (Tools -> Reboot Vehicle) and double-check the following parameters to ensure that the setup is correct. The loaded parameters will set up the EKF2 for the internal filter. However, you can choose between the EKF2 or the Local Pose Estimator (LPE) for the internal filter. In any case, verify the parameters for the individual estimator below. The parameters set the individual filter to use an external pose that is subscribed from the rostopic /mavros/vision_pose/pose.
Please reboot the vehicle after changing the SYS_MC_EST_GROUP parameter to enable the subsequent filter options. You can find the parameters by typing their names in the search bar while you are in the Parameters tab.
EKF2 Settings:
- Set
SYS_MC_EST_GROUPto EKF2 (value 2) - Restart the PX4 (Tools -> Reboot Vehicle)
- Set
EKF2_AID_MASKto 24 ([x] vision position fusion and [x] vision yaw fusion) - Set
EKF2_EVP_NOISEto 0.1m - Set
EKF_EV_DELAYto 0ms - Set
EKF2_HGT_MODEto Vision
LPE Setting:
The LPE position estimator is an extended Kalman filter for 3D position and velocity states.
- Set
SYS_MC_EST_GROUPto LPE position estimator (value 1) - Restart the PX4 (Tools -> Reboot Vehicle)
LPE_FUSION- enable vision position, disable baro fusion- Set
ATT_EXT_HDG_Mto 1 for vision - Set
LPE_VIS_XYandLPE_VIS_Z0.01 (force-save needed)
This is all that is needed to set up the vehicle.
(Skip this step if you are using the AMADEE catkin workspace or the AMADEE OS)
Prepare your catkin workspace with the following packages:
git clone https://github.com/aau-cns/ros_vrpn_client.git &&
git clone https://github.com/ethz-asl/vrpn_catkinand install the following packages:
# Install mavros
apt-get update && apt-get install -y \
ros-melodic-mavros \
ros-melodic-mavros-extras
# Download geographiclib
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh && \
chmod +x install_geographiclib_datasets.sh
# Install geographiclib
./install_geographiclib_datasets.shYou can change the velocity settings for the transition in 3D space. This applies to manual and waypoint flight modes. Especially the default value for the max. vertical descent velocity is too high for the normal use case.
| Parameter | Description | Value |
|---|---|---|
MPC_XY_VEL_MAX |
Maximum horizontal velocity | |
MPC_Z_VEL_MAX_UP |
Maximum vertical ascent velocity | |
MPC_Z_VEL_MAX_DN |
Maximum vertical descent velocity |
If the vehicle loses contact or does not receive waypoints within the defined timeout, it will switch into Return to Land mode (RTL). This is a safety feature. However, be sure to adapt the parameters below to reasonable values allowed in your environment. E.g., by default, the vehicle will rise to an altitude of RTL_RETURN_ALT 30 meters before landing. This is dangerous if you are located in an indoor environment that does not allow such heights. The parameters below are an example for an indoor setup.
| Parameter | Description | Value |
|---|---|---|
RTL_RETURN_ALT |
RTL altitude to fly back to home | |
RTL_DESCEND_ALT |
Altitude to wait at before landing | |
RTL_LAND_DELAY |
Time before switching from returning, to landing |
The off-board mode is used for e.g., waypoint following. To ensure uninterrupted communication between the PX4 and a companion board, the COM_OF_LOSS_T parameter needs to be increased. The default value of 1 second has shown to be too low; due to this, the PX4 rejects waypoints, especially in the initial phase. Setting COM_OF_LOSS_T=10s prevents this issue (see the image below).
| Parameter | Description | Value |
|---|---|---|
COM_OF_LOSS_T |
off-board mode timeout |
This software is made available to the public to use (source-available),
licensed under the terms of the BSD-2-Clause-License with no commercial use
allowed, the full terms of which are made available in the LICENSE file.
No license in patents is granted.




