controls  3.0.0
Types.h
Go to the documentation of this file.
1 #ifndef CONTROLS_UTILS_TYPES_H
2 #define CONTROLS_UTILS_TYPES_H
3 
4 #include <cmath>
5 #include <eigen3/Eigen/Core>
6 #include <eigen3/Eigen/Geometry>
7 
8 // ROS message types
9 #include <bb_controls_msgs/msg/thruster_forces.hpp>
10 #include <geometry_msgs/msg/pose_array.hpp>
11 #include <geometry_msgs/msg/twist_stamped.hpp>
12 #include <geometry_msgs/msg/wrench_stamped.hpp>
13 #include <nav_msgs/msg/odometry.hpp>
14 #include <optional>
15 
16 // Fixed-size matrix types
17 using Eigen::Matrix2d;
18 using Eigen::Matrix3d;
19 using Matrix4d = Eigen::Matrix<double, 4, 4>;
20 using Matrix6d = Eigen::Matrix<double, 6, 6>;
21 
22 // Dynamic-size matrix type
23 using Eigen::MatrixXd;
24 
25 // Fixed-size vector types
26 using Eigen::Vector2d;
27 using Eigen::Vector3d;
28 using Vector4d = Eigen::Matrix<double, 4, 1>;
29 using Vector6d = Eigen::Matrix<double, 6, 1>;
30 using Vector18d = Eigen::Matrix<double, 18, 1>;
31 
32 // Dynamic-size vector type
33 using Eigen::VectorXd;
34 
35 // Quaternion type
36 using Eigen::Quaterniond;
37 
38 // Array types
39 using Eigen::ArrayXd;
40 using Array6d = Eigen::Array<double, 6, 1>;
41 
42 constexpr double RAD2DEG = 180.0 / M_PI;
43 constexpr double DEG2RAD = M_PI / 180.0;
44 constexpr double M_2PI = 2.0 * M_PI;
45 
49 struct Pose {
51  Vector3d position = Vector3d::Zero();
52 
54  Quaterniond orientation = Quaterniond::Identity();
55 };
56 
63 struct State {
66 
68  Vector6d twist = Vector6d::Zero();
69 
71  Vector6d acceleration = Vector6d::Zero();
72 };
73 
80 struct DebugMessage {
82  std::optional<double> t;
83 
85  std::optional<geometry_msgs::msg::PoseArray> traj_viz;
86 
88  std::optional<Vector6d> controller_force;
89 
91  std::optional<Vector6d> allocator_force;
92 
94  std::optional<bb_controls_msgs::msg::ThrusterForces> thruster_forces;
95 };
96 
97 #endif // CONTROLS_UTILS_TUPES_H
constexpr double DEG2RAD
Definition: Types.h:43
constexpr double M_2PI
Definition: Types.h:44
Eigen::Array< double, 6, 1 > Array6d
Definition: Types.h:40
Eigen::Matrix< double, 6, 6 > Matrix6d
Definition: Types.h:20
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Types.h:29
Eigen::Matrix< double, 4, 1 > Vector4d
Definition: Types.h:28
Eigen::Matrix< double, 18, 1 > Vector18d
Definition: Types.h:30
constexpr double RAD2DEG
Definition: Types.h:42
Eigen::Matrix< double, 4, 4 > Matrix4d
Definition: Types.h:19
Aggregates optional debug data produced each control-loop tick.
Definition: Types.h:80
std::optional< bb_controls_msgs::msg::ThrusterForces > thruster_forces
Per-thruster force magnitudes in Newtons.
Definition: Types.h:94
std::optional< geometry_msgs::msg::PoseArray > traj_viz
Sampled trajectory poses for RViz visualisation.
Definition: Types.h:85
std::optional< Vector6d > controller_force
6DOF body-frame force output by the controller (N / Nm)
Definition: Types.h:88
std::optional< Vector6d > allocator_force
6DOF body force actually achieved after thrust allocation
Definition: Types.h:91
std::optional< double > t
ROS timestamp of this message in seconds.
Definition: Types.h:82
6DOF rigid-body pose as a 3D position and unit quaternion orientation
Definition: Types.h:49
Vector3d position
3D position in the world frame (x, y, z) in metres
Definition: Types.h:51
Quaterniond orientation
Orientation as a unit quaternion (w, x, y, z)
Definition: Types.h:54
Full kinematic state of the vehicle.
Definition: Types.h:63
Vector6d acceleration
Body-frame acceleration [ax, ay, az, αx, αy, αz] in m/s² and rad/s²
Definition: Types.h:71
Pose pose
6DOF pose (position + orientation) in the world frame
Definition: Types.h:65
Vector6d twist
Body-frame velocity [u, v, w, p, q, r] in m/s and rad/s.
Definition: Types.h:68