|
Simulating the Helicopter
In order to better develope and debug the flight control system,
we've extended Aaron Kahn's aerodynamical simulator that he used
for his X-Cell 60 project. The
original source code
and
expanded version
were written for Windows +
OpenGL;
we've converted it to work with Linux and our
IMU / AHRS
and
control board.
Our
source code
is available as
Free Software.
A packaged tar file is available for
download
(get Release 2.2).
The graphics aren't photorealistic, but the model includes the aerodynamic
effects of the horizontal and vertical tail surfaces, engine torque,
swashplate non-linearity, inertia, transmission power loss, translational
lift and many, many other factors. These constants are specified in
the init_model() routine in
model.cpp.
As a compile time option, you can select an
HH60
or
HH65
model for the display. This helps with orientation and visual presentation,
but does slow down the frame rate for the display model.
Models are extracted from
Search and Rescue
with permission.
The roadmap:
-
The first step is to get the software working with a joystick and
manual control. Most of the code is already there, although it needed
to be ported from Aaron's Windows version to use the Linux joystick
interface.
This code is in place in
heli-stick.c,
although it is not very polished at this time. It requires that the
limits on each axis be set in the limits[] array. The included
calibrate
program prints out this array for it.
This was based on the earlier joystick parsing code in the
efis
package:
test-joystick.c
and
Joystick.pm.
All three axes are debugged and working now. You can fly the helicopter
around with the joystick and generally have fun. If you crash, the
aircraft rights itself and gives you another chance.
-
The second step is to extract the IMU-related data from the simulator
model and feed it to our control code. We can begin giving different
flight controls to the software as we develop the different axes.
Rather than require a human pilot to operate the remaining controls,
it is possible to "lock" them in place and have the model ignore
those axes.
The
hover.c
program can now handle all three axes and six degrees of freedom. It will
position the helicopter at (0,0) and 2m off the ground, then hold it there.
The internal algorithm is a PD loop for pitch and roll attitude, with a
PID loop for position control. You can watch an
MPEG of it hovering
(266 kb). You can also view
a graph of the North/East parameters
and
a graph of the flight path.
After getting the PID constants tuned, noise will be introduced into the
"sensor" data. The
Kalman filter
should be able to cope with this. It will better model the data produced
by the actual IMU.
-
The third step will be to feed the simulated IMU data to the AVR in
real time and have our control board run the software. This will
help us determine if the 4 Mhz microcontroller is fast enough at
doing the Kalman filtering to safely fly the helicopter.
-
And the fourth step is to actually put the system onto the helicopter.
We should be flying by then...
|