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;
92 Eigen::Vector3d
transform_frame(
const Eigen::Vector3d &vec,
const Eigen::Quaterniond &q);
351 inline void quaternion_to_rpy(
const Eigen::Quaterniond &q,
double &roll,
double &pitch,
double &yaw)
372 template <typename _Scalar, typename std::enable_if<std::is_floating_point<_Scalar>::value,
bool>::type =
true>
386 return Eigen::Quaterniond(q[0], q[1], q[2], q[3]);
392 template<
class T, std::
size_t SIZE>
395 std::copy(cov.cbegin(), cov.cend(), covmsg.begin());
401 template<
class T, std::
size_t ARR_SIZE>
405 std::size_t COV_SIZE =
m.rows() * (
m.rows() + 1) / 2;
407 "frame_tf: covariance matrix URT size (%lu) is different from Mavlink msg covariance field size (%lu)",
410 auto out = covmsg.begin();
412 for (
size_t x = 0;
x <
m.cols();
x++) {
413 for (
size_t y =
x;
y <
m.rows();
y++)
422 template<
class T, std::
size_t ARR_SIZE>
425 std::size_t COV_SIZE = covmat.rows() * (covmat.rows() + 1) / 2;
427 "frame_tf: covariance matrix URT size (%lu) is different from Mavlink msg covariance field size (%lu)",
430 auto in = covmsg.begin();
432 for (
size_t x = 0;
x < covmat.cols();
x++) {
433 for (
size_t y =
x;
y < covmat.rows();
y++) {
434 covmat(
x,
y) =
static_cast<double>(*in++);
435 covmat(
y,
x) = covmat(
x,
y);
452 inline Eigen::Vector3d
to_eigen(
const geometry_msgs::Point r) {
453 return Eigen::Vector3d(r.x, r.y, r.z);
456 inline Eigen::Vector3d
to_eigen(
const geometry_msgs::Vector3 r) {
457 return Eigen::Vector3d(r.x, r.y, r.z);
460 inline Eigen::Quaterniond
to_eigen(
const geometry_msgs::Quaternion r) {
461 return Eigen::Quaterniond(r.w, r.x, r.y, r.z);
change orientation from being expressed in baselink frame to aircraft frame in an absolute frame of r...
change from expressed WRT ENU frame to WRT ECEF frame
will change orientation from being expressed WRT NED frame to WRT ENU frame
StaticEcefTF
Orientation transform options when applying rotations to data, for ECEF.
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.
Eigen::Map< const Eigen::Matrix< double, 3, 3, Eigen::RowMajor > > EigenMapConstCovariance3d
void quaternion_to_mavlink(const Eigen::Quaternion< _Scalar > &q, std::array< float, 4 > &qmsg)
Store Quaternion to MAVLink float[4] format.
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...
T transform_orientation_absolute_frame_aircraft_baselink(const T &in)
Transform from attitude represented WRT aircraft frame to attitude represented WRT base_link 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,...)
Eigen::Vector3d transform_static_frame(const Eigen::Vector3d &vec, const Eigen::Vector3d &map_origin, const StaticEcefTF transform)
Transform data expressed in one frame to another frame with additional map origin parameter...
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::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.
change orientation from being expressed in aircraft frame to baselink frame in an absolute frame of r...
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_orientation_absolute_frame_baselink_aircraft(const T &in)
Transform from attitude represented WRT baselink frame to attitude represented WRT body 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...
change from expressed WRT ECEF frame to WRT ENU frame
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_...