Frankenpilot the Homemade Autopilot - Tillerpilot Ram

          -K[igain][2]*headingdot + K[igain][3]*head_error_int; //units are volts

The gains are calculated using a LQR design technique.  This was my friend Bryan's idea, and it is a nice way to go.  With LQR you can trade how fast your system responds to disturbances with how much power you put into the actuator.  If I was to sail to Hawaii the power budget would be pretty important, and I might want a minimally-steering autopilot, but in big waves I might be willing to use more power in an aggressively-steering autopilot.  I pre-calculated 10 gain sets that vary from super-low-power to very-aggressive-rudder-hammer.  Matlab makes this simple if you have a dynamic model.  I can change the gain set on the fly to whatever seems appropriate.  The igain variable in the equation above contatins the gain setting; the other index is which state the gain goes with.  I'm still working on the best gains to use, and also using logged data to create a dynamic model for my boat.

There are some modifications to the basic LQR scheme.  Since a regulator tries to drive the states to zero, heading error is used in place of the heading state (or else the autopilot would only steer North!).  The commanded heading can be changed with button presses, but it ramps from one setpoint to the next to give the boat a chance to keep up.  The integrated error is reset to zero when large heading changes are commanded, and the integration is halted if the motor is at its max voltage or the rudder is hard over.  The integration feedback is necessary to trim steady-state errors but it is destabilizing so you need to be careful with the calculations.


Here is some data from sailing the boat.

This plot shows commanded heading and actual heading as the boat sailed downwind on a gusty day.  I had a single reef in the main and the spinnaker up; I was singlehanding.  I think the oscillations are the waves making the boat turn, but I need to log the pitch and roll of the boat to see for sure.  I only tried one gain setting too-- if I had tried some more it might be clearer whether the autopilot is oscillating or the boat.  In any case, the boat steered itself just great: I was able to jibe, adjust the heading command for the wind shifts, and I let the autopilot drive the whole time.

Here's some upwind data from the same day.  I had to really work hard on the buttons to keep the boat on the wind as it shifted and the gusts came down.  I was a little overpowered with only me hiking out, and I was working the traveller and mainsheet actively to keep the boat trimmed, so the autopilot had plenty to do.  The time scale is zoomed out relative to the plot above.  The autopilot was driving the tacks you see too.

 

 

  

Random Images

remote_boxfrnt.jpg
screenshot.jpg