|
| 1 | +# Thrust allocator |
| 2 | + |
| 3 | +The **Thrust Allocator** is responsible for distributing the generalized control forces $\tau \in \mathbb{R}^n$ to the actuators in terms of control inputs $u \in \mathbb{R}^r$. For linear systems this boils down to $\tau = Bu$, where B is the input matrix. The individual control inputs $u_i$ are later passed into thruster_interface_auv. |
| 4 | + |
| 5 | +# Notation |
| 6 | + |
| 7 | +The thrust allocation problem follows the notation of Fossen (2021), Ch. 11. |
| 8 | +The variables used in all allocation formulations (unconstrained, pseudoinverse, and QP) are: |
| 9 | + |
| 10 | +### Generalized forces and configuration matrix |
| 11 | + |
| 12 | +- $\tau \in \mathbb{R}^n$, Desired generalized force |
| 13 | + |
| 14 | +- $T_e$, Extended thruster configuration matrix |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +### Actuator forces and extended vectors |
| 19 | + |
| 20 | +- $f_e$, Extended force vector |
| 21 | + |
| 22 | +- $\bar{f}$ defined as, $\; -\bar{f} \le f_{e,i} \le \bar{f}$ is the scalar bound used for load balancing |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +### Weighting matrices and penalties |
| 27 | + |
| 28 | +- $W_f \succeq 0$, Weighting matrix on the extended force vector |
| 29 | + |
| 30 | +- $Q \succeq 0$, Weighting matrix on the slack vector $s$. |
| 31 | + |
| 32 | +- $\beta > 0$, Penalty weight on $\bar{f}$ used for load balancing (QP formulation). |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +### Constraints |
| 37 | + |
| 38 | +- $f_{\min}, f_{\max}$ Lower and upper bounds on the extended force vector $f_e$. |
| 39 | + |
| 40 | +# Interfaces |
| 41 | + |
| 42 | +- **[ThrusterInterface](https://github.com/vortexntnu/vortex-auv/tree/main/motion/thruster_interface_auv)** |
| 43 | + |
| 44 | +# Solvers |
| 45 | + |
| 46 | +### **Pseudoinverse Allocator** |
| 47 | + |
| 48 | +The pseudoinverse allocator follows the unconstrained weighted least–squares formulation |
| 49 | +given in Fossen (2021, Eq. 11.27): |
| 50 | + |
| 51 | +$$ |
| 52 | +J = \min_{f_e} \; ( f_e^\top W_f f_e ) |
| 53 | +\qquad \text{s.t.} \qquad |
| 54 | +\tau - T f = 0, |
| 55 | +$$ |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +#### **Generalized pseudoinverse (Fossen Eq. 11.35)** |
| 60 | + |
| 61 | +Solving the weighted least–squares problem leads to the **generalized pseudoinverse** |
| 62 | + |
| 63 | +$$ |
| 64 | +T_w^+ |
| 65 | += W_f^{-1} T_e^\top \left( T_e W_f^{-1} T_e^\top \right)^{-1}, |
| 66 | +$$ |
| 67 | + |
| 68 | +where $T_e$ is the extended configuration matrix used in the allocation. |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +#### **Right Moore–Penrose pseudoinverse (Fossen Eq. 11.36)** |
| 73 | + |
| 74 | +If the allocator uses **identity actuator weights**, |
| 75 | +i.e. $W_f = I$, then the generalized pseudoinverse simplifies to the **right Moore–Penrose pseudoinverse** |
| 76 | + |
| 77 | +$$ |
| 78 | +T^+ = T_e^\top (T_e T_e^\top)^{-1}. |
| 79 | +$$ |
| 80 | + |
| 81 | +For orca there was no big reason to weigh the different actuators since the drone will be using 8 of the same thruster. Therefore the pseudoinverse_allocator solution degenerates to the simpler Right Moore-Penrose pseudoinverse. |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +### **Constrained QP Allocator** |
| 86 | + |
| 87 | +The constrained thrust allocation problem is formulated as a quadratic program (QP) following |
| 88 | +Fossen (2021, Eq. 11.38). The optimization variables include the **extended force vector** $f_e$, |
| 89 | +a slack vector $s$, and the scalar load-balancing parameter $\bar{f}$. For our intents and purposes it |
| 90 | +the load balancing parameter will do more harm than good as different maneuvers require some thrusters |
| 91 | +to work hard whilst other thrusters to be at rest. |
| 92 | + |
| 93 | +### **Original Fossen Formulation (QP standard form)** |
| 94 | + |
| 95 | +$$ |
| 96 | +J = \min_{f_e,\, s,\, \bar{f}} |
| 97 | +\; ( f_e^\top W_f f_e + s^\top Q s + \beta \bar{f} ) |
| 98 | +$$ |
| 99 | + |
| 100 | +$$ |
| 101 | +\text{s.t.} \quad |
| 102 | +T_e f_e = \tau + s |
| 103 | +$$ |
| 104 | + |
| 105 | +$$ |
| 106 | +f_{\min} \le f_e \le f_{\max} |
| 107 | +$$ |
| 108 | + |
| 109 | +$$ |
| 110 | +-\bar{f} \le f_{e,i} \le \bar{f}. |
| 111 | +$$ |
| 112 | + |
| 113 | +### **Implemented QP Formulation (QP standard form)** |
| 114 | + |
| 115 | +$$ |
| 116 | +J = \min_{f_e,\, s} |
| 117 | +\; ( f_e^\top W_f f_e + s^\top Q s) |
| 118 | +$$ |
| 119 | + |
| 120 | +$$ |
| 121 | +\text{s.t.} \quad |
| 122 | +T_e f_e = \tau + s |
| 123 | +$$ |
| 124 | + |
| 125 | +$$ |
| 126 | +f_{\min} \le f_e \le f_{\max} |
| 127 | +$$ |
| 128 | + |
| 129 | +This QP formulation allows thrust limits, load balancing, soft constraint handling. |
| 130 | + |
| 131 | +# Testing |
| 132 | + |
| 133 | +If you wish to run the tests inside of the tests folder, run the following commands: |
| 134 | + |
| 135 | +#### 1. Build the package together with the tests. |
| 136 | + |
| 137 | +```bash |
| 138 | +colcon build --packages-select thrust_allocator_auv --cmake-args -DBUILD_TESTING=ON |
| 139 | +``` |
| 140 | + |
| 141 | +#### 2. Run colcon test. |
| 142 | + |
| 143 | +```bash |
| 144 | +colcon test --packages-select thrust_allocator_auv --event-handlers console_direct+ |
| 145 | +``` |
| 146 | + |
| 147 | +#### 3. print out the results with the --verbose flag. |
| 148 | + |
| 149 | +```bash |
| 150 | +colcon test-result --verbose |
| 151 | +``` |
| 152 | + |
| 153 | +# Debugging (CasADi) |
| 154 | + |
| 155 | +If the solver behaves unexpectedly it is possible to turn on CasADi's inbuilt spdlogs which show iterations, objective function value and report if the convergence was successful or not. |
| 156 | + |
| 157 | +```bash |
| 158 | +colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug |
| 159 | +``` |
0 commit comments