INDI Controller Outer + Inner loop problems

Firmware/software/electronics/mechanics
Max_Kemmeren
Member
Posts: 40
Joined: Wed Jan 20, 2021 4:03 pm

INDI Controller Outer + Inner loop problems

Post by Max_Kemmeren »

Dear all,

For my thesis I need to use the implemented INDI controller, both outer and inner loop. On the crazyflie 2.1 I have the flowdeck 2.1 and the multiranger attched. The only problem I experience is an unstable controller.

For commanding the drone I use the python library with the following commands.

def move_up(scf):
with MotionCommander(scf, default_height = DEFAULT_HEIGHT) as mc:
time.sleep(2)
mc.up(0.3,0.05)
time.sleep(2)
mc.forward(0.3,0.20)
time.sleep(2)
mc.right(0.3,0.20)
time.sleep(2)
mc.land()

When having the inner and outer INDI Loop activated the outerloop reference values do not seem to be used in the inner INDI loop, when looking at logged parameters. Up on further investigation it seem to be that the if statement withholds this. (see code below from controller.INDI.c)

if (RATE_DO_EXECUTE(ATTITUDE_RATE, tick)) {

// Call outer loop INDI (position controller)
if (outerLoopActive) {
positionControllerINDI(sensors, setpoint, state, &refOuterINDI);
}

// Switch between manual and automatic position control
if (setpoint->mode.z == modeDisable) {
// INDI position controller not active, INDI attitude controller is main loop
actuatorThrust = setpoint->thrust;
// actuatorThrust = refOuterINDI.z;
} else{
if (outerLoopActive) {
// INDI position controller active, INDI attitude controller becomes inner loop
actuatorThrust = refOuterINDI.z;
}
}
if (setpoint->mode.x == modeDisable) {

// INDI position controller not active, INDI attitude controller is main loop
attitudeDesired.roll = setpoint->attitude.roll;
// attitudeDesired.roll = refOuterINDI.x;

}else{
if (outerLoopActive) {
// INDI position controller active, INDI attitude controller becomes inner loop
attitudeDesired.roll = refOuterINDI.x;
}
}

if (setpoint->mode.y == modeDisable) {

// INDI position controller not active, INDI attitude controller is main loop
attitudeDesired.pitch = setpoint->attitude.pitch;
// attitudeDesired.pitch = refOuterINDI.y;

}else{
if (outerLoopActive) {
// INDI position controller active, INDI attitude controller becomes inner loop
attitudeDesired.pitch = refOuterINDI.y;
}
}

As the mode.x etc are set to ModeDisable the setpoint value is used as reference instead of the refOuterINDI.x. I cannot seem to fix this, and cannot find where the setpoint.roll values are defined and thus do not understand what reference values it is using. Even though the outer loop is activated and calculated it is not used in the inner loop due to this mode problem.

Does someone have experience with this?

Greetings
Max Kemmeren
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: INDI Controller Outer + Inner loop problems

Post by kimberly »

Hi Max,

I can't really help you with this but I reached out to the contributors of both the inner and outerloop INDI to notify them on this forum post. I hope they will answer you soon.
dedecun
Beginner
Posts: 15
Joined: Tue Jul 02, 2019 1:43 pm

Re: INDI Controller Outer + Inner loop problems

Post by dedecun »

Hi, Max.

The INDI controller was implemented a while ago, and honestly we used it in only one application. This is only the second time someone reaches to talk about it, which is definitely a good sign, even though experiencing problems.

First step is to tell you this implementation has been completely inspired in a pre-existing implementation from a different platform, which does not mean we can still find bugs.

Have you tried to follow the steps from the issue and the PR the gave birth to this controller? I would recommend you to study them a bit, so you can have more context of how this was born:
- Issue: https://github.com/bitcraze/crazyflie-f ... issues/446
- PR: https://github.com/bitcraze/crazyflie-f ... /483/files

Both have some level of description of the papers which were used as background, and also the papers mention the Parrot platform from which the code was inspired.

You should start there. If you still can't understand what is wrong and try to fix the bug with a PR, then in order for others to help, we would need more details on how to reproduce your exact situation, as you are the one holding the test case.

Also, have you run the calibration processes for the INDI controller?

Cheers,

André
volmen3
Beginner
Posts: 11
Joined: Sat Nov 30, 2019 12:21 pm

Re: INDI Controller Outer + Inner loop problems

Post by volmen3 »

Hey Max,

I can not really help you with the problem on how to provide commands to the outer loop through the setpoint interface. While implementing the outer loop, I had myself difficulties to understand the differences and the correct usage of those multiple modes. So, when testing the controller algorithm, I was directly inputing reference commands to the outer loop through the crazyflie client, by manually enabling the outer loop ( setting outerLoopActive = true).

However, just before merging the outer loop with the rest of the crazyflie firmware, @kimberly adjusted the interface, such that one could provide reference values through the python script. This is explained at the end of this pull request:
https://github.com/bitcraze/crazyflie-f ... -821004070

I would suggest you to firstly read the information in the pull request, since it touches some of the implementation details and explains at the end how to control the crazyflie with Python.

Best regards
Eugen
Max_Kemmeren
Member
Posts: 40
Joined: Wed Jan 20, 2021 4:03 pm

Re: INDI Controller Outer + Inner loop problems

Post by Max_Kemmeren »

Hi Andre,

Thanks for the response. What exactly do you mean with the calibration processes?

Greetings
Max
dedecun wrote: Fri Apr 16, 2021 10:15 am Hi, Max.

The INDI controller was implemented a while ago, and honestly we used it in only one application. This is only the second time someone reaches to talk about it, which is definitely a good sign, even though experiencing problems.

First step is to tell you this implementation has been completely inspired in a pre-existing implementation from a different platform, which does not mean we can still find bugs.

Have you tried to follow the steps from the issue and the PR the gave birth to this controller? I would recommend you to study them a bit, so you can have more context of how this was born:
- Issue: https://github.com/bitcraze/crazyflie-f ... issues/446
- PR: https://github.com/bitcraze/crazyflie-f ... /483/files

Both have some level of description of the papers which were used as background, and also the papers mention the Parrot platform from which the code was inspired.

You should start there. If you still can't understand what is wrong and try to fix the bug with a PR, then in order for others to help, we would need more details on how to reproduce your exact situation, as you are the one holding the test case.

Also, have you run the calibration processes for the INDI controller?

Cheers,

André
dedecun
Beginner
Posts: 15
Joined: Tue Jul 02, 2019 1:43 pm

Re: INDI Controller Outer + Inner loop problems

Post by dedecun »

The parameters used in the filtering of the angular acceleration need to be estimated from the model itself. I have included tools for doing so, they can be found mainly in the `tools/param_est` folder. You will certainly need to dig in the theory behind the controller a little bit more to understand why and how this should happen.
Max_Kemmeren
Member
Posts: 40
Joined: Wed Jan 20, 2021 4:03 pm

Re: INDI Controller Outer + Inner loop problems

Post by Max_Kemmeren »

Thanks! Ah you mean the control effectiveness parameters from the inner loop. Yes for my thesis my supervisor is Ewoud Smeur, thus I can ask anything I do not understand from the INDI to him. For the rest thanks for helping!
dedecun wrote: Tue Apr 20, 2021 6:45 pm The parameters used in the filtering of the angular acceleration need to be estimated from the model itself. I have included tools for doing so, they can be found mainly in the `tools/param_est` folder. You will certainly need to dig in the theory behind the controller a little bit more to understand why and how this should happen.
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: INDI Controller Outer + Inner loop problems

Post by kimberly »

Also thanks @dedecun and @volmen3 for reacting so quickly and helping out!
dedecun
Beginner
Posts: 15
Joined: Tue Jul 02, 2019 1:43 pm

Re: INDI Controller Outer + Inner loop problems

Post by dedecun »

Really? Your supervisor is Dr. Ewoud Smeur? OK, you should have started there, my friend, hahahahaha. This is very important context to give.

Alright, you are in a position better than anyone else to fix anything here. You can talk directly to the Oracle :)

Also, this implementation was completely inspired in one other implementation from him in another platform, as I said. So you are now in a position to make a real contribution here if there are any bugs, and this will be a lasting and important contribution if there is.

I suggest you talk Dr. Smeur, ask him to give you the source of his implementation in the Parrot Platform, and check the implementation details to see if you can find any errors. I will be around to support you if you have specific doubts, but it will really pay off to have new eyeballs on this.
Max_Kemmeren
Member
Posts: 40
Joined: Wed Jan 20, 2021 4:03 pm

Re: INDI Controller Outer + Inner loop problems

Post by Max_Kemmeren »

Haha sorry. I know the other implementation is on the parrot Bebop. For what I can find know it seems to be a mix of filtering cutoff frequency and the inner loop gains, that cause some instability in the inner loop.

Some other points, the consistency in units is a bit lacking. When the inner loop is stable I will try and make all units in the INDI code consistent. Such that everything is in radians when it comes in etc. Moreover I might add some comments behinds variables with the units such that people can immedeately tell what units are used.
Post Reply