Documentation

/NGOS

/Signals

/Shells

/Cmds

/Ctrl

/HALs

/Conf

/Params

/Behaviors

/Receiver

/GPS

Next Chapter

The NG Controllers

The Controller Concept of the NG

Introduction

A Quadcopter only flies as good as its algorithms allow. Since the QC system is inherently unstable the closed-loop control algorithm is of most importance.

People tend to have different ideas about the right algorithms. In order to allow people to implement different algorithms and to help compare them we designed the NG controller framework.

Concept

From an algorithms view the framework essentially encapsulates the whole NG OS. The algorithm is implemented in a funtion called process function and receives input data via an input structure (controller input structure), does its calculations on that data and then outputs its results to a second structure (controller output structure). It's doing this job by using a third structure (controller state structure). The framework makes sure the algorithm receives the sensor data, that it gets called regularly and that its output gets back to the actors. It also handles all the rest of the NG OS.

In short: The closed-loop control algorithm receives input, processes that input with the help of some state variables and then outputs the results.

Implementation

The implementation is quite simple. The controller framework itself essentially does the following in each closed-loop control step:

The ctrl_output function call outputs the controller output structure to the actors. The ctrl_input function call gets new sensor data into the controller input structure. The ctrl_process_func function call goes into the currently configured closed-loop control algorithm, which then does its magic.

The closed-loop control algorithm is represented by a C function in a C module called process function. The module also has access to three global structures, the controller input structure, the controller output structure and the controller state structure. The module itself exports a configuration variables table as a structure. The global and controller dependent variables can be easily accessed by two imported global structures. This assures the algorithm has all information it needs to do its magic and makes sure its output gets back to the actors.

The closed-loop controller algorithm function itself uses the global flight-state variable to use different behavior in the different flight-stages.

Extensions

A new controller can be implemented by adding a simple C module implementing the structures and function described above. The 'none' and the 'rc-test' controllers can be used as samples how to implement and add a new controller.

The implemented Controllers

The 'none' Controller

The 'none' controller is a very simple 'do nothing' controller. It can be used as a sample or as template for new controllers. It always outputs zero for the actors and so essentially does nothing.

The 'rc-test' Controller

The 'rc-test' controller is a very simple controller which just outputs the RC throttle directly onto the 4 motors. Essentially it just outputs the RC throttle four times as motor actor data.

The 'wolferl' Controller

The 'wolferl' controller is a proven controller. It's essentially Amir's interpretation of Wolfgang's closed-loop control algorithm used in the UAVP. It's a very good algorithm for hovering but does not perform very well in dynamic flight. Using the 1kHz closed-loop clock cycle it reaches very good performance when trying to point-hover or photograph.

The 'bearing' Controller

The 'bearing' controller is a Heading-Hold controller. It's implemented a bit differently than most other implementations in that it uses a PID controller for stabilization and not a PD controller. It does this by essentially switching off the I part when registering a movement and switching it back on as soon as the position should not change anymore. It works very well but is difficult to fly for beginners! Be warned!

The 'amir' Controller

The 'amir' controller is Amir's first try at a flight control algorithm. It is a combined linear Kalman / Complementary-Filter controller. Its workings are too difficult to explain here. It flies very good and allows stable hovering and dynamic flight. It's the most suited controller for beginners.

This controller supports attitude, orientation and height stabilization. No GPS support has been implemented yet.

The 'amir-ng' Controller

The 'amir-ng' controller is a Discrete Cosine Matrix (DCM) controller with Kalman drift compensation. It's the most complex of the current implementations. It flies very good and allows stable hovering and dynamic flight. It works for all angles irrelevant of the orientation of the FC. It also works upside down and at angles of exactly 90 degrees.

The DCM controller calculates the attitude and orientation information in the SO(3) manifold, the special orthogonal group of rotations. Rotations are a linear operation in the SO(3) manifold. This means that a linear Kalman filter, which is optimal for linear observations, is an optimal observer in SO(3). Using a DCM with Kalman drift compensation in the SO(3) manifold resulted in a very nice stabilization algorithm for attitude and orientation which works for all angles without any singularities or special cases.

This controller supports attitude, orientation, height and GPS position stabilization.

How to use different Controllers

The different controllers can be configured on the NG Shells. It's a simple set controller <ctrl> command to switch controllers. Each controller will have it's own controller dependant configuration variables. Some of them are shared between controllers because they represent the same parameters, some are not.

The needed Shell Commands

The needed NG shell commands are simple. You can switch closed-loop controller algorithms using the command set controller <name>. The command list ctrl lists all possible values for <name>. The variable controller is a normal controller dependent variable.

Behavior triggered Controller Change

There exists a behavior action which can change the configured controller. It is called ctrl.switch.ctrl(x). It can switch to the next or the previous controller or to a specific one.

Documentation/Controllers (last edited 2012-06-24 20:36:10 by kroimon)