• Stars
    star
    191
  • Rank 202,877 (Top 4 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

web application for flight log analysis & review

Flight Review

This is a web application for flight log analysis. It allows users to upload ULog flight logs, and analyze them through the browser.

It uses the bokeh library for plotting and the Tornado Web Server.

Flight Review is deployed at https://review.px4.io.

Plot View

3D View

3D View

Installation and Setup

Requirements

Ubuntu

sudo apt-get install sqlite3 fftw3 libfftw3-dev

Note: Under some Ubuntu and Debian environments you might have to install ATLAS

sudo apt-get install libatlas3-base

macOS

macOS already provides SQLite3. Use Homebrew to install fftw:

brew install fftw

Installation

# After git clone, enter the directory
git clone --recursive https://github.com/PX4/flight_review.git
cd flight_review/app
pip install -r requirements.txt
# Note: preferably use a virtualenv

# Note: if you get an error about "ModuleNotFoundError: No module named 'libevents_parse'" update submodules
git submodule update --init --recursive

Setup

Initialize the Database as following:

./app/setup_db.py

Note: setup_db.py can also be used to upgrade the database tables, for instance when new entries are added (it automatically detects that).

Settings

  • By default the app will load config_default.ini configuration file
  • You can override any setting from config_default.ini with a user config file config_user.ini (untracked)
  • Any setting on config_user.ini has priority over config_default.ini

Usage

For local usage, the server can be started directly with a log file name, without having to upload it first:

cd app
./serve.py -f <file.ulg>

To start the whole web application:

cd app
./serve.py --show

The plot_app directory contains a bokeh server application for plotting. It can be run stand-alone with bokeh serve --show plot_app (or with cd plot_app; bokeh serve --show main.py, to start without the html template).

The whole web application is run with the serve.py script. Run ./serve.py -h for further details.

Interactive Usage

The plotting can also be used interative using a Jupyter Notebook. It requires python knowledge, but provides full control over what and how to plot with immediate feedback.

  • Start the notebook
  • Locate and open the test notebook file testing_notebook.ipynb.
# Launch jupyter notebook
cd app
jupyter notebook testing_notebook.ipynb

Implementation

The web site is structured around a bokeh application in app/plot_app (app/plot_app/configured_plots.py contains all the configured plots). This application also handles the statistics page, as it contains bokeh plots as well. The other pages (upload, browse, ...) are implemented as tornado handlers in app/tornado_handlers/.

plot_app/helper.py additionally contains a list of log topics that the plot application can subscribe to. A topic must live in this list in order to be plotted.

Tornado uses a single-threaded event loop. This means all operations should be non-blocking (see also http://www.tornadoweb.org/en/stable/guide/async.html). (This is currently not the case for sending emails).

Reading ULog files is expensive and thus should be avoided if not really necessary. There are two mechanisms helping with that:

  • Loaded ULog files are kept in RAM using an LRU cache with configurable size (when using the helper method). This works from different requests and sessions and from all source contexts.
  • There's a LogsGenerated DB table, which contains extracted data from ULog for faster access.

Caching

In addition to in-memory caching there is also some on-disk caching: KML files are stored on disk. Also the parameters and airframes are cached and downloaded every 24 hours. It is safe to delete these files (but not the cache directory).

Notes about python imports

Bokeh uses dynamic code loading and the plot_app/main.py gets loaded on each session (page load) to isolate requests. This also means we cannot use relative imports. We have to use sys.path.append to include modules in plot_app from the root directory (Eg tornado_handlers.py). Then to make sure the same module is only loaded once, we use import xy instead of import plot_app.xy. It's useful to look at print('\n'.join(sys.modules.keys())) to check this.

Docker usage

This section explains how to work with docker.

Arguments

Edit the .env file according to your setup:

  • PORT - The number of port, what listen service in docker, default 5006
  • USE_PROXY - The set his, if you use reverse proxy (Nginx, ...)
  • DOMAIN - The address domain name for origin, default = *
  • CERT_PATH - The SSL certificate volume path
  • EMAIL - Email for challenging Let's Encrypt DNS

Paths

  • /opt/service/config_user.ini - Path for config
  • /opt/service/data - Folder where stored database
  • .env - Environment variables for nginx and app docker container

Build Docker Image

cd app
docker build -t px4flightreview -f Dockerfile .

Work with docker-compose

Run the following command to start docker container. Please modify the .env and add app/config_user.ini with respective stages.

Uncomment the BOKEH_ALLOW_WS_ORIGIN with your local IP Address when developing, this is for the bokeh application's websocket to work.

Development

docker-compose -f docker-compose.dev.yml up

Test Locally

Test locally with nginx:

docker-compose up

Remember to Change NGINX_CONF to use default_ssl.conf and add the EMAIL for production.

Production

htpasswd -c ./nginx/.htpasswd username
# here to create a .htpasswd for nginx basic authentication
chmod u+x init-letsencrypt.sh
./init-letsencrypt.sh

Contributing

Contributions are welcome! Just open a pull request with detailed description why the changes are needed, or open an issue for bugs, feature requests, etc...

More Repositories

1

PX4-Autopilot

PX4 Autopilot Software
C++
7,009
star
2

PX4-Avoidance

PX4 avoidance ROS node for obstacle detection and avoidance.
C++
618
star
3

PX4-ECL

Estimation & Control Library for Guidance, Navigation and Control Applications
C++
473
star
4

eigen

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
C++
418
star
5

PX4-SITL_gazebo-classic

Set of plugins, models and worlds to use with OSRF Gazebo Simulator in SITL and HITL.
C++
368
star
6

PX4-user_guide

PX4 User Guide
Jupyter Notebook
257
star
7

PX4-Bootloader

PX4 Bootloader for PX4FMU, PX4IO and PX4FLOW
C
236
star
8

PX4-Flow

Firmware for PX4FLOW board
C
232
star
9

sapog

Sapog - advanced multiplatform ESC firmware
C
203
star
10

PX4-Devguide

PX4 Devguide GitBook
TeX
193
star
11

PX4-Matrix

Lightweight, dependency free Matrix library (BSD)
C++
176
star
12

PX4-OpticalFlow

This repository contains different algorithms to calculate the optical flow. It can be used as input for a position estimator
C++
156
star
13

NuttX

Standard NuttX with current PX4 patches
C
138
star
14

pyulog

Python module & scripts for ULog files
Python
124
star
15

px4_ros_com

ROS2/ROS interface with PX4 through a Fast-RTPS bridge
C++
120
star
16

PX4-GPSDrivers

Platform independent GPS drivers
C++
84
star
17

DriverFramework

Operating system and flight stack agnostic driver framework for POSIX (Linux, NuttX, Mac OS, QNX, VxWorks).
C++
77
star
18

px4_msgs

ROS/ROS2 messages that match the uORB messages counterparts on the PX4 Firmware
CMake
69
star
19

homebrew-px4

PX4-related Homebrew formula for developers using OS X
Ruby
68
star
20

PX4-containers

Build scripts for containers running various PX4 setups, like SITL with ROS.
Makefile
64
star
21

HIL

Hardware in the loop tools for PX4 Firmware
Python
38
star
22

PX4NuttX

For Migration to new NuttX Repository layout
36
star
23

PX4-windows-toolchain

Repo containing all scripts to install and use the PX4 Toolchain for Windows.
Batchfile
31
star
24

snap_cam

This package provides tools to work with the Snapdragon Flight cameras as well as perform optical flow for use with the PX4 flight stack.
C++
27
star
25

NuttX-apps

Standard NuttX apps with current PX4 patches
C
26
star
26

PX4-gazebo-models

Model repo in app.gazebosim.org
Python
18
star
27

uvc_ros_driver

A ros node to stream images from a multi-camera UVC device
C++
18
star
28

px4ros

contains submodules for ROS SITL, used to define relations between projects/versions
17
star
29

Lepton

FLIR Lepton ROS node
C++
14
star
30

docs.px4.io

PX4 User Guide Content: See https://github.com/PX4/px4_user_guide
HTML
11
star
31

micrortps_agent

microRTPS agent side of the microRTPS bridge. Used to interface PX4 with the DDS world through FastRTPS/FastDDS.
C++
10
star
32

UAVCAN_Bootloaders

C
8
star
33

disparity_to_point_cloud

ROS Node which converts a disparity map in a point cloud
C++
8
star
34

electronWebGCS

JavaScript
7
star
35

ulog_cpp

C++ library for reading and writing ULog files
C++
7
star
36

dev.px4.io

PX4 Developer Guide Content: See https://github.com/PX4/Devguide
HTML
7
star
37

rpi_toolchain

Files for building PX4 POSIX on Raspberry Pi
Shell
5
star
38

mav_comm

This repository contains message and service definitions used for mavs. All future message definitions go in here, existing ones in other stacks should be moved here where possible.
C++
4
star
39

px4_sdk

Library to control PX4 from a companion computer using ROS 2
C++
4
star
40

PX4-Metadata-Translations

Translated metadata for https://github.com/PX4/PX4-Autopilot
Python
3
star
41

Board_ID

3
star
42

uavcan_board_ident

CMake
2
star
43

PX4-graphics

Downloadable media assets and branding guideline
2
star
44

Toolchains

PX4 build system toolchains
Shell
2
star
45

Firmware-Doxygen

PX4 Firmware Doxygen documentation
HTML
2
star
46

rddrone_uavcan

2
star
47

companion

Companion computer bringup and maintenance scripts
Shell
1
star
48

px4_msgs-release

Release repository of px4_msgs for ROS (1) distros
1
star
49

px4_msgs2-release

Release repository of px4_msgs for ROS 2 distros
1
star
50

NuttX-NxWidgets

C++
1
star
51

rfcs

Requests for Comment for PX4/Firmware
1
star