Scaling Commanded Thrust as a Function of Height

Firmware/software/electronics/mechanics
Post Reply
controlsysdes
Beginner
Posts: 4
Joined: Tue Mar 19, 2019 6:01 pm

Scaling Commanded Thrust as a Function of Height

Post by controlsysdes »

Hi there,

I'm trying to scale the commanded thrust to the motors as a function of height. However, I'm not sure how to implement such a function and where to add it in the code. Does anyone have some experience with this? Please let me know.

Thank you.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Scaling Commanded Thrust as a Function of Height

Post by arnaud »

The interesting part of the code for that is the stabilizer loop, it is the loop that runs the controllers and eventually controls the motors: https://github.com/bitcraze/crazyflie-f ... zer.c#L190. You can add a function there that modify the thrust in the control structure. One place to quickly hack would be to modify the power distribution directly: https://github.com/bitcraze/crazyflie-f ... on_stock.c.
controlsysdes
Beginner
Posts: 4
Joined: Tue Mar 19, 2019 6:01 pm

Re: Scaling Commanded Thrust as a Function of Height

Post by controlsysdes »

Thanks for your response. What about the position_controller_pid? There is already a section at the bottom of the code related to thrust scale and feedforward term.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Scaling Commanded Thrust as a Function of Height

Post by arnaud »

This is also a possibility, basically you want to affect the control structure, where to put the code is mode a question of where does it fit logically.

Without having more precision about what you want to achieve, I would think that if your code is PID-specific then adding it in the PID code makes sense, if it could work with any controller (like the Melinger controller), then I would think that calling a function in the stabilizer loop makes more sense.
Post Reply