Page 1 of 2

Hover mode | accelerometer?

Posted: Tue Nov 29, 2016 5:35 pm
by jassi0709
Hi guys.
I'm working on making the drone flying really steady in hover mode without the human need to change something.

So far I managed to tune the PID for an almost perfect hover in the XY plane. The things get complicated which I go in hover mode because, from what I understood, it starts using different PIDs and, because of the noise in the barometer's data, it starts oscillating in the Z axis. Unfortunately, this oscillation on the Z axis influence the XY plane movements and the drone starts to have little shift.

Do you guys ever faced this sort of problem?
I have already done a characterization of the barometer's raw data and found out that a "moving average" algorithm helps to reduce the oscillations but the drifts of the barometer cannot be solved easily.
I was thinking this is, maybe, because the Z accelerations are not considered in hover mode? I mean the acceleration from the accerometer.

Finally, I cannot really understand the following:

Code: Select all

struct selfState_s {
  float estimatedZ; // The current Z estimate, has same offset as asl
  float velocityZ; // Vertical speed (world frame) integrated from vertical acceleration (m/s)
  float estAlpha;
  float velocityFactor;
  float vAccDeadband; // Vertical acceleration deadband
  float velZAlpha;   // Blending factor to avoid vertical speed to accumulate error
  float estimatedVZ;
};
What are those estAlpha, velocityFactor, vAccDeadband, velZAlpha? I don't want to change before understanding what are those. Maybe some sort of low-pass filter?

In the meantime I will try to tune the hovering PID in order to see if something gets better. I will update you.

Thank you for you time.
Best regards,
Jassy

Re: Hover mode | accelerometer?

Posted: Fri Dec 02, 2016 2:04 am
by islamoc
Hello can you give me and idea how did you tuned the PID ? in more details please

Re: Hover mode | accelerometer?

Posted: Fri Dec 02, 2016 9:00 am
by jassi0709
Hi.
Read my last thesis weekly report (attachments).
2016.11.25_Report#9_withHiddenParts.pdf
Jaskirat's thesis weekly report #9 with unnecessary info removed.
(810.27 KiB) Downloaded 304 times
Let me know if everything is clear.

Best regards,
Jassy

Re: Hover mode | accelerometer?

Posted: Fri Dec 02, 2016 9:16 am
by arnaud
Hi Jassy,

The parameter you copy-pasted (the alpha and factor) are filter parameter for the complementary filter. The calculated altitude is a mix of filtered pressure sensor and the accelerometer: https://github.com/bitcraze/crazyflie-f ... .c#L67-L69. The parameters allows to change filtering of the accelerometer, of the pressure and to change the contribution of each sensors.

When fixing alt-hold I had to filter a bit more the pressure since I saw oscillation coming from the thrust: the thrust was changing the pressure reading which made the altitude control loop oscillating. Maybe this is what you are experiencing.

There is still a lot to tune to make the alt-hold correct. One hopeful thing is that if you set the Z velocity to 0 disabling completely the estimator part, you end up with some kind of constant velocity control which is pretty stable: on my tests I can get the copter to say at the same height for about 5 to 10 sec before diverging. This is using only the accelerometer to control the velocity. It means that there should be a lot of room for improvement.

Best,
/Arnaud

Re: Hover mode | accelerometer?

Posted: Mon Dec 05, 2016 1:10 pm
by jassi0709
Hi Arnaud,
Thank you for you answer.

I am still working a bit on that, I will update you with some documentations which can turn out to be useful for the community too.
Indeed I'm try to make a flow diagram of the PIDs present on the Crazyflie 2.0.
Crazyflie PID description.png
This is just a first draft and I believe there might be some errors. Meanwhile, I would approcciate some feedback and/or suggestions.

Best regards,
Jassy

Re: Hover mode | accelerometer?

Posted: Tue Dec 06, 2016 11:29 am
by arnaud
Hi Jassy,

Wow this is very beautiful! Have you done is with inkscape?

Though the diagram is not accurate:
- You are missing the thrust, which is what altitude hold will be eventually driving
- Maybe you can represent the power distribution: the output of the angle PID will be torque-like and the output of the thrust PID will be force-like (they are currently expressed in PWM, but they are really torque and force). The power distribution block is responsible for translating these force and torques is individual motor control.
- The velocity loop will generate the attitude setpoint for the attitude loop. What altitude hold is doing is to multiplex the attitude loop thrust input from direct gamepad control, to velocity loop output.

Best,
Arnaud

Re: Hover mode | accelerometer?

Posted: Wed Dec 07, 2016 1:14 pm
by jassi0709
Hi Arnaud,
I was aware of few inconsistencies. I will check your comments, add more details and then post it again during the weekend.
I actually used draw.io, but maybe I should use Inkscape... :D

I've also managed to achieve a better hovering which I will share soon as I can.

Best regards,
Jassy

Re: Hover mode | accelerometer?

Posted: Wed Dec 07, 2016 5:31 pm
by islamoc
Hello
I'm still having issues tuning the PID actually
even when I send just a thrust command it is going in diagonal direction even if I send only thrust
any advice ?

Thank you

Re: Hover mode | accelerometer?

Posted: Thu Dec 08, 2016 7:29 am
by jassi0709
Hi Islamoc
I just tried to the pid that I suggested you to a new Crazyflie and everything works like a charm! Have you already tried to trim the pitch and roll angle? They are in the main "Flight Control" tab of the Crazyflie client.

Best regards,
Jassy

Re: Hover mode | accelerometer?

Posted: Thu Dec 08, 2016 8:46 am
by tobias
@islamoc This could be hardware related. Try looking for vibrations and if so tune the propellers or check for bent motor axle.