How to design a PID controller for boat?

I have a boat with two trusters and a trajectory planner which is based on the bicycle model. In order to control the boat, the linear velocity of each truster has to be provided.

The following information is known for trajectory tracker: position $$P_d$$, linear velocity $$v_d$$,and desired yaw angle $$\theta_d$$ and desired yaw rate $$\omega_d$$

The following information is known for the boat: current position $$P_a$$ and current yaw angle $$\theta_a$$ and yaw rate $$\omega_a$$

The objective is to navigate the boat according to the trajectory planner. I was trying to develop a PID controller. But still no luck. The following steps have been carried out, not sure exactly what is the correct way to achieve this?

PID controller

$$v = k_p(P_d - P_a) - k_d v_a, \quad \omega = k_a(\theta_d-\theta_a) - k_v \omega_a$$

Control signals (left and right velocities):

$$v_l = v - k_1\omega, \quad v_r = v + k_1 \omega$$, where $$k_1$$ is a constant.

If a PD controller can not be used for the boat, could someone suggest to me what kind of way to control the boat?

• 1) your PID controller for v feels incorrect. Pd, Pa and va are not defined. Jun 4 at 18:36
• 2) the PID equation for w is a bit off, the subscripts notation is misleading perhaps. Jun 4 at 18:37
• 3) vl and vr should probably read "vl = v- k1w; vr = v+ k1w" Jun 4 at 18:38
• PD (or PID) controller should be fine to control a boat. Jun 4 at 18:39
• @GürkanÇetin thanks for noticing the mistakes, corrected it Jun 4 at 20:23

It should be perfectly fine to control the boat with two thrusters (i.e. propellers with some distance in between them), via a PID control scheme. To compensate for ambiguities in the model and the real world (e.g. streams, wind, thruster inequalities, etc) integral terms are required, but I didn't include them in the following answer. :)

Your definition of velocity controller seems incorrect, in the derivative term.

define PositionError = Pdesired - Pactual;
define DerivativeOfPositionError = (PositionError - PreviousPositionError)/deltaTime
v_temporary = Kp * (PositionError) + Kd * (DerivativeOfPositionError)


Btw, Position should be a vector (of latitude and longitude) but I'm leaving it to you(or others) to work out the geometric relationships (of position and yaw angle). The question is about the Controller not the Navigator, as far as I understand.

// the naming of w is somewhat misleading, so name it YawControl
YawControl = Kp_yaw * (Theta_desired - Theta_actual) + Kp_yawRate * (w_desired - w_actual)


Important Note: There are two different (and related) variables being controlled with a single control command. This assumes that YawRate demand (w_desired) coming from the trajectory controller is consistent and convergent. Otherwise, the solution might not converge, i.e. the boat can oscillate around a Heading.

The rest is OK. You simply assign YawControl to left and right thrusters, with a scale factor, k1.

• sure, I will check and let you know Jun 13 at 6:14