Giter Site home page Giter Site logo

mfkiwl / cvar-energy-risk-deep-model Goto Github PK

View Code? Open in Web Editor NEW

This project forked from castacks/cvar-energy-risk-deep-model

0.0 1.0 0.0 1.68 MB

CVaR-based Flight Energy Risk Assessment for Multirotor UAVs using a Deep Energy Model

License: BSD 4-Clause "Original" or "Old" License

Python 100.00%

cvar-energy-risk-deep-model's Introduction

CVaR-based Flight Energy Risk Assessment for Multirotor UAVs using a Deep Energy Model

This repository contains the code for ICRA 2021 paper:

CVaR-based Flight Energy Risk Assessment for Multirotor UAVs using a Deep Energy Model
Arnav Choudhry*, Brady Moon*, Jay Patrikar*, Constantine Samaras, Sebastian Scherer
(* equal contribution)

Brief overview [Video]

energy model - cvar overview

Energy management is a critical aspect of risk assessment for Uncrewed Aerial Vehicle (UAV) flights, as a depleted battery during a flight brings almost guaranteed vehicle damage and a high risk of human injuries or property damage. Predicting the amount of energy a flight will consume is challenging as routing, weather, obstacles, and other factors affect the overall consumption.

deep energy model overview

We develop a deep energy model for a UAV that uses Temporal Convolutional Networks to capture the time varying features while incorporating static contextual information. Our energy model is trained on a real world dataset and does not require segregating flights into regimes. We illustrate an improvement in power predictions by 29% on test flights when compared to a state-of-the-art analytical method. Using the energy model, we can predict the energy usage for a given trajectory and evaluate the risk of running out of battery during flight. We propose using Conditional Value-at-Risk (CVaR) as a metric for quantifying this risk. We show that CVaR captures the risk associated with worst-case energy consumption on a nominal path by transforming the output distribution of Monte Carlo forward simulations into a risk space. Computing the CVaR on the risk-space distribution provides a metric that can evaluate the overall risk of a flight before take-off. Our energy model and risk evaluation method can improve flight safety and evaluate the coverage area from a proposed takeoff location.

Prerequisites

  • Python >= 3.8

Installation

  • Clone this repo:
git clone #
cd #
  • Create a new virtual environment using Conda or virtualenv.
conda create --name <envname> python=3.8
  • Activate the environment and install the requirements:
conda activate <envname>
pip install -r requirements.txt

Datasets

We use the data set provided in the paper "Data Collected with Package Delivery Quadcopter Drone" (available here). The scripts are to preprocess the dataset are included.

Training

We provide a training script to train a TCN or LSTM model with some amount of flexibility. To train a custom recurrent net, run the following line of code along with some (or none) of the options provided

python train.py

Optional arguments can be given as following:

  • -d, --directory sets the working directory for data. Default is current working directory.
  • -o, --output sets the output directory for training. Default is current working directory.
  • -D, --data whether to download the data or not. This is a binary flag whose default is set to False.
  • --lookback sets the size of lookback window. (default = 20)
  • --batch_size size of batch passed to tf. (default = 32)
  • --nb_filters (For TCN) The number of filters to use in the convolutional layers. Would be similar to units for LSTM. Can be a list. (default = 32)
  • --kernel_size (For TCN) The size of the kernel to use in each convolutional layer. (default = 3)
  • --nb_stacks (For TCN) The number of stacks of residual blocks to use. (default = 1)
  • --n_layers Number of layers in the network. (default = 4)
  • --total_epochs Total number passes over the entire training data set. (default = 10)
  • --optimizer Optimizer used by the neural network. (default = Adam)
  • --dropout Dropout used by the neural network. (default = 0)
  • --units (For LSTM) The number of units in each layer. (default = 32)
  • --net_type The type of net to train. Either lstm or tcn. (default = tcn)
  • --stateful sets whether to create a stateful neural net or not. This is a binary flag whose default is set to False.

On running the training script, everything is saved in a new folder called Results which is created in the output directory. The initialized model is saved in a sub-folder called saved_models. It is saved with the name <save_str> which is created using the following rule for a TCN

{net_type}_{lookback}_{nb_filters}_{kernel_size}_{nb_stacks}_{n_layers}

and the following rule for an LSTM

{net_type}_{lookback}_{dropout}_{units}_{n_hidden}_{optimizer}

The model is checkpointed at epoch 0 as well as every 50 training flights. The checkpoints are stored in a sub-folder called ckpts/<save str>. While training, logs are saved for tensorboard in the sub-folder logs/<save str>/<time at start of experiment>. At the end of the experiment, a csv file is created with the Validation and Training results at CsvResults/<save str>/csv_result.csv.

Evaluation

The repo contains the deep energy model and the Liu model cited as the baseline in the paper. To run the evaluation script on the provided checkpoints, run the following

python evaluation.py

Optional arguments can be given as following:

  • -d, --directory sets the working directory for the data. Default is current working directory.
  • -m, --model model(s) to evaluate. Can be any of b-TCN, s-TCN, b-LSTM, s-LSTM, liu, all or custom. Default is b-TCN.
  • -e, --evaluate which dataset to evaluate on. Can be train, test, val, random, or all. Defult is test.
  • -D, --data whether to download the dataset or not. This is a binary flag whose default is set to False.
  • -c, --ckpt is the location of the checkpoint file for weights of the custom neural net. It is required if a custom model is selected.
  • Other additional options are available in case a custom net is to be evaluated. For details on those options please check the Train section above.

Pre-trained models

We also ship the checkpoints to reproduce the results presented in the paper. Details on how to run the model with the pretrained checkpoints are shown in the Evaluation section of this README file.

Model Random Flights Test Flights # params
MAPE (%) RE (%) MAPE (%) RE (%)
Liu model 14.05 9.16 12.70 7.41 5
b-LSTM 13.58 10.35 11.47 7.57 84,649
s-LSTM 15.35 11.65 12.36 8.24 5,833
b-TCN 10.38 7.38 9.06 5.12 76,073
s-TCN 10.36 7.56 9.13 5.52 5,225

For more information on the models please refer to the paper.

Quadrotor Simulation

We have also provided our simple quadrotor simulation for running MC simulations over a flight path and computing the risk.

python sim.py

The example environment is the same as Case Study 1 from our paper. The wind fiels and interfaces for getting wind at any position for any inlet condition is also included.

Cite

If you have any questions, please contact [email protected] or [email protected], or open an issue on this repo.

If you find this repository useful for your research, please cite the following paper:

@proceedings{cvarEnergy,
    title={CVaR-based Flight Energy Risk Assessment for Multirotor UAVs using a Deep Energy Model},
    author={Choudhry, Arnav and Moon, Brady and Patrikar, Jay and Samaras, Constantine and Scherer, Sebastian},
    booktitle = {International Conference on Robotics and Automation (ICRA)},
    year={2021}
}

cvar-energy-risk-deep-model's People

Contributors

bradygm avatar

Watchers

 avatar

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.