controls  3.0.0
ThrustAllocation3DOFQPSolver.h
Go to the documentation of this file.
1 #ifndef CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_3DOF_QP_SOLVER_H
2 #define CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_3DOF_QP_SOLVER_H
3 
6 #include <eigen-quadprog/QuadProg.h>
7 
8 #include <vector>
9 
21 protected:
24 
26  std::vector<int> thrustersIdxMapping;
27 
30 
32  std::vector<Thruster> sorted_thrusters;
33 
35  MatrixXd T_full;
36 
38  MatrixXd Aeq;
39 
41  MatrixXd Aineq;
42 
44  VectorXd Bineq;
45 
47  VectorXd C;
48 
50  MatrixXd Q;
51 
53  Eigen::QuadProgDense qp;
54 
60  void buildQPMatrices(const MatrixXd& T_full);
61 
68  void setBineq(float min_force, float max_force);
69 
70 public:
72 
78  void build(const ThrusterLayout& layout) override;
79 
87  VectorXd allocate(const Vector6d& tau) override;
88 
96  Vector6d getBodyForce(const VectorXd& thrusterForces) override;
97 
107  void setQ(double val, uint8_t axis) override;
108 
115  void updateLimits(float min_force, float max_force) override;
116 };
117 
118 #endif // CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_3DOF_QP_SOLVER_H
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Types.h:29
Quadratic-programming thrust allocator for 3DOF (X, Y, Yaw) surface vehicles.
Definition: ThrustAllocation3DOFQPSolver.h:20
ThrusterLayout layout
Copy of the layout passed to build()
Definition: ThrustAllocation3DOFQPSolver.h:29
int numThrusters
Number of thrusters in the current layout.
Definition: ThrustAllocation3DOFQPSolver.h:23
Vector6d getBodyForce(const VectorXd &thrusterForces) override
Reconstructs the achieved 6DOF body force from per-thruster forces.
Definition: ThrustAllocation3DOFQPSolver.cpp:107
Eigen::QuadProgDense qp
Dense QP solver instance.
Definition: ThrustAllocation3DOFQPSolver.h:53
VectorXd allocate(const Vector6d &tau) override
Solves the 3DOF QP and returns per-thruster force magnitudes.
Definition: ThrustAllocation3DOFQPSolver.cpp:84
MatrixXd Aeq
3x(N+3) equality-constraint matrix [T_xy_yaw | I_3]
Definition: ThrustAllocation3DOFQPSolver.h:38
void build(const ThrusterLayout &layout) override
Builds QP matrices and initialises the solver from a thruster layout.
Definition: ThrustAllocation3DOFQPSolver.cpp:8
MatrixXd Q
(N+3)x(N+3) quadratic cost matrix (thruster effort + slack penalties)
Definition: ThrustAllocation3DOFQPSolver.h:50
void updateLimits(float min_force, float max_force) override
Updates the per-thruster force bounds for the QP inequality constraints.
Definition: ThrustAllocation3DOFQPSolver.cpp:119
MatrixXd T_full
Full 6xN allocation matrix retained for getBodyForce()
Definition: ThrustAllocation3DOFQPSolver.h:35
void buildQPMatrices(const MatrixXd &T_full)
Builds the equality and inequality QP matrices from the allocation matrix.
Definition: ThrustAllocation3DOFQPSolver.cpp:51
VectorXd C
Linear cost vector (zero for pure quadratic minimisation)
Definition: ThrustAllocation3DOFQPSolver.h:47
std::vector< Thruster > sorted_thrusters
Thrusters sorted by idx for deterministic column ordering.
Definition: ThrustAllocation3DOFQPSolver.h:32
void setBineq(float min_force, float max_force)
Updates the inequality RHS vector with new per-thruster force bounds.
Definition: ThrustAllocation3DOFQPSolver.cpp:75
std::vector< int > thrustersIdxMapping
Maps QP variable index i to the global thruster idx.
Definition: ThrustAllocation3DOFQPSolver.h:26
VectorXd Bineq
2N-element inequality right-hand side vector
Definition: ThrustAllocation3DOFQPSolver.h:44
MatrixXd Aineq
2Nx(N+3) inequality-constraint matrix encoding per-thruster bounds
Definition: ThrustAllocation3DOFQPSolver.h:41
void setQ(double val, uint8_t axis) override
Sets the slack-variable penalty weight for a 3DOF-relevant axis.
Definition: ThrustAllocation3DOFQPSolver.cpp:123
Abstract interface for quadratic-programming thrust allocation solvers.
Definition: ThrustAllocationSolverInterface.h:15
Manages a collection of Thruster objects and builds the allocation matrix.
Definition: ThrusterLayout.h:11