controls  3.0.0
ThrustAllocation6DOFQPSolver.h
Go to the documentation of this file.
1 #ifndef CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_6DOF_QP_SOLVER_H
2 #define CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_6DOF_QP_SOLVER_H
3 
6 #include <eigen-quadprog/QuadProg.h>
7 
8 #include <vector>
9 
19 protected:
22 
24  std::vector<int> thrustersIdxMapping;
25 
28 
30  std::vector<Thruster> sorted_thrusters;
31 
33  MatrixXd Aeq;
34 
36  MatrixXd Aineq;
37 
39  VectorXd Bineq;
40 
42  VectorXd C;
43 
45  MatrixXd Q;
46 
48  Eigen::QuadProgDense qp;
49 
55  void buildQPMatrices(const MatrixXd& T_full);
56 
63  void setBineq(float min_force, float max_force);
64 
65 public:
67 
73  void build(const ThrusterLayout& layout) override;
74 
82  VectorXd allocate(const Vector6d& tau) override;
83 
91  Vector6d getBodyForce(const VectorXd& thrusterForces) override;
92 
99  void setQ(double val, uint8_t axis) override;
100 
107  void updateLimits(float min_force, float max_force) override;
108 };
109 
110 #endif // CONTROLS_ALLOCATOR_SOLVER_THRUST_ALLOCATION_6DOF_QP_SOLVER_H
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Types.h:29
Quadratic-programming thrust allocator for full 6DOF underwater vehicles.
Definition: ThrustAllocation6DOFQPSolver.h:18
std::vector< int > thrustersIdxMapping
Maps QP variable index i to the global thruster idx.
Definition: ThrustAllocation6DOFQPSolver.h:24
Vector6d getBodyForce(const VectorXd &thrusterForces) override
Reconstructs the achieved 6DOF body force from per-thruster forces.
Definition: ThrustAllocation6DOFQPSolver.cpp:114
std::vector< Thruster > sorted_thrusters
Thrusters sorted by idx for deterministic column ordering.
Definition: ThrustAllocation6DOFQPSolver.h:30
MatrixXd Aeq
6x(N+6) equality-constraint matrix [T_full | I_6]
Definition: ThrustAllocation6DOFQPSolver.h:33
void setBineq(float min_force, float max_force)
Updates the inequality RHS vector with new per-thruster force bounds.
Definition: ThrustAllocation6DOFQPSolver.cpp:78
int numThrusters
Number of thrusters in the current layout.
Definition: ThrustAllocation6DOFQPSolver.h:21
void updateLimits(float min_force, float max_force) override
Updates the per-thruster force bounds for the QP inequality constraints.
Definition: ThrustAllocation6DOFQPSolver.cpp:132
void setQ(double val, uint8_t axis) override
Sets the slack-variable penalty weight for a given body axis.
Definition: ThrustAllocation6DOFQPSolver.cpp:136
void build(const ThrusterLayout &layout) override
Builds QP matrices and initialises the solver from a thruster layout.
Definition: ThrustAllocation6DOFQPSolver.cpp:8
MatrixXd Q
(N+6)x(N+6) quadratic cost matrix (thruster effort + slack penalties)
Definition: ThrustAllocation6DOFQPSolver.h:45
ThrusterLayout layout
Copy of the layout passed to build()
Definition: ThrustAllocation6DOFQPSolver.h:27
void buildQPMatrices(const MatrixXd &T_full)
Builds the equality and inequality QP matrices from the allocation matrix.
Definition: ThrustAllocation6DOFQPSolver.cpp:54
MatrixXd Aineq
2Nx(N+6) inequality-constraint matrix encoding per-thruster bounds
Definition: ThrustAllocation6DOFQPSolver.h:36
Eigen::QuadProgDense qp
Dense QP solver instance.
Definition: ThrustAllocation6DOFQPSolver.h:48
VectorXd Bineq
2N-element inequality right-hand side vector
Definition: ThrustAllocation6DOFQPSolver.h:39
VectorXd allocate(const Vector6d &tau) override
Solves the 6DOF QP and returns per-thruster force magnitudes.
Definition: ThrustAllocation6DOFQPSolver.cpp:90
VectorXd C
Linear cost vector (zero for pure quadratic minimisation)
Definition: ThrustAllocation6DOFQPSolver.h:42
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