GithubHelp home page GithubHelp logo

purdue-biorobotics / flappy Goto Github PK

View Code? Open in Web Editor NEW
211.0 27.0 61.0 2.1 MB

An open source dynamic simulation for flapping wing robots and animals

License: MIT License

Python 70.09% C++ 29.89% SWIG 0.02%

flappy's Introduction

Flappy

Flappy Hummingbird: An Open Source Dynamic Simulation of Flapping Wing Robots and Animals

This work has been published and presented at ICRA2019 (The 2019 International Conference on Robotics and Automation).

It will be updated continuously. Stay tuned.

Publication

To cite this work in publications:

@inproceedings{fei2019flappy,
  title={Flappy Hummingbird: An Open Source Dynamic Simulation of Flapping Wing Robots and Animals},
  author={Fei, Fan and Tu, Zhan and Yang, Yilun and Zhang, Jian and Deng, Xinyan},
  booktitle={2019 IEEE International Conference on Robotics and Automation (ICRA)},
  pages={9223--9229},
  year={2019},
  organization={IEEE}
}

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Flappy requires python3 with the development headers. You'll also need some other system packages. DART is required as a simulation engine (and we use pydart2 as interface). They can be installed as follows

Ubuntu

# install system packages
sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev swig python3-pip python3-pyqt4 python3-	pyqt4.qtopengl
pip install click

Install DART from source

Install DART from soucrce

  • Please install all the dependencies so there will less likely to have errors when installing the repository

  • Make sure you install version 6.2.1 by changing

     git checkout tags/v6.8.2

    to

     git checkout tags/v6.2.1

Please refer the official DART installation document when you have problems.

Mac OS X(not finished)

Installation of system packages on Mac requires Homebrew. With Homebrew installed, run the follwing:

# install system packages
brew install cmake openmpi

# install dart
brew install dartsim

Alternative installation methods

  1. Pydart2 source code included in our project. (No extra installation required) No installation
  2. Pydart2 source code not included in our project. (Installation required, which is not a pleasant experience.)
    • Please continue your steps here
  3. Docker (If you do not have access to recommanded OS environment) Docker container

Virtual environment

From the general python package sanity perspective, it is a good idea to use virtual environments (virtualenvs) to make sure packages from different projects do not interfere with each other. Creation of virtual environments is done by executing the command venv:

python3 -m venv /path/to/new/virtual/environment

To activate a venv:

source /path/to/venv/bin/activate

Installation

  • Pydart2 is a python binding to DART.

    pip install pydart2

    If this does not work please try to install from source. Please refer to document when you have problems.

  • Tensorflow is needed for the usage of neural network. If you want to make use of your GPU, please install the tensorflow with gpu

  • Please make sure you install tensorflow version < 2.0

    pip install tensorflow-gpu # if you have a CUDA-compatible gpu and proper drivers

    else

    pip install tensorflow==1.9

    please refer to TensorFlow installation guide for more details.

  • Clone the repo and cd into it:

    git clone https://github.com/purdue-biorobotics/flappy.git
    cd flappy
  • Install Flappy package

    pip install -e .
  • Lack dependency

    • Please try to install any dependency if there is an error related to that library during the installation process.
    pip [Dependency lack of]
    or
    apt-get install [Dependency lack of]
    

Environments

FWMAV

Dual motor driven flapping wing robots based on the Purdue Hummingbird robot.

The control of this vehicle is a difficult problem. We challenge developers, researchers, scientists and roboticists to come up with better control algorithms, either feedback controller or learning-based controller.

Two default working controller are included: a cascading PID controller (control structure similar to ArduPilot) and an Adaptive Robust Controller (ARC). These two controllers can be evaluated in the provided test script.

'fwmav_hover-v0'

This environment is for controlling the dual wing flappin wing robot.

The four inputs are the thrust and torque signals: * voltage_amplitude_ [0,18] volt for thrust * differential_voltage_ [-3,3] volt for roll torque * mean_voltage_ [-3.5,3.5] volt for pitch torque * split_cycle_ [-0.15,0.15] for yaw torque

This mode of control is similar to helicopter or quadcopter control. The sinusoidal voltage signal drives the wing back and forth is generated by using wing beat modulation.

The input actions are in [-1,1] and will be scaled to their appropriate range. If implementing a feedback controller, the input should be scaled to [-1,1]. See the baseline PID controller and test example for detail.

Testing with Closed loop controller (PID or ARC)
python test.py --model_type=PID
python test.py --model_type=ARC
Learning

We choose to use stable baselines instead of baselines as our RL library. Note that our environment still follows the specification of the gym/env, so baselines can be applied to our env as well.

Training
python train.py --model_type=PPO2 --model_path=ppo2_mlp --policy_type=MlpPolicy --n_cpu=12 --time_step=100000
Testing with trained model
python test.py --model_type=PPO2 --model_path=ppo2_mlp --policy_type=MlpPolicy

'fwmav_hover-v1'

This environment similar to 'fwmav_hover-v0', but without using [wing beat modulation][doman2010wingbeat].

An example using PID is in test_simple.py, this example still uses the same PID controller and wing beat modulation. But the input to the environment are just two voltage signals ([-18,18] volt) supplied to the two motors.

To develop a new control policy, the policy should generate sinusoidal signals near 34Hz to drive the wings and implement control at the same time. Without specifying the wing kinematics allows the ability to generate torque and force in arbitrary directions.

Testing with Closed loop controller (PID or ARC)
python test_simple.py --model_type=PID
python test_simple.py --model_type=ARC

Contributor

Fan Fei, Ruoyu Wu, Jian Zhang, Zhan Tu, Yunlei Yan, Yuan-Cheng Chen

License

MIT

Acknowledments

flappy's People

Contributors

arbalest1027 avatar chen3082 avatar ffnc1020 avatar purdue-biorobotics 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  avatar  avatar  avatar

flappy's Issues

pydart2 cannot be install on Ubuntu 18.04 (python3)

Pydart2 cannot be installed with this issue from the year of 2018. Still not solved. Pip install and make install will goes to the same problem.

Since pydart2 is now deprecated.
Is it possible to make some updates so that flappy will not rely on pydart2?

Colab Notebook

Hello,

I set up a colab notebook, so you can train your agents online on flappy envs ;) : https://colab.research.google.com/drive/13mJ1bU2tKVurG9chNhM0U7ivgVKlzPu7

Also, I have some questions about the training:

  • How many timesteps did you use for the hover and maneuver envs?
  • What was the final performance?

It seems, that your maneuver does not follow gym interface, the reward must be a float, but is currently a numpy array (I had to use a reward wrapper to catch up the error).

I would also normalize the reward using the opposite of the cost instead of the inverse (otherwise the reward magnitude is really huge), and maybe add a "life bonus" (+1 for each timesteps) for the hover env, see here for an example ;)

Aerodynamic Normal Coefficient in FWMAVs geometric control

Hello,

While reading the papers on FWMAVs control and design optimization, I found in your paper [1] references to "..C_L, C_D and C_N are the aerodynamic lift, drag and normal coefficient given by [19]... ". However, after checking [19] I could only find the definition and values for C_L and C_D, but not for C_N, the aerodynamic normal coefficient.

I verified as well other references but yet could not find references to the C_N. Would you please be kind to let me know where can I find more information on the aerodynamic normal coefficient, its values and mathematical derivation?

I would like to test out my control ideas, and need the C_N value.

Thanks for your time.

Juan Medrano

[1]Zhang, J., Tu, Z., Fei, F., & Deng, X. (2017). Geometric flight control of a hovering robotic hummingbird. Proceedings - IEEE International Conference on Robotics and Automation, 5415โ€“5421. https://doi.org/10.1109/ICRA.2017.7989638

[19] Dickinson, M. H., Lehmann, F., Sane, S. P., Dickinson, M. H., Lehmann, F., & Sane, S. P. (2016). Wing Rotation and the Aerodynamic Basis of Insect Flight Published by : American Association for the Advancement of Science Stable URL : http://www.jstor.org/stable/2898158 Linked references are available on JSTOR for this article : Wing Rotation and the , 284(5422), 1954โ€“1960.

pydart2 issues

Hello,

Thanks for releasing such a nice simulator. I have been trying to run it and, while I was successful only once, now I am not able to continue. I keep getting this error:

Traceback (most recent call last):
  File "/home/fer/git_clone/flappy/pydart2/pydart2/pydart2_api.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/home/fer/git_clone/flappy/.flappy_env/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'pydart2._pydart2_api'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 15, in <module>
    from flappy.envs.fwmav.controllers.arc_xy_arc_z import ARCController
  File "/home/fer/git_clone/flappy/flappy/envs/fwmav/__init__.py", line 1, in <module>
    from flappy.envs.fwmav.fwmav_sim_env import FWMAVSimEnv
  File "/home/fer/git_clone/flappy/flappy/envs/fwmav/fwmav_sim_env.py", line 11, in <module>
    import pydart2 as pydart
  File "/home/fer/git_clone/flappy/pydart2/pydart2/__init__.py", line 5, in <module>
    from . import pydart2_api as papi
  File "/home/fer/git_clone/flappy/pydart2/pydart2/pydart2_api.py", line 17, in <module>
    _pydart2_api = swig_import_helper()
  File "/home/fer/git_clone/flappy/pydart2/pydart2/pydart2_api.py", line 16, in swig_import_helper
    return importlib.import_module('_pydart2_api')
  File "/home/fer/git_clone/flappy/.flappy_env/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libdart.so.6.8: cannot open shared object file: No such file or directory

Also, it seems that now pydart2 is deprecated.

Could you please let me know if there is any way to solve this issue? I would really like to use your simulator to test control ideas. Thanks!

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.