GithubHelp home page GithubHelp logo

px4 / flight_review Goto Github PK

View Code? Open in Web Editor NEW
183.0 24.0 179.0 28.47 MB

web application for flight log analysis & review

Home Page: https://logs.px4.io/

License: BSD 3-Clause "New" or "Revised" License

Python 82.34% CSS 1.95% JavaScript 4.25% HTML 7.70% Jupyter Notebook 2.64% Shell 0.90% Dockerfile 0.23%
bokeh plotting flight-log-analysis interactive-plots px4 drone python web

flight_review's Introduction

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...

Feel free to run ./run_pylint.sh before PR to ensure CICD checks pass on your code.

flight_review's People

Contributors

alexklimaj avatar alhicks avatar amandastowers avatar anassinator avatar bbworld1 avatar bkueng avatar bresch avatar carlolsson avatar cclauss avatar dagar avatar duckythescientist avatar jinchengde avatar johannesbrand avatar junwoo091400 avatar kaklik avatar luvwinnie avatar m1kelyons avatar mcsauder avatar mhkabir avatar mooneyj avatar moreba1 avatar mrpollo avatar not-vibhu avatar parakhm95 avatar pietrodn avatar ricardom17 avatar ryguy101 avatar sfuhrer avatar slimonslimon avatar tsc21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flight_review's Issues

Stabilized Mode color error in for Google Map

The stabilized mode color for the google map is incorrectly shown as purple.

Here is the altitude graph which correctly shows stabilized mode with blue background:
Altitude

Here is the google map view of the log, which show stabilized mode incorrectly as purple:
Google Map

And here is the link to the log in question:
https://review.px4.io/plot_app?log=77a2d3d3-1834-40d0-bb0c-61b22aad9214

Here is another log with the same problem:
https://review.px4.io/plot_app?log=80daaa0a-6f12-467d-add2-27599c8fda38

Maps view broken

This is from the SITL system, completely unreadable:

screen shot 2016-12-13 at 09 31 31

Zooming in and panning even worse:

screen shot 2016-12-13 at 09 31 41

define your own functions

it would be beneficial to have the ability to define your own functions, such as subtracting mean of logs

Use S3 instead of local disk to store logs

Drive costs on AWS are somewhat expensive, we should move our storage to S3, there's lots of python bindings for S3 nowadays, I'll submit a PR as soon as I can, or if there's anyone interested in helping just let me know I can set you up with S3

Upload broken

Tried to upload a log today, there is some Problem, as it always returns HTTP 500 on logs.px4.io.

I don't know who to contact on this issue or if you also operate the px4.io infrastructure.

VTOL average speed

@bkueng i see you added average speed. For VTOL it would be great to have average speed separated for MC and FW mode. The sum of these doesn't say much but individually they do

download log file not parameters

Hello,
When I try to download parameters from a log, the .ulog file is downloaded not the paramters file.
This worked few days ago. Maybe since the KLM track download function ?

Thank for this very usefull flight log analysis.

Vivien

vehicle mode

Should flight review use vehicle_status.nav_sate instead of commander_state.main_state for the vehicle mode?

Plot vision topics

@bkueng Now that the firmware side is in (PX4/PX4-Autopilot#6074), we need plotting for vision topics.

There should be new plots :

  1. External position, velocity (vehicle_vision_position and relevant fields from vehicle_local_position_groundtruth)
  2. External atttiude, angular velocity (vehicle_vision_attitude and relevant fields from vehicle_attitude_groundtruth)

It would also be great if you can add ground-truth to the existing local position / velocity plots. I will add plumbing the Firmware side to log data from ATT_POS_MOCAP and in the future from mavlink/mavlink#660 into vehicle_groundtruth_position.

The plotting system should check whether these topics exist and plot them if available. I'm not sure if it does this already.

Log upload email

A few suggested changes to the email sent by Flight Review:

  • Add the title to the subject
  • Add the description to the body

This will make searching and archiving easier

Create new table with releases (unique combinations of PX4 release and OS release)

We need to be able to see the number of flights, the number of different airframes (identified by the unique ID of the MCU) and the number of hours per release and accumulated (all previous releases up to this release).

This is required to get an idea about the testing coverage we have achieved for a particular release. We might need some fuzzy matching and have two different hour counts: One for a particular minor release (1.5.2) and one for the major release (1.5), which is generally a bit more informative.

error: (vehicle_local_position_groundtruth): list index out of range

Run locally, got this error.
This is the ulog:
https://review.px4.io/plot_app?log=2f9610e9-87fa-409a-bb8f-0fab6c61971a

% ./serve.py -f log_206_2017-12-14-16-22-02.ulg                                                                                                                                                                                 eric@eric-Lenovo
[8157:8196:1215/152545.162167:ERROR:browser_gpu_channel_host_factory.cc(107)] Failed to launch GPU process.
Created new window in existing browser session.
GET[log]=/home/eric/all_code/flight_review/log_206_2017-12-14-16-22-02.ulg
Downloading http://px4-travis.s3.amazonaws.com/Firmware/master/airframes.xml
<class 'IndexError'> (vehicle_local_position_groundtruth): list index out of range
Traceback (most recent call last):
  File "/home/eric/all_code/flight_review/plot_app/main.py", line 185, in <module>
    plots = generate_plots(ulog, px4_ulog, db_data, vehicle_data)
  File "/home/eric/all_code/flight_review/plot_app/configured_plots.py", line 187, in generate_plots
    mark_nan=True, use_step_lines=True)
  File "/home/eric/all_code/flight_review/plot_app/plotting.py", line 467, in add_graph
    p.step(x='timestamp', y=field_name, source=data_source,
AttributeError: 'Figure' object has no attribute 'step'

NAN markers

These are really helpful, but there are a few cases where NAN is used normally. For example an IDLE position setpoint will have a lat/lon set to NAN.

Feature: Automatic log creation/association to PX4/Firmware issue

The idea is that when the user uploads the file, adds the issue description on the Additional Feedback field, and then checks an option like Create Github issue on PX4/Firmware, popping up a Github login if the user is not logged in yet. I assume that the backbone of the Flight Review would have to include one API like https://github.com/paulirish/git-open or https://github.com/node-gh/gh or similar and the binds between issue creation and the Flight Review capabilities. We could also iterate over this and present options for choosing what plots to show on the Github issue, parameter values, etc.

For example, for nodegh, would be something like a script that runs something like:

gh is --new --title <the_log_description_field> --message <the_additional_feedback_field> --user <the_github_user> --repo <master> --log <the_uploaded_log_file> --plots .... --parameters ...

We can add an option for link the flight log with an existent issue also. For example, in nodegh, that could be something like:

gh is <issue_number_or_name> --comment <log_description> --log <the_uploaded_log_file> --others ...

In the Flight Review side, we can add an option Link log to Github isse, which pops a dropdown list of open issues and/or having the option to the user write the issue number, though I prefer the first option.

Note: to keep track of the suggested in PX4/PX4-Autopilot#7701.

Load plots piece-by-piece to avoid huge page load time

@bkueng We should try to load the GPS track immediately (cache the KML export on upload on the server) and then offer the other plots later. That way people can start looking at some of the data already and the 20 seconds wait time isn't feeling like forever.

peoblem of setup server

i setup a server with ubuntu 16.04 lts,but it can not plot anything.in chrome dev console,it show me websocks not work,and console show me

list index out of range
but i don't know where is wrong.can you give me some advice?thanks!

screenshot 2017-07-26 at 12 36 43
screenshot 2017-07-26 at 12 52 06

Clarify dt on sensor sampling

screen shot 2017-08-02 at 20 56 55

How is the delta time (in blue) calculated here? The reason I ask is that we need to make very clear if the system slips that delta or just the logging process. That makes a huge difference. If it is merely the logging process we might consider moving all these quantities to a new, separate plot and do one for system performance (potentially including control system delay) and one for logging performance.

My primary concern is that people think that the system is unreliable in timing when its actually not.

Setpoint plots should be bars, not lines

Since setpoints are values that are effective until the next setpoint is issued, a plot of them should be more like a bar graph than a line. With the current graphs, connecting the setpoint updates with lines makes it visually appear as though the setpoint is changing linearly with time between updates.

This characteristic is more readily apparent with flights and/or vehicles that have slow setpoint updates. For example, my vehicle's yaw rate setpoint changes only once a minute or so, and only by large values. The graph plots end look like a sawtooth, rather than a square wave. See the following plot for an example.

screen shot 2017-11-14 at 4 55 31 am

Add date and time

Would be nice if we could display the date and time from the log where the logging duration etc. is

Graphs should have the same time dimension

Currently the graphs do not align in time - e.g. if messages from one topic stop updating it crops the graph and they are unaligned. All graphs should start and stop at the min and max times for which we have any data, not just the topic they are graphing.

The current state can make crash analysis quite confusing, because you carefully need to read the time labels.

user input plogging (rc_channels, input_rc, manual_control_setpoint)

Currently flight review plots rc_channels as "Raw Radio Control Inputs" to show user input. This is the calibrated RC input which is then mapped to manual_control_setpoint x,y,z,r, etc.

image

In PX4 RC enters the system through input_rc -> rc_channels -> manual_control_setpoint.
The message manual_control_setpoint is what the controllers actually use and it's more helpful for debugging. Additionally it's the only thing logged when using a gamepad/joystick over mavlink instead of RC.

In summary, I think we should be logging and plotting manual_control_setpoint instead of rc_channels. I can help make the transition if we're in agreement.

PX4 1.6.2 log upload broken

PX4 version 1.6.2 adds the feature:

  • "New .ulg uLog logging format which directly logs uORB topics and offers more accurate time stamping. Supported in FlightPlot"

I tested 1.6.2 with a VTOL QuadRanger. I loaded 1.6.2 firmware, loaded my parameters from 1.6.1, calibrated the sensors etc. and did a few short flights.

The resulting logs load fine in FlightPlot under Windows (I cannot seem to get FlightPlot working on Ubuntu, but that's a different issue).

But when I try to upload to review.px4.io, I get "HTTP Error 400: Failed to parse the file. It is most likely corrupt."

I attach a sample log: log_8_2017-6-13-08-42-46.zip.

The logs are fine in FlightPlot so should be loadable by Flight Review?

Access to the private log DB

Hello guys,
Thank you for this amazing tool! Is it possible to access/download the whole public flight log database (instead of writing a scraper that pulls it)? This would make it easier to experiment with all the timeseries available so far and feed them to some LSTMs etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.