21 #ifndef INCLUDE_ROTORS_CONTROL_COMMON_H_ 22 #define INCLUDE_ROTORS_CONTROL_COMMON_H_ 28 #include <nav_msgs/Odometry.h> 56 const Eigen::Quaterniond& _orientation,
57 const Eigen::Vector3d& _velocity,
58 const Eigen::Vector3d& _angular_velocity) {
80 Eigen::Matrix4Xd* allocation_matrix) {
81 assert(allocation_matrix !=
nullptr);
82 allocation_matrix->resize(4, rotor_configuration.
rotors.size());
84 for (
const Rotor& rotor : rotor_configuration.
rotors) {
98 Eigen::FullPivLU<Eigen::Matrix4Xd> lu(*allocation_matrix);
100 lu.setThreshold(1e-9);
101 int rank = lu.rank();
103 std::cout <<
"The rank of the allocation matrix is " << lu.rank()
104 <<
", it should have rank 4, to have a fully controllable system," 105 <<
" check your configuration." << std::endl;
111 *skew_matrix << 0, -vector.z(), vector.y(),
112 vector.z(), 0, -vector.x(),
113 -vector.y(), vector.x(), 0;
117 *vector << skew_matrix(2, 1), skew_matrix(0,2), skew_matrix(1, 0);
static const std::string kDefaultOdometryTopic
static const std::string kDefaultCommandMotorSpeedTopic
Eigen::Vector3d vector3FromMsg(const geometry_msgs::Vector3 &msg)
static constexpr char COMMAND_ROLL_PITCH_YAWRATE_THRUST[]
static const std::string kDefaultCommandMultiDofJointTrajectoryTopic
Eigen::Vector3d angular_velocity
static constexpr char COMMAND_ACTUATORS[]
double rotor_moment_constant
static constexpr char ODOMETRY[]
static const std::string kDefaultImuTopic
void vectorFromSkewMatrix(Eigen::Matrix3d &skew_matrix, Eigen::Vector3d *vector)
EigenOdometry(const Eigen::Vector3d &_position, const Eigen::Quaterniond &_orientation, const Eigen::Vector3d &_velocity, const Eigen::Vector3d &_angular_velocity)
std::vector< Rotor > rotors
static constexpr char IMU[]
Eigen::Quaterniond orientation
static const std::string kDefaultNamespace
Eigen::Quaterniond quaternionFromMsg(const geometry_msgs::Quaternion &msg)
Eigen::Vector3d vector3FromPointMsg(const geometry_msgs::Point &msg)
double rotor_force_constant
static constexpr char COMMAND_TRAJECTORY[]
void eigenOdometryFromMsg(const nav_msgs::OdometryConstPtr &msg, EigenOdometry *odometry)
void skewMatrixFromVector(Eigen::Vector3d &vector, Eigen::Matrix3d *skew_matrix)
void calculateAllocationMatrix(const RotorConfiguration &rotor_configuration, Eigen::Matrix4Xd *allocation_matrix)
static const std::string kDefaultCommandRollPitchYawrateThrustTopic