rl-pybullets-cf

Re-implementation of reinforcement learning based quadcopter control in gym-pybullet-drones.

https://github.com/danielbinschmid/rl-pybullets-cf

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: ieee.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Re-implementation of reinforcement learning based quadcopter control in gym-pybullet-drones.

Basic Info
  • Host: GitHub
  • Owner: danielbinschmid
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 150 MB
Statistics
  • Stars: 15
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 1
Created over 2 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

Reinforcement Learning for Quadcopter Control

This repository is a fork of gym-pybullet-drones and implements a reinforcement learning based control policy inspired by Penicka et al. [1].

Documentation

For documenation and a summary of the results, see our 4-pages whitepaper.

Result

RL Control Result

  • The drone can follow arbitrary trajectories.
  • It is given two next target waypoints as observation. If the two target waypoints are close, it will reach the target slower.
  • The learned policy corresponds to the obtained result after slow-phase training in Penicka et al. [1].

Implemented New Features

  • Reward implementation of RL policy proposed by Penicka et al. [1].
  • Attitude control action type. In gym-pybullet-drones, only motor-level control using PWM signals is implemented. This repository extends the original implementation and adds a wrapper for sending attitude commands (thrust and bodyrates).
  • Random trajectory generation using polynomial minimum snap trajectory generation using largescaletraj_optimizer [2] for training and test set generation. Implementation in trajectories subfolder.
  • Scripts for bechmarking the policy by computing basic benchmarks such as mean and max deviation from the target trajectory and time until completion.

Setup

Tested on ArchLinux and Ubuntu. Note that Eigen must be installed on the system. On linux, install via your package manager. E.g. on Ubuntu:

s $ sudo apt-get install libeigen3-dev

It is strongly recommended to use a python virtual environment such as conda or pyvenv.

  1. Initialise repository. Repository must be pulled recursively

s $ git clone git@github.com:danielbinschmid/RL-pybullets-cf.git $ git submodule --init --recursive

  1. Initialise virtual environment. Tested with python version 3.10.13. E.g.:

s $ pyenv install 3.10.13 $ pyenv local 3.10.13 $ python3 -m venv ./venv $ source ./venv/bin/activate $ pip3 install --upgrade pip

  1. Install dependencies and build

s $ pip3 install -e . # if needed, `sudo apt install build-essential` to install `gcc` and build `pybullet`

Usage

Scripts for training, testing and visualization are provided.

Training

To train the RL policy from scratch with our implementation, run

s $ cd runnables $ ./train_rl.sh

It will produce a folder with the weights. Later, this weights folder can be passed to the visualization and testing scripts.

Testing

To run our small benchmark suite, run

s $ cd runnables $ ./test_rl.sh $ ./test_pid.sh

Out of the box, it will use our pre-trained weights. Each bash script produces a .json file with the benchmarks.

Visualization

To just visualize the control policy, run

s $ cd runnables $ ./vis_rl.sh Out of the box, it will use our pre-trained weights and randomly generated trajectories.

Evaluation track generation

To generate a test set with random tracks, run

s $ cd runnables/utils $ python gen_eval_tracks.py

Plot generation

To generate the plots used in our whitepaper, run

s $ cd runnables $ ./generate_plots.sh

Dev

  • Autoformatting with black.

Test

Run all tests from the top folder with

sh pytest tests/

Common Issues

References

Owner

  • Name: danielbin
  • Login: danielbinschmid
  • Kind: user

Informatics Master's student at TU Munich.

Citation (CITATION.cff)

cff-version: 1.2.0
preferred-citation:
  type: article
  authors:
  - family-names: "Panerati"
    given-names: "Jacopo"
    orcid: "https://orcid.org/0000-0003-2994-5422"
  - family-names: "Zheng"
    given-names: "Hehui"
    orcid: "https://orcid.org/0000-0002-4977-0220"
  - family-names: "Zhou"
    given-names: "SiQi"
  - family-names: "Xu"
    given-names: "James"
  - family-names: "Prorok"
    given-names: "Amanda"
    orcid: "https://orcid.org/0000-0001-7313-5983"
  - family-names: "Schoellig"
    given-names: "Angela P."
    orcid: "https://orcid.org/0000-0003-4012-4668"
  doi: "10.0000/00000"
  journal: "2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)"
  month: 1
  start: 1 # First page number
  end: 8 # Last page number
  title: "Learning to Fly---a Gym Environment with PyBullet Physics for Reinforcement Learning of Multi-agent Quadcopter Control"
  issue: 1
  volume: 1
  year: 2021

GitHub Events

Total
  • Watch event: 13
  • Fork event: 1
Last Year
  • Watch event: 13
  • Fork event: 1

Dependencies

.github/workflows/push.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/release.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish master composite
pyproject.toml pypi
  • gymnasium ^0.28
  • matplotlib ^3.7
  • numpy ^1.24
  • pybullet ^3.2.5
  • pytest ^7.3
  • python ^3.10
  • scipy ^1.10
  • stable-baselines3 ^2.0.0
  • tensorboard 2.15.1
  • trajectory_cpp *
  • transforms3d ^0.4.1