Mellinger and PID controllers

Discussions about quadcopters/multi-rotors
Post Reply
fede_tiberti
Beginner
Posts: 6
Joined: Tue Apr 13, 2021 9:09 am

Mellinger and PID controllers

Post by fede_tiberti »

Hi, I have a crazyflie 2.0 with the flow deck 2.0... I would like to compare the two controllers with a simple script. Is it possible?
I know that the problem with the Mellinger could be the position, but can I manage it in some ways?

I have already installed the latest firmware version (2021.03)

Thanks ;)
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: Mellinger and PID controllers

Post by kristoffer »

You can change controller using the stabilizer.controller parameter
The available types are defined in https://github.com/bitcraze/crazyflie-f ... .h#L31-L37

PID = 1
Mellinger = 2
INDI = 3

You can find an example of how to set the parameter from python here https://github.com/bitcraze/crazyflie-l ... el.py#L147
fede_tiberti
Beginner
Posts: 6
Joined: Tue Apr 13, 2021 9:09 am

Re: Mellinger and PID controllers

Post by fede_tiberti »

Yes, I knew this.. maybe I didn't ask the right question, sorry.
The question is: Can I use different controllers, besides the PID, with only the flow deck 2? If yes, how can I do?

Does the Mellinger could have problems with the position? Unfortunately I don't have a positioning system, like mocap or LPS.
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: Mellinger and PID controllers

Post by kristoffer »

Ah, I see. The mellinger is more sensitive to errors in the position estimate and it is mainly useful with a good mocap system. I do not know a lot about the INDI controller, but I don't think it works without some tweaking.

I think the PID controller is the best option for the flow deck, it is robust and forgiving.

I have not tried a flow deck and the mellinger controller my self, but you can try to switch to the mellinger and see what happens. In worst case you will crash :-)
fede_tiberti
Beginner
Posts: 6
Joined: Tue Apr 13, 2021 9:09 am

Re: Mellinger and PID controllers

Post by fede_tiberti »

I've already done several attempts.
Using the client, I'm able to takeoff with the Mellinger controller. I set '2' on the parameter stabilizer.controller and then I click "Take off" from the "Command Based Flight Control" window. No problem, it works very well. Also to land of course.

But when I execute the script, with the Mellinger, it does not work. Probably I'm not using the right class.
Which library does the client use to execute the commands?
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: Mellinger and PID controllers

Post by kristoffer »

As mentioned before, the mellinger controller requires very good position estimation and the flow deck is probably not good enough.

I did a quick test my self with the autonmouse_sequence_high_level.py script, it contains a line that is commented out that switches to the mellinger. I did see the same problem and I could not complete a full figure 8 with the mellinger + flow.

I also tried with the client and switched to the mellinger controller using the param tab and used the Command based flight control buttons. It actually worked surprisingly well but was a bit shaky from time to time. I tested on the 2021.03 release.
Note: there is a known bug with the flow deck that makes the CF move backwards 1.5 m after take off when clicking one of the arrow buttons (https://github.com/bitcraze/crazyflie-f ... issues/760)
fede_tiberti
Beginner
Posts: 6
Joined: Tue Apr 13, 2021 9:09 am

Re: Mellinger and PID controllers

Post by fede_tiberti »

Thanks, but I don't understand which class the client uses.
Do your autonmouse_sequence_high_level.py script and the client use the same library? If yes, which?

Because I would try the library that the client uses (when I click takeoff) with a script, but the problem is that I don't know which class the client uses.
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: Mellinger and PID controllers

Post by kristoffer »

Ah, I see. The client uses the PositionHlCommander, you can find it here https://github.com/bitcraze/crazyflie-c ... ab.py#L436
Post Reply