# Feedback controller: Is there any influence between outer and inner loop when running at different frequencies?

I've develop a quadrotor (only simulation on my PC using ROS) and the feedback controller resumes more or less the following structure:

where you can think that process is the dynamic movement of the quadrotor (motion equations), the inner loop is the attitude controller (it just sets the orientation about all 3 axis) and the outer loop is the position controller that takes care where the quadrotor actually is. Why are they separated? Because in many papers I found out that the attitude controller (pitch, roll, yaw) need to run at higher frequency then any other controller in the system. The position controller instead needs to run at lower frequency.

The following picture is a better explanation of my description. Don't be scared...it is more simpler than one could think:

Now I did it as in the paper. BUT I discovered that my quadrotor was really unstable and I spent days and days trying to correct the gains of the controller without getting a stable system. My intuition said to me that maybe they are running at wrong frequency, so I put a different frequency values for the position controller being sure it is not a multiply of the main frequency (something like 1000Hz and 355 Hz for example.)

Lately I removed the timer in my program (C++) and let the position controller run at the same frequency as the attitude controller just because I run out of ideas and suddenly worked everything nice.

So here is my question. What should I consider when my system has an outer/inner controllers? How to be aware of that?

Regards and happy new year!!!

In short, there is no particular need for synchronization of inner and outer loops. The inner loop should run "fast enough" to control attitude dynamics and the outer loop should run "fast enough" to control translation dynamics. In my last quad the inner loop ran at 200Hz and the outer loop ran at a variable rate from 50Hz-100hz.

Typically, you shouldn't be trying to "tune" the loop frequencies. Once they are fast enough there is no further benefit to be had. In your case, I would carefully check the code to see what the inner loop controller is doing between outer loop controller updates. In most setups, it will just remember the last command from the outer loop and control to that.

To elaborate on the rationale for separate inner/outer loop controllers ...

As you noticed in papers, for quadrotors it is very common to have a separate inner loop (attitude) and outer loop (translation). One strong motivation for this has been the relative ease of attitude control and state estimation. The attitude subsystem is fully actuation and can be aggressively controlled for tight command tracking. Equally important, state estimation is generally quite accurate using a small 9-axis IMU (gyro + accel + mag).

When implemented correctly, this allows the outer loop to assume that it's attitude commands are tracked very tightly. The system now looks like a system where attitude acts like a traditional input. In this case, the translation subsystem also becomes fully actuated. For this to work, the inner loop typically needs to run much faster than translation dynamics. Conversely, this means the translation dynamics are relatively slow so the outer loop controller doesn't need to run very fast.

The biggest limitation for the outer loop is how quickly and accurately you can estimate the translation state. For fully autonomous systems, This is typically slow and not very accurate so you can't act aggressively.

One final note, from a control theory point of view most of the inner+outer loop controllers don't have stability guarantees; I've seen only one paper where they went through the effort for a similar control architecture. There are also several papers where they create advanced algorithms with stability analysis but those typically aren't work the effort to implement.

As short answer, the design of nested controllers proceeds normally from the inner/faster loop to the outer/slower loop. Hence, the outer controller is required to stabilize the "equivalent plant" composed of the actual plant along with the inner controller. In this stabilization design, of course, the frequency of the outer controller plays an important role. Generally speaking, therefore, it's not a matter of equating the two sample frequencies. Multi-rate controllers are quite widespread indeed.

To choose the sampling rate $f_s$ one should observe the following thumb rule: $$10\cdot f_c<f_s<40\cdot f_c,$$ where $f_c$ is the cross-over frequency of the system to control.

Motivations for this consideration can be found in this article (page 6).