byu-magicc / fcu_sim

[DEPRECATED] Superseded by https://github.com/byu-magicc/rosflight_plugins
2 stars 4 forks source link

command mode in multirotor_forces_and_moments.cpp #23

Open ttdm opened 7 years ago

ttdm commented 7 years ago

Hello,

I have a question about the command mode in the simple model. It may be a code issue but it is most likely a comprehension issue on my side.

So I noticed that in the simple model :

I have trouble understanding how the same PID coefficients can control the drone either in angle rate or directly in angle. As a consequence, I feel that in switching the command type, we implicitly change the drone dynamics. I saw that the differential term is computed in a specific way when the control is in rate and that its the simple velocity when the control is in position but I don't understand how this change could "correct" the differences in the P and I terms.

If it is indeed possible to use the same PID, I wonder if you could gave me a short explanation of why it is possible to do so and sorry for the trouble ?

If on the other side, it is impossible to silently switch from angle to angle rate, I think there are a few possibilities with the simplest one being to reduce the command choice to the "PID adapted" command mode and to clearly state somewhere what are the PID inputs ( angle or rate ).

A Huge thank you for all your work !! TTDM

superjax commented 7 years ago

You are completely correct. I think that is just a massive oversight on my part.

I'm pretty sure that the simplified model is really robust to gain changes (since it's perfect), so I think I have been using the same gains on both control modes and it's been working fine. (I'll be honest, I haven't actually done much work with the RATE mode so I can't say for certain that it works very well). I'm pretty sure that I tested it, but it has definitely been a long time.

That is definitely a bug. There should be a second set of gains for pitchrate and rollrate. Let's convert this to a bug and we'll close this issue once the fix you recommended has been put into place. (I think we should also print a message when the multirotor switches command modes, as you suggested)

As a side note, I think you alluded to the "dirty derivative" term in our simplePID. This is simply a way to reduce noise when differentiating measurements to obtain velocity. In case you are wondering exactly why we do that, I've linked an excerpt from "Small Unmanned Aircraft: Theory and Practice" By Randy Beard which explains the derivation of that term.