The controller
The controller can be any application capable of reading TCP sockets and reading/writing to Advantage PCI 1711/1720 cards. The current controller is implemented in Matlab. It uses pnet sockets, matlab timer function and DAQ analog input/output objects.
Overview of the application
This application is implemented to be generic enough to allow manual control, identification experiments and control experiments. The entry point is a Matlab script which initializes everything and starts a timer object. This timer executes every 30th of a second. It takes care of reading and writing all the data and calling the user function, the controller strictly speaking. The following figure depicts the structure and main procedures of this application.

It is not necessary to understand everything in the application to be able to perform most of the experiments. Only the interface with the user control function would be essential.
User control function interface
The user control function has the following definition
function [mvCol,mvAnti,mvLat,mvLong] = control(t,x,y,z,pitch,yaw,roll,col,anti,cLat,cLong)
The variables it uses have the following meanings
output variables <--- they will all be written to the RC controller and sent to the helicopter mvCol is collective mvAnti is antitorque mvLAt is lateral cyclic mvLon is longitudinal cyclic
input variables <--- they have all been read from the sensor application or the RC controller t is time as calculated by Matlab, might differ from time as calculated by the sensor x,y,z is the helicopter measured center of gravity position in meters. The coordinate system is centered in the middle of the CCD of the left camera, x pointing right, y pointing down and z pointing in front of it. pitch,yaw,roll is the helicopter measured attitude in degrees col,anti,cLat,cLong are collective, antitorque and lateral and longitudinal cyclics readings from the joysticks of the RC controller
User control function use cases
Three typical use cases are considered here. First one is the data recording case, in which the user wants to fly the helicopter manually and save all the data to a file. The second one is the identification case, in which the user wants to inject predesigned signals to one or more inputs of the helicopter but still maintain manual control of it. The third case is the fully automatic control of one or more variables.
Data recording user control function
function [mvCol,mvAnti,mvLat,mvLong] = control(t,x,y,z,pitch,yaw,roll,col,anti,cLat,cLong) mvCol = col; mvAnti = anti; mvLat = cLat; mvLong = cLong;
Identification user control function
Noise is added to the collective joystick reading every 15 executions, i.e. twice a second.
function [mvCol,mvAnti,mvLat,mvLong] = control(t,x,y,z,pitch,yaw,roll,col,anti,cLat,cLong)
persistent i
if isempty(i)
i = 0;
end
if (mod(i,15)==0)
noise = (rand()-0.5)*0.4;
end
mvCol = col + noise;
mvAnti = anti;
mvLat = cLat;
mvLong = cLong;
Automatic control user control function
The antitorque output is calculated from an error proportional control action. As long as set points are preprogrammed trajectories or constants they are easily given this way. In this case the yaw set point is obtained from the base workspace of Matlab.
function [mvCol,mvAnti,mvLat,mvLong] = control(t,x,y,z,pitch,yaw,roll,col,anti,cLat,cLong)
persistent Kp
if isempty(Kp)
Kp = 1.2;
spYaw = evalin('base', 'yawSetPoint'); % yaw set point
end
mvCol = col;
mvAnti = Kp*(spYaw-yaw);
mvLat = cLat;
mvLong = cLong;