How does one write UAV controller software without crashing a single UAV? By using a simulator, of course.
It turns out that simulating a UAV is pretty simple actually. A UAV can be abstracted like this:
– a simple rigid body with 4 forces – the propellers – pushing upward based on their throttle
– gyro value is the angular momentum of the rigid body + any drift noise you want to simulate
– accelerometer value is the body acceleration
– compass is some random world vector projected in the bodys space.
– air friction is 4 forces pushing in the direction opposite to the movement on 4 arms, with a strength depending on orientation of the quad and some random coefficient
This is enough to test the rate/stab pids and ahrs. Add a simulated GPS and you can test RTL. And so on.
The tricky part is to have the same code base running in the simulator and on the actual UAV. The more the better. Since raspberry pi is debian – just like ubuntu – this is actually pretty simple and it boils down, in my case, to have a io_board simulator. That is – the code that runs on the AVR crius board.
The next step is to add a UI for the simulator where I can configure sensor noise and fail rates and wind.