How to specify base thrust in cfclient

Firmware/software/electronics/mechanics
Post Reply
f-rower
Beginner
Posts: 16
Joined: Wed Jun 14, 2017 10:19 am

How to specify base thrust in cfclient

Post by f-rower »

Hello, I'm trying to get the CF 2.0 to perch by standing on a single point, and I'm adjusting the PID gains in the roll and pitch axes in the cfclient. I have noticed that when I set the minimum thrust to 0% and set the pitch and yaw PID gains all to zero (PID only in roll axis), the maximum thrust in the motors only goes up to 25 % (and if I set the minimum thrust to, say, 10%, then the maximum thrust will go up to 35%), see bottom right of picture. I would like to set this base thrust to something higher, say 50%. Where in the code is this parameter set?
25_percent_base_thrust.png
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to specify base thrust in cfclient

Post by arnaud »

I do not completly understand what base-thrust you are talking about. The thrust to individual motors is calculated by the power distribution code (https://github.com/bitcraze/crazyflie-f ... tock.c#L74) as a mix between the mean thrust and the requested attitude corrections (it is essentially torques). The source of the attitude correction is the attitude rate loop: https://github.com/bitcraze/crazyflie-f ... .c#L87-L89 calls https://github.com/bitcraze/crazyflie-f ... #L101-L113.

As a side note:
I actually played a bit and got something similar to your experiment to work here. I did as you do: I put the minimum thrust to 0 and maximum thrust starting to 1%. I then thrust to the maximum with the gamepad and increase the max thrust until I get a stable attitude.

At very low thrust (2-3%) I get some stability but this is due to friction in my system: any perturbation makes it unstable. Until about 15% it oscillate around 0. At about 15% it is starting to be very stable, though it overshoot at startup and does not react well to perturbation. Above 20% it is very stable and does not overshoot at startup.
experiment.jpg
This is an interesting experiment and I think most of the oscillation at low thrust comes from the calculation of the torque correction: the current power distribution is assuming that there is headroom for thrust correction and is not going to compensate when one motors is at 0 thrust (the opposite propeller should be pushed higher to compensate for the loss of torque). One quick idea would be to only add trust for torque correction and never subtract: the thrust then becomes a minimum thrust and not a mean thrust anymore.
f-rower
Beginner
Posts: 16
Joined: Wed Jun 14, 2017 10:19 am

Re: How to specify base thrust in cfclient

Post by f-rower »

Hi Arnaud,

sorry I got so long to reply, but I wanted to make sure I got it working before posting again :) . I managed to implement perching by adjusting the roll/pitch/yaw axes' PID parameters one by one (ie, for adjusting roll gains, I'd set all pitch and yaw gains to zero), and as you said, playing around with the max thrust value. It is very cool, as the cf can now land pretty much anywhere! I will be uploading a video to YouTube soon, and will update this post with the link when I do so :):)
Post Reply