Close

Tricopter simulation

A project log for Modular Unmanned Vehicle Controller

(former YAUVeC - Yet Another Unmanned Vehicle Controller)

e-n-heringE. N. Hering 02/14/2019 at 15:040 Comments

After moving to another city, the development of the system PCBs had to be halted for some time. Due to a lack of space, I had to focus most of the work on this project on the computer. My new job created an opportunity to revive a n-body simulation program I have written during the physics course, around the 90s. This program allowed me to simulate configurations of particles and springs interacting through well known laws and visualize them through virtual 3D cameras. I upgraded it to run on multiprocessor machines and moved all the code to C++, using SDL as a plotting tool and CERN ROOT to plot graphs.

Testing the real tricopter became a dangerous task. The control system PIDs need to read sensor data and control engine power. I had to tie the tricopter to a string connecting the room ceiling to a 20kg water bottle that was hanging on it. When the control system was turned on, the engines could go to maximum speed and destroy something around, even with the tricopter tied. Testing the control system in a real system proved to be tricky.

I decided to unite both efforts and build a simple tricopter model on the simulation program. I used a four particle model with particles connected by hi-K springs. Three particles behaved as the three engines, the fourth behaving as a payload. Their relative positions can be controlled by parameters.

The forces that are applied on the three engine particles are the near same forces that would apply to the engines. And they would be defined by the PIDs that control the real tricopter. A servo was simulated to deflect the tail engine air flow and counteract residual torque. By monitoring the tricopter gravity center and particle configuration I could calculate the sensor data thus simulating a magnetometer, an accelerometer and a gyroscope. A virtual planet was also simulated to give me geographical coordinates for the simulated GPS and a magnetic field for the magnetometer.

Tuning the PID parameters on the simulated system proved to be as difficult as doing it in a real system. The good part is that I would not hurt my fingers on real propellers. After many, many tries and different PID connection configurations, I reached a more or less stable system and decided to code some genetic algorithm programing on the simulation. Now I had populations of tricopters that tried to stay near a waypoint as long as possible. The best of them was used as a seed for the next generation. PID gains were perturbed along the population to generate more or less adaptable individuals.

It turned out that a perturbing many parameters at a time, even slightly, did not produce optimal results. The selection process was taking many generations to produce a better individual, and its performance was far from the one I expected, so I decided to restart tuning the PIDs of a single individual manually. I also changed the PIDs arrangement, to use the maximum amount of sensor information I could.

Today I believe to have reached a milestone. The video below shows the latest result. The red cross is the tricopter waypoint, which is moving because the small planet below it is rotating slowly. The forces produced by the engines are plotted in white, while the control system desired heading is shown in red or blue, depending on the distance to the waypoint.

Now I believe this control code can be used on the real tricopter system.  

Discussions