Hi Brian!

A few thoughts.

The IMU measures acceleration and rotation. Assume the IMU is centrally placed, with its Y-axis along the hull (bow is positive) and X-axis is across the hull (starboard positive). Z-axis rotations are the hull yawing. To keep it simple, we're only interested in these three things - disregard Z-axis motion and other axes' rotation (due to wave action, pitching and rolling in a sea).

If your loop queries the IMU at, say, a hundred checks per second, you'll get two lots of quite accurate acceleration information, and one of rotation.

How to use this data?

The area under a graph of acceleration/time is the velocity. This is not particularly interesting. However, the area under a graph of velocity/time is a displacement, a distance, and this is **very** interesting. We want to work the anchor handler to minimise/cancel out any displacements from our zero position.

So here's some pseudo code - you'd need to do this for both the x and y axes:

time = time since last checked

x_acn1 = IMU's current x-axis acceleration

x_vel1 = time * (x_acn1 - x_acn0)/2

x_displacement = time * (x_vel1 - x_vel0)/2

**stuff here**

x-acn0 = x_acn1

x_vel0 = x_vel1

...and repeat.

'Stuff here'?

The image shows our original position, that is, the point at which the system was switched on **P**_{0}, and our current position at any point in time **P**_{1}.

Since we can calculate the x and y displacements, and the current z-axis rotation, we can drive the boat back to P_{0}.

All angles are measured clockwise from the positive y-axis and best worked in radians.

**alpha **is the angle of our displacement. It's given by **pi/2-ATAN2(dx,dy)**.

**beta** is the hull rotation (heading).

So the angle we need to drive the boat (from the boat's point of view) is **pi+alpha-beta**. Let's call it** gamma**.

Given the layout of the proposed model, I suspect you'd rig the bow thrusters to correct for beta, and the three azipods to drive the hull along gamma.

As the heading changes over time, back to zero, gamma will change.

Now, the beauty of this is that, at high sample rates (fast loop times) the displacements will be far smaller than that shown in the diagram. I suspect your azipods' props will be barely turning (the bulk of their work will be in changing the angle of thrust).

And - perhaps - there lies the real problem. It would take some experimentation to determine the best angles for the azipods to move the vessel in the desired gamma, but a *close guess* around the compass might be enough, because the system will constantly be monitoring and measuring its current **P**_{1}.

Andy