23 #include <Eigen/Eigen> 24 #include <Eigen/Geometry> 28 #include <sensor_msgs/Imu.h> 29 #include <geometry_msgs/Point.h> 30 #include <geometry_msgs/Vector3.h> 31 #include <geometry_msgs/Quaternion.h> 32 #include <geometry_msgs/PoseWithCovariance.h> 37 using Covariance3d = sensor_msgs::Imu::_angular_velocity_covariance_type;
40 using Covariance6d = geometry_msgs::PoseWithCovariance::_covariance_type;
84 Eigen::Vector3d
transform_frame(
const Eigen::Vector3d &vec,
const Eigen::Quaterniond &q);
323 inline void quaternion_to_rpy(
const Eigen::Quaterniond &q,
double &roll,
double &pitch,
double &yaw)
357 return Eigen::Quaterniond(q[0], q[1], q[2], q[3]);
363 template<
class T, std::
size_t SIZE>
366 std::copy(cov.cbegin(), cov.cend(), covmsg.begin());
372 template<
class T, std::
size_t ARR_SIZE>
376 std::size_t COV_SIZE =
m.rows() * (
m.rows() + 1) / 2;
378 "frame_tf: covariance matrix URT size (%lu) is different from Mavlink msg covariance field size (%lu)",
381 auto out = covmsg.begin();
383 for (
size_t x = 0;
x <
m.cols();
x++) {
384 for (
size_t y =
x;
y <
m.rows();
y++)
393 template<
class T, std::
size_t ARR_SIZE>
396 std::size_t COV_SIZE = covmat.rows() * (covmat.rows() + 1) / 2;
398 "frame_tf: covariance matrix URT size (%lu) is different from Mavlink msg covariance field size (%lu)",
401 auto in = covmsg.begin();
403 for (
size_t x = 0;
x < covmat.cols();
x++) {
404 for (
size_t y =
x;
y < covmat.rows();
y++) {
405 covmat(
x,
y) =
static_cast<double>(*in++);
406 covmat(
y,
x) = covmat(
x,
y);
423 inline Eigen::Vector3d
to_eigen(
const geometry_msgs::Point r) {
424 return Eigen::Vector3d(r.x, r.y, r.z);
427 inline Eigen::Vector3d
to_eigen(
const geometry_msgs::Vector3 r) {
428 return Eigen::Vector3d(r.x, r.y, r.z);
431 inline Eigen::Quaterniond
to_eigen(
const geometry_msgs::Quaternion r) {
432 return Eigen::Quaterniond(r.w, r.x, r.y, r.z);
will change orientation from being expressed WRT NED frame to WRT ENU frame
Eigen::Quaterniond mavlink_to_quaternion(const std::array< float, 4 > &q)
Convert Mavlink float[4] quaternion to Eigen.
StaticTF
Orientation transform options when applying rotations to data.
Eigen::Map< Eigen::Matrix< double, 6, 6, Eigen::RowMajor > > EigenMapCovariance6d
Eigen::Map for Covariance6d.
change from expressed WRT ENU frame to WRT ECEF frame
Eigen::Map< const Eigen::Matrix< double, 3, 3, Eigen::RowMajor > > EigenMapConstCovariance3d
Eigen::Quaterniond transform_orientation(const Eigen::Quaterniond &q, const StaticTF transform)
Transform representation of attitude from 1 frame to another (e.g. transfrom attitude from representi...
T transform_orientation_enu_ned(const T &in)
Transform from attitude represented WRT ENU frame to attitude represented WRT NED frame...
void mavlink_urt_to_covariance_matrix(const std::array< float, ARR_SIZE > &covmsg, T &covmat)
Convert MAVLink float[n] format (upper right triangular of a covariance matrix) to Eigen::MatrixXd<n...
Eigen::Vector3d transform_static_frame(const Eigen::Vector3d &vec, const StaticTF transform)
Transform data expressed in one frame to another frame.
T transform_frame_enu_aircraft(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in ENU to aircraft frame. Assumes quaternion represents rotation from ENU to...
Eigen::Vector3d transform_frame(const Eigen::Vector3d &vec, const Eigen::Quaterniond &q)
Transform data expressed in one frame to another frame.
T transform_frame_enu_baselink(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in ENU to base_link frame. Assumes quaternion represents rotation from ENU t...
change from expressed WRT ECEF frame to WRT ENU frame
T transform_frame_aircraft_baselink(const T &in)
Transform data expressed in Aircraft frame to Baselink frame.
change from expressed WRT aircraft frame to WRT to baselink frame
Eigen::Vector3d quaternion_to_rpy(const Eigen::Quaterniond &q)
Convert quaternion to euler angles.
#define ROS_ASSERT_MSG(cond,...)
T transform_frame_ned_aircraft(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in NED to aircraft frame. Assumes quaternion represents rotation from NED to...
Eigen::Vector3d transform_static_frame(const Eigen::Vector3d &vec, const Eigen::Vector3d &map_origin, const StaticTF transform)
Transform data expressed in one frame to another frame with additional map origin parameter...
Eigen::Map< Eigen::Matrix< double, 9, 9, Eigen::RowMajor > > EigenMapCovariance9d
Eigen::Map for Covariance9d.
T transform_frame_aircraft_enu(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in aircraft frame to ENU frame. Assumes quaternion represents rotation from ...
T transform_frame_ned_enu(const T &in)
Transform data expressed in NED to ENU frame.
Eigen::Vector3d to_eigen(const geometry_msgs::Point r)
Helper to convert common ROS geometry_msgs::Point to Eigen::Vector3d.
void covariance_urt_to_mavlink(const T &covmap, std::array< float, ARR_SIZE > &covmsg)
Convert upper right triangular of a covariance matrix to MAVLink float[n] format. ...
geometry_msgs::PoseWithCovariance::_covariance_type Covariance6d
Type matching rosmsg for 6x6 covariance matrix.
T transform_frame_baselink_aircraft(const T &in)
Transform data expressed in Baselink frame to Aircraft frame.
boost::array< double, 81 > Covariance9d
Type matching rosmsg for 9x9 covariance matrix.
Eigen::Map< Eigen::Matrix< double, 3, 3, Eigen::RowMajor > > EigenMapCovariance3d
Eigen::Map for Covariance3d.
T transform_frame_enu_ecef(const T &in, const T &map_origin)
Transform data expressed in ENU frame to ECEF frame.
T transform_frame_enu_ned(const T &in)
Transform data expressed in ENU to NED frame.
sensor_msgs::Imu::_angular_velocity_covariance_type Covariance3d
Type matching rosmsg for 3x3 covariance matrix.
Eigen::Quaterniond quaternion_from_rpy(const Eigen::Vector3d &rpy)
Convert euler angles to quaternion.
change from expressed WRT baselnk to WRT aircraft
Covariance9d transform_frame(const Covariance9d &cov, const Eigen::Quaterniond &q)
Transform 9x9 convariance expressed in one frame to another.
double quaternion_get_yaw(const Eigen::Quaterniond &q)
Get Yaw angle from quaternion.
T transform_frame_ecef_enu(const T &in, const T &map_origin)
Transform data expressed in ECEF frame to ENU frame.
T transform_frame_aircraft_ned(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in aircraft frame to NED frame. Assumes quaternion represents rotation from ...
T transform_orientation_ned_enu(const T &in)
Transform from attitude represented WRT NED frame to attitude represented WRT ENU frame...
void quaternion_to_mavlink(const Eigen::Quaterniond &q, std::array< float, 4 > &qmsg)
Store Quaternion to MAVLink float[4] format.
T transform_orientation_baselink_aircraft(const T &in)
Transform from attitude represented WRT baselink frame to attitude represented WRT body frame...
void covariance_to_mavlink(const T &cov, std::array< float, SIZE > &covmsg)
Convert covariance matrix to MAVLink float[n] format.
T transform_orientation_aircraft_baselink(const T &in)
Transform from attitude represented WRT aircraft frame to attitude represented WRT base_link frame...
Eigen::Map< const Eigen::Matrix< double, 9, 9, Eigen::RowMajor > > EigenMapConstCovariance9d
Eigen::Map< const Eigen::Matrix< double, 6, 6, Eigen::RowMajor > > EigenMapConstCovariance6d
change from expressed WRT ENU frame to WRT NED frame
T transform_frame_baselink_enu(const T &in, const Eigen::Quaterniond &q)
Transform data expressed in baselink to ENU frame. Assumes quaternion represents rotation from basel_...