New simulation software to aid PID research and development

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
BirdShredder
Posts: 31
Joined: Mon Jun 16, 2014 10:50 pm

New simulation software to aid PID research and development

Post by BirdShredder »

I was planning to play around with some PID algorithms. But I could not find a simulator fitting my needs. Thus I created one. It is not finished, but it is in a state that it might be useful for someone else.

I'm not a physicist and primarily relying on the physics I learned long ago in high school. I would very much appreciate reviews of the code by anyone.(it is just 200 or 300 lines of code)

Image

https://github.com/yschaeff/quadsim

What is it and why?

This is a multirotor physics simulator specifically designed to help
in development and research of PID controllers. It has been kept as
simple as possible to make the code accessible for others as well.

Almost all calculations are made in 3D, it should be relatively easy to
switch to a 3D gui at a later time. Currently a two
rotor craft is simulated, adding more rotors should be trivial.

Features
* (should have) accurate physics
* accessible code
* aircraft steerable
* reasonable drag model
* motors do not respond infinitely fast

Missing features
* Sensors (with jitter and max update frequency)
* propellers are not modelled.
* Yaw (motors generate no toque along their shaft)
* controller should not run every simulation step

Usage

python quadsim.py

Then use arrowkeys to steer the aircraft and spacebar to reset motion

You will additionally need numpy and pygame packages

BirdShredder
Posts: 31
Joined: Mon Jun 16, 2014 10:50 pm

Re: New simulation software to aid PID research and developm

Post by BirdShredder »

Among fixing the drag model I also included a pidcontroller run time. If you want, you can study the effects of a slow processor on the stability of the aircraft and the required PID values. Or even vary the speed the motors can react.

Zenman
Posts: 7
Joined: Tue Jul 16, 2013 4:46 pm

Re: New simulation software to aid PID research and developm

Post by Zenman »

Interesting! I don't know anything about coding so I'm sorry to not be able to contribute, but I think an accurate model of pid algorithms used by mwc could be quite useful. Hope you go forward with this. How can I try it out? Do you have a compiled exe?

BirdShredder
Posts: 31
Joined: Mon Jun 16, 2014 10:50 pm

Re: New simulation software to aid PID research and developm

Post by BirdShredder »

I guess you are on Windows. You will have to install the Python interpreter. Make sure you get the SciPy and pygame packages as well. When you did that you can start quadsim.py

https://www.python.org/downloads/windows/
http://www.pygame.org/download.shtml
http://www.scipy.org/install.html

Post Reply