Page 1 of 1

Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Mon May 24, 2021 8:11 am
by fede_tiberti
Hi, I was doing several attemps trying the two controllers with the method "send_zdistance_setpoint".
I notice that probably they process the data in different ways. If I write 0 on the third parameter (yaw-rate) the Mellinger begins to rotate, while the pid no.
The same for the roll setpoint, a value of 10 for the PID gives different output from the same value of 10 for the Mellinger.

Do you know this effect? How do the controllers elaborate the data?
It's important for me because I'am working on a project to compare them.

Re: Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Mon May 24, 2021 2:59 pm
by kristoffer
I don't have a good answer for you, but the best way forward is probably to check out the code. The set point structure in the Crazyflie is very generic and fairly confusing, you can find the definition here ... #L175-L196
There is a mode associated with each value that tells you if the value is absolute or velocity.

As you can see in the python lib ... #L105-L116 the send_zdistance_setpoint() method uses the generic commander, TYPE_ZDISTANCE.

This is handled in the Crazyflie in the crtp_commander_generic.c, ... ric.c#L126
Here you can see what values and modes that are set in the setpoint struct.

The struct is then pushed into one of the controllers (depending of your configuration) and you will end up here ... _pid.c#L60 or here ... ger.c#L124

From here I don't really know the details, and you will have to try to figure it out from the code how the values are used in different modes. It is possible (likely) that all controllers do not support all combinations of modes and maybe this is the reason you see different behaviour?

Good luck!

Re: Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Thu May 27, 2021 10:53 am
by fede_tiberti
Hi, I read all the codes and the controllers seem to have the same set point value.

Probably, I 've thought that the difference is in the reference systems. Could be possible that the Mellinger receives setpoint in the world reference and not in the body reference?
If yes, I could multiply the values with the rotation matrix and solve this issue. Do you know which is the rotation matrix?
I have only the flow deck v2, so I cannot have absolute coordinate.

Re: Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Mon May 31, 2021 1:56 pm
by kristoffer
As mentioned in another thread, this as been files as an issue in ... issues/789

Re: Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Mon May 31, 2021 4:12 pm
by fede_tiberti
Yes, I've read, thanks.
But maybe, the problem is not only the yaw. As I wrote, also the roll setpoint is decoded in different ways by pid and Mellinger.
Is this correct? Have you tested it?

Re: Mellinger and PID controllers (send_zdistance_setpoint)

Posted: Tue Jun 01, 2021 6:49 am
by kristoffer
Ah, I did not see any roll problems, but on the other hand I did not look too close either. I added it as a comment to the github issue.