While Loïc and Bertrand were working on Friday’s presentation slides, Samuel and myself spent the whole day testing our copter’s PID.
We finally found two majors bugs in our code (a motor offset unbalancing the system and a Integral term too often cleared). After that we were able for the first time to get a real flight while only acting on the thrust using remote control. We now have to add yaw PID and altitude PID and we may have something really nice to show on Friday.
Last days, we spent plenty of time understanding why we had so much problems.
It started yesterday evening: our motors weren’t responding to our commands. After long hours debugging with an oscilloscope, we finally succeed in making them work again, but we didn’t find any rational explanation of this problem.
Today, as we wanted to test graphical logs of copter flights, we experimented big problems again. After having taken advices from our professors, we added some improvements to our code: we improved our scripts, added locks on processes to avoid multiple instances of them… Finally, we found the problem which was making us mad. One of our battery has a big problem: it seems it can’t deliver enough power to the motors, what gives our copter a very strange behaviour.
We now have the same conditions of work than a few days earlier, but with a better work environment. We are going to spend next day intensively working on the stabilization and the command of our copter, we hope this will be easier than the days we just passed through.
Today, we went to the complex, a more spacious room than the one where we used to do our tests. The tests were quite conclusive. We were able to do some « landing » (the copter was caught by Axel near the floor because of turbulences caused by the proximity of this obstacle). With more power to the motors, we made the copter stay longer in the air, about 10/20 seconds (sadly, it wasn’t filmed).
We also used the remote to control the trust and the setpoint of the PID. It will need some software adjustments since it is still to brutal and rather hard to use.
Tomorrow, we’ll restore height control in our PID and see how much the copter drifts. This drift shall be corrected with the remote.
After having spent hours focusing on our PID into the Télécom ParisTech’s dancing room, we joined Télécom Robotic’s room in order to work on our implementation of Lucas and Kanade algorithm, because of a giant chessboard in green and red, perfect for image processing. We fixed Copterix in the air using some strings, and started test, with or without threshold, and it wasn’t really efficient…
We thought a moment about using ‘unfisheye’ opencv’s algorithm (see joined photo to understand why we wanted to use it), but it took 0.6 seconds per frame on our Gumstix…
What our camera actually sees: we can observe a 'fisheye' effect
Then we stopped and decided we should decide exactly how, even if it worked, Lucas and Kanade would help us to correct Copterix’s drift.
As we have 10 frames per second when processing the algorithm, it will be really difficult to determine in real time if we actually corrected the drift whenever we would want to correct it, and that is why we imagined the following algorithm:
wait for Copterix to be horizontal (pitch and yaw < epsilon)
take a reference picture and search the good features to track on it (quite heavy operation)
while Copterix is horizontal (pitch and yaw < epsilon)
____take a picture, compare it with reference
____if not horizontal (pitch and yaw >= epsilon)
______wait for Copterix to be horizontal (pitch and yaw < epsilon)
______go to 3.
____if drift is big enough (move size > threshold)
______go to 12.
____if we don’t find enough features to track
______go to 1.
ask PID to incline Copterix toward the good direction (we have to decide an angle)
wait a chosen time (we have to be over-precise on this data)
ask PID to set Copterix horizontal
go to 1.
The real difficulty of this algorithm is that it infers we do own a powerful and precise PID, able to remain horizontal most of the time, and to follow an order in the better and faster possible way, which is of course not true.
That is why we are now considering the fact that we may not have time to have a excellent PID AND implement such a precise algorithm; we will talk about it tomorrow with our teachers.
Today, we began to write some articles for the website and we mainly worked on Lucas and Kanade algorithm. We did some tests and we have some good results when the camera is recording pictures from the ceiling, but we have bad results when they are from the floor. Here is some illustrations:These pictures represent the evolution of the helicopter movement (x and y). The first picture was taken when the camera was watching the floor held by Loïc. We cannot distinguish a good evolution of the motion.
For the second picture, the camera was oriented to the ceiling. The copter was put on a table that we could move. The first peak represents a slow movement in one direction and a fast movement in the opposite direction. The second peak represents the same experiment with the introduction of some manual oscillations.
Tomorrow, in order to solve these problems, we will first of all apply a low pass filter and we will try to use a draughtboard on the floor with a good lighting.
We can now control the attitude of our copter with the RF remote control. We have also implemented the possibility of turning on/off the motors directly with the RF remote control. Bertrand has made a script for running all the control tasks at boot. We can thus take control of our Copter as soon as the gumstix has started and is running Linux, without using any SSH connexion.
Then, we took the Copter outside for a first flight in real conditions. We succeed in taking off, but I wasn’t very comfortable with it. Then, we had a big crash: Bertrand accidentally put the thrust too high at the takeoff. The Copter overturned and damaged/broke some propellers. Fortunately, we put a protection onto the motors’ boards yesterday. They thus don’t seem to have suffered damages. Here are some photos after the crash. (Photos are from Samuel Tardieu)
the broken propeller... what a shame.
Crash of the 22th April, 2011
Tomorrow, we’ll try to improve our PID algorithm for pitch, yaw and roll, and then we’ll probably work on the Kanade algorithm, for X and Y control loop.
Today, we added the yaw servomechanism on the Copterix and it responded pretty well, it is now able to fall slowly like a fall leaf. Sorry we don’t have any video this time, but you will soon understand why…
Our octocopter went through a lot of trouble:
When we passed on battery, motors were twice as powerful as on sector, and even though we lowed them a lot, it finally crashed on the ceiling. That was of course not a real test environment (indoor flights are not the exact purpose of a copter), and that is exactly the reason why this accident occurred. It turned out that we just had to change a propeller and our copter was back on tracks.
Since yesterday evening, Copterix tends not to start properly. We thought first it was because of the motors card security, which turns off every motors in case of a brutal startup, but it was late tonight we finally discovered with our teacher that it was just a bad contact between a part of this card and the rest of it on the i2c bus, and we finally fixed it.
Afterwards, we performed a Radio Frequency test and it went really well: we think we will be able to control the thrust, roll and pitch by remote control after a few callibration.
Finally, we started our web site ! We plan to add a lot of content about our project during next week, keep on checking !
Today, our purpose was also to find the good values for the PID. At the beginning, the copter was very instable and oscillating. But after having changed the structure of the PID (before we had 6 values to configure, now we have only 3 coefficients), the impact of each coefficients was more easily to understand. The result seems good, but it will be better when we will have the camera and the Sharp (distance sensor). Here is a little video illustrating our breakthrough:
Today, we tried to set the coefficients of our PID algorithm. In order to do this, we used the Ziegler-Nichols method. The first step is to set the integral and the derivative gains to zero. Then, we increase the value of the proportional gain, to obtain the control loop oscillating constantly. Unfortunatly, we didn’t succeed in obtaining the special value of P (proportional gain). It seemed we had still some bugs on the Kalman filter. Samuel and Axel tested again the good working of the Kalman filter (we had to change some coefficients of the Kalman since we put the card on the Copter), and fixed it.
Samuel made a basic program, in order to change easily the PID coefficients, while the Copter is running : we can now observe the effects of the changes in live.
We worked also on some improvements of the code: for the STM32 and for the Kanade algorithm, to prepare the future work & debug. For example, the UART was configured at 1 000 000 bps, so the STM32 had only 72 instructions to perform between each UART interrupt. Since we only send 150 packets/s (~20 bytes), 57600 bps speed would be fine, and more convenient.
Today, I finalized the emission of the commands for the motors, from the Gumstix to the STM32 and their reception (check the validity of the packet and if it’s valid, update the commands sent to the motors).
Then, with Samuel, we added 0MQ exchanges on the Gumstix between Kalman and the PID and between the PID and the UART.
On the Gumstix, the program that handles the UART has two threads. One receives data from the sensors from the STM32 and sends it -thanks to 0MQ- to the program computing Kalman. The other one, receives the commands of the motors from the PID and sends them to the STM32.
We also attached the PCBs on the copter:
We configured Kalman with the new axes and the offset of roll and pitch angles.
Finally, we all tested the PID. The algorithm seems okay, however, we’ll have to set each coefficient properly.
We’re trying to control roll and pitch angles with a low thrust (in order to prevent any accident). Then, we’ll add a control on Z thanks to the Sharp sensor.