10#include <geometry_msgs/msg/pose.hpp>
11#include <geometry_msgs/msg/transform.hpp>
13#include "smooth/se3.hpp"
15using namespace geometry_msgs::msg;
20static_assert(std::is_same_v<
decltype(Vector3::x),
double>);
21static_assert(std::is_same_v<
decltype(Vector3::y),
double>);
22static_assert(std::is_same_v<
decltype(Vector3::z),
double>);
24static_assert(offsetof(Vector3, x) == 0);
25static_assert(offsetof(Vector3, y) ==
sizeof(double));
26static_assert(offsetof(Vector3, z) == 2 *
sizeof(double));
29static_assert(std::is_same_v<
decltype(Point::x),
double>);
30static_assert(std::is_same_v<
decltype(Point::y),
double>);
31static_assert(std::is_same_v<
decltype(Point::z),
double>);
33static_assert(offsetof(Point, x) == 0);
34static_assert(offsetof(Point, y) ==
sizeof(double));
35static_assert(offsetof(Point, z) == 2 *
sizeof(double));
38static_assert(std::is_same_v<
decltype(Quaternion::x),
double>);
39static_assert(std::is_same_v<
decltype(Quaternion::y),
double>);
40static_assert(std::is_same_v<
decltype(Quaternion::z),
double>);
41static_assert(std::is_same_v<
decltype(Quaternion::w),
double>);
43static_assert(offsetof(Quaternion, x) == 0);
44static_assert(offsetof(Quaternion, y) ==
sizeof(double));
45static_assert(offsetof(Quaternion, z) == 2 *
sizeof(double));
46static_assert(offsetof(Quaternion, w) == 3 *
sizeof(double));
49static_assert(std::is_same_v<
decltype(Pose::position), Point>);
50static_assert(std::is_same_v<
decltype(Pose::orientation), Quaternion>);
51static_assert(offsetof(Pose, position) == 0);
52static_assert(offsetof(Pose, orientation) ==
sizeof(Point));
55static_assert(std::is_same_v<
decltype(Transform::translation), Vector3>);
56static_assert(std::is_same_v<
decltype(Transform::rotation), Quaternion>);
57static_assert(offsetof(Transform, translation) == 0);
58static_assert(offsetof(Transform, rotation) ==
sizeof(Vector3));
63#define CREATE_MAPS(DATATYPE, LIETYPE, BASETYPE) \
66 struct smooth::liebase_info<smooth::Map<DATATYPE>> : public liebase_info<LIETYPE> \
71 class smooth::Map<DATATYPE> : public BASETYPE<smooth::Map<DATATYPE>> \
73 using Base = BASETYPE<smooth::Map<DATATYPE>>; \
77 SMOOTH_INHERIT_TYPEDEFS; \
80 explicit Map(DATATYPE & msg) : m_coeffs(reinterpret_cast<double *>(&msg)) {} \
82 using Storage = Eigen::Map<Eigen::Matrix<double, RepSize, 1>>; \
84 Storage & coeffs() { return m_coeffs; } \
86 const Storage & coeffs() const { return m_coeffs; } \
88 Scalar * data() { return m_coeffs.data(); } \
90 const Scalar * data() const { return m_coeffs.data(); } \
98 struct smooth::liebase_info<smooth::Map<const DATATYPE>> : public liebase_info<LIETYPE> \
101 static constexpr bool is_mutable = false; \
106 class smooth::Map<const DATATYPE> : public BASETYPE<smooth::Map<const DATATYPE>> \
108 using Base = BASETYPE<smooth::Map<const DATATYPE>>; \
112 SMOOTH_INHERIT_TYPEDEFS; \
115 explicit Map(const DATATYPE & msg) : m_coeffs(reinterpret_cast<const double *>(&msg)) {} \
117 using Storage = Eigen::Map<const Eigen::Matrix<double, RepSize, 1>>; \
119 const Storage & coeffs() const { return m_coeffs; } \
121 const Scalar * data() const { return m_coeffs.data(); } \
127 static_assert(true, "")
129CREATE_MAPS(geometry_msgs::msg::Quaternion, smooth::SO3d, smooth::SO3Base);
130CREATE_MAPS(geometry_msgs::msg::Pose, smooth::SE3d, smooth::SE3Base);
131CREATE_MAPS(geometry_msgs::msg::Transform, smooth::SE3d, smooth::SE3Base);
#define CREATE_MAPS(DATATYPE, LIETYPE, BASETYPE)
Map message DATATYPE as implementation LIETYPE with CRTP base BASETYPE.