A 4 channel, fixed-pitch, RC helicopter is a good analogy for my VTVL rocket. Both vehicles control altitude by changing the magnitude of the thrust vector and both vehicles control attitude by changing the direction of the thrust vector. On the rocket, the magnitude of the thrust vector is controlled by opening and closing the main propellant valves. On a fixed-pitch helicopter, an ESC controls how fast the main rotor spins. On the rocket, the direction of the thrust vector is controlled by gimbaling the motor via linear actuators. On the helicopter, servos connected to the swashplate cyclically pitch the main rotor blades. Paul Breed used a T-Rex 600 to test his GNC software and extensively documented the process on his blog.
I purchased a Blade 200 SR X, extra blades, extra battery, and a simulator; my plan is to create control hardware and software for the helicopter that can be ported to the rocket. Most of the past week has just been learning to fly the simulator, but I did put some effort into hardware. A nice thing about the Blade 200 SR X is it uses conventional hobby servos and ESCs (many of the small helis have dedicated boards which serve as receiver, ESC, and servo) so it’s easy to control with a microcontroller. However, I didn’t know that ESCs have to be armed before you can send them a PWM control signal. On my helicopter, firmware in the receiver sends the ESC the arm command a few seconds after it powers on. This is what the receiver sends the ESC to arm:
The frequency is 344 Hz and the duty cycle is 34.4%. I created this pulse train using an Uno and the digitalWrite() and delayMicroseconds() functions and successfully armed the ESC.
IMUs and State Observer
The VTVL rocket has 12 states (6DOFs plus the time derivative of each DOF) and I need an estimate or reliable measurement of each state in order to control the rocket. Plan A is to obtain yaw, pitch, and roll from an IMU, position and altitude from GPS, and the rest of the states from a state observer. Masten and Armadillo flew KVH and Crossbow IMUs built around fiber optic gyroscopes. These units retail for more than $10,000 and are prohibitively expensive. Several companies (VectorNav, Xsens, LORD MicroStrain) sell IMUs based on MEMS sensors, which fuse magnetometer, accelerometer, and gyroscope readings together via a Kalman filter to produce reliable estimates of yaw, pitch, and roll. These units retail for at least $1,000, which is still a little expensive for my tastes.
Last winter I started experimenting with Fabio Varesano’s FreeIMU. I built a few of them (my first time with SMD components) and they worked pretty well, but I couldn’t get rid of the yaw drift. The FreeIMU has good hardware, so I’m going to try to write my own sensor fusion code based on TJ Bordelon’s FreeSpace algorithm.
TJ uses a three-axis accelerometer, a three-axis magnetometer, and a three-axis gyroscope, and fuses them together in three steps.
- Integrate the gyro output to obtain a quaternion which rotates you from the body-fixed frame to the earth-fixed frame. This quaternion is incorrect because of the gyroscope bias. The calculated attitude will drift over time.
- Measure the acceleration in the body-fixed frame and rotate it to the world-fixed frame using the quaternion from Step 1. The answer should be [0 0 1] g. Use the difference between [0 0 1] and the calculated world-fixed acceleration to correct your quaternion. This step compensates for errors in pitch and roll.
- Measure magnetic field in the body-fixed frame and rotate it to the world-fixed frame using the quaternion from Step 2. The compass should be pointing North, [1 0 0]. Use the difference between [1 0 0] and the the calculated world-fixed magnetic field to correct the quaternion. This step compensates for error in yaw (or heading).
The amount of money Masten and Armadillo spent on their IMUs speaks to their importance. But my goal is a 30 second flight, not a 180 second NGLLC Level 2 flight, and I’m cautiously optimistic that 30 seconds is short enough to make my homemade MEMS solution viable. If hobby-grade sensors don’t work, Plan B is the VectorNav VN-100 Rugged DevKit for $1000.