|
| 1 | +#ifndef _MANIF_MANIF_SGAL3_H_ |
| 2 | +#define _MANIF_MANIF_SGAL3_H_ |
| 3 | + |
| 4 | +#include "manif/impl/sgal3/SGal3_base.h" |
| 5 | + |
| 6 | +namespace manif { |
| 7 | + |
| 8 | +// Forward declare for type traits specialization |
| 9 | +template <typename _Scalar> struct SGal3; |
| 10 | +template <typename _Scalar> struct SGal3Tangent; |
| 11 | + |
| 12 | +namespace internal { |
| 13 | + |
| 14 | +//! Traits specialization |
| 15 | +template <typename _Scalar> |
| 16 | +struct traits<SGal3<_Scalar>> { |
| 17 | + using Scalar = _Scalar; |
| 18 | + |
| 19 | + using LieGroup = SGal3<_Scalar>; |
| 20 | + using Tangent = SGal3Tangent<_Scalar>; |
| 21 | + |
| 22 | + using Base = SGal3Base<SGal3<_Scalar>>; |
| 23 | + |
| 24 | + static constexpr int Dim = LieGroupProperties<Base>::Dim; |
| 25 | + static constexpr int DoF = LieGroupProperties<Base>::DoF; |
| 26 | + static constexpr int RepSize = 11; |
| 27 | + |
| 28 | + /// @todo would be nice to concat vec3 + quaternion + vec3 + t |
| 29 | + using DataType = Eigen::Matrix<Scalar, RepSize, 1>; |
| 30 | + |
| 31 | + using Jacobian = Eigen::Matrix<Scalar, DoF, DoF>; |
| 32 | + using Rotation = Eigen::Matrix<Scalar, 3, 3>; |
| 33 | + using Translation = Eigen::Matrix<Scalar, 3, 1>; |
| 34 | + using LinearVelocity = Eigen::Matrix<Scalar, 3, 1>; |
| 35 | + using Vector = Eigen::Matrix<Scalar, 3, 1>; |
| 36 | +}; |
| 37 | + |
| 38 | +} // namespace internal |
| 39 | +} // namespace manif |
| 40 | + |
| 41 | +namespace manif { |
| 42 | + |
| 43 | +// |
| 44 | +// LieGroup |
| 45 | +// |
| 46 | + |
| 47 | +/** |
| 48 | + * @brief Represent an element of SGal3. |
| 49 | + */ |
| 50 | +template <typename _Scalar> |
| 51 | +struct SGal3 : SGal3Base<SGal3<_Scalar>> { |
| 52 | +private: |
| 53 | + |
| 54 | + using Base = SGal3Base<SGal3<_Scalar>>; |
| 55 | + using Type = SGal3<_Scalar>; |
| 56 | + |
| 57 | +protected: |
| 58 | + |
| 59 | + using Base::derived; |
| 60 | + |
| 61 | +public: |
| 62 | + |
| 63 | + MANIF_MAKE_ALIGNED_OPERATOR_NEW_COND |
| 64 | + |
| 65 | + MANIF_COMPLETE_GROUP_TYPEDEF |
| 66 | + using Translation = typename Base::Translation; |
| 67 | + using Quaternion = Eigen::Quaternion<Scalar>; |
| 68 | + using LinearVelocity = typename Base::LinearVelocity; |
| 69 | + |
| 70 | + MANIF_INHERIT_GROUP_API |
| 71 | + using Base::rotation; |
| 72 | + using Base::normalize; |
| 73 | + |
| 74 | + SGal3() = default; |
| 75 | + ~SGal3() = default; |
| 76 | + |
| 77 | + MANIF_COPY_CONSTRUCTOR(SGal3) |
| 78 | + MANIF_MOVE_CONSTRUCTOR(SGal3) |
| 79 | + |
| 80 | + template <typename _DerivedOther> |
| 81 | + SGal3(const LieGroupBase<_DerivedOther>& o); |
| 82 | + |
| 83 | + MANIF_GROUP_ASSIGN_OP(SGal3) |
| 84 | + |
| 85 | + /** |
| 86 | + * @brief Constructor given a translation, a unit quaternion and a linear velocity. |
| 87 | + * @param[in] t A translation vector. |
| 88 | + * @param[in] q A unit quaternion. |
| 89 | + * @param[in] v A linear velocity vector. |
| 90 | + * @param[in] time A time. |
| 91 | + * @throws manif::invalid_argument on un-normalized complex number. |
| 92 | + */ |
| 93 | + SGal3( |
| 94 | + const Translation& t, |
| 95 | + const Eigen::Quaternion<Scalar>& q, |
| 96 | + const LinearVelocity& v, |
| 97 | + const Scalar time |
| 98 | + ); |
| 99 | + |
| 100 | + /** |
| 101 | + * @brief Constructor given a translation, an angle axis and a linear velocity. |
| 102 | + * @param[in] t A translation vector. |
| 103 | + * @param[in] angle_axis An angle-axis. |
| 104 | + * @param[in] v A linear velocity vector. |
| 105 | + * @param[in] time A time. |
| 106 | + */ |
| 107 | + SGal3( |
| 108 | + const Translation& t, |
| 109 | + const Eigen::AngleAxis<Scalar>& angle_axis, |
| 110 | + const LinearVelocity& v, |
| 111 | + const Scalar time |
| 112 | + ); |
| 113 | + |
| 114 | + /** |
| 115 | + * @brief Constructor given a translation, SO3 element and a linear velocity. |
| 116 | + * @param[in] t A translation vector. |
| 117 | + * @param[in] SO3 An element of SO3. |
| 118 | + * @param[in] v A linear velocity vector. |
| 119 | + * @param[in] time A time. |
| 120 | + */ |
| 121 | + SGal3( |
| 122 | + const Translation& t, |
| 123 | + const SO3<Scalar>& SO3, |
| 124 | + const LinearVelocity& v, |
| 125 | + const Scalar time |
| 126 | + ); |
| 127 | + |
| 128 | + /** |
| 129 | + * @brief Constructor given translation components, |
| 130 | + * roll-pitch-yaw angles and linear velocity components |
| 131 | + * @param[in] x The x component of the translation. |
| 132 | + * @param[in] y The y component of the translation. |
| 133 | + * @param[in] z The z component of the translation. |
| 134 | + * @param[in] roll The roll angle. |
| 135 | + * @param[in] pitch The pitch angle. |
| 136 | + * @param[in] yaw The yaw angle. |
| 137 | + * @param[in] vx The x component of the linear velocity. |
| 138 | + * @param[in] vy The y component of the linear velocity. |
| 139 | + * @param[in] vz The z component of the linear velocity. |
| 140 | + * @param[in] t time. |
| 141 | + */ |
| 142 | + SGal3( |
| 143 | + const Scalar x, const Scalar y, const Scalar z, |
| 144 | + const Scalar roll, const Scalar pitch, const Scalar yaw, |
| 145 | + const Scalar vx, const Scalar vy, const Scalar vz, |
| 146 | + const Scalar t |
| 147 | + ); |
| 148 | + |
| 149 | + /** |
| 150 | + * @brief Constructor from a 3D Eigen::Isometry<Scalar> relevant to SE(3) and a linear velocity |
| 151 | + * @param[in] h a isometry object from Eigen defined for SE(3) |
| 152 | + * @param[in] v a linear velocity vector. |
| 153 | + * @note overall, this should be a double direct spatial isometry, |
| 154 | + */ |
| 155 | + SGal3( |
| 156 | + const Eigen::Transform<_Scalar,3,Eigen::Isometry>& h, |
| 157 | + const LinearVelocity& v, |
| 158 | + const Scalar t |
| 159 | + ); |
| 160 | + |
| 161 | + // LieGroup common API |
| 162 | + |
| 163 | + DataType& coeffs(); |
| 164 | + const DataType& coeffs() const; |
| 165 | + |
| 166 | + // SGal3 specific API |
| 167 | + |
| 168 | +protected: |
| 169 | + |
| 170 | + DataType data_; |
| 171 | +}; |
| 172 | + |
| 173 | +MANIF_EXTRA_GROUP_TYPEDEF(SGal3) |
| 174 | + |
| 175 | +template <typename _Scalar> |
| 176 | +template <typename _DerivedOther> |
| 177 | +SGal3<_Scalar>::SGal3(const LieGroupBase<_DerivedOther>& o) : SGal3(o.coeffs()) { |
| 178 | + // |
| 179 | +} |
| 180 | + |
| 181 | +template <typename _Scalar> |
| 182 | +SGal3<_Scalar>::SGal3( |
| 183 | + const Translation& t, |
| 184 | + const Eigen::Quaternion<Scalar>& q, |
| 185 | + const LinearVelocity& v, |
| 186 | + const Scalar time |
| 187 | +) : SGal3((DataType() << t, q.coeffs(), v, time).finished()) { |
| 188 | + // |
| 189 | +} |
| 190 | + |
| 191 | +template <typename _Scalar> |
| 192 | +SGal3<_Scalar>::SGal3( |
| 193 | + const Translation& t, |
| 194 | + const Eigen::AngleAxis<Scalar>& a, |
| 195 | + const LinearVelocity& v, |
| 196 | + const Scalar time |
| 197 | +) : SGal3(t, Quaternion(a), v, time) { |
| 198 | + // |
| 199 | +} |
| 200 | + |
| 201 | +template <typename _Scalar> |
| 202 | +SGal3<_Scalar>::SGal3( |
| 203 | + const Scalar x, const Scalar y, const Scalar z, |
| 204 | + const Scalar roll, const Scalar pitch, const Scalar yaw, |
| 205 | + const Scalar vx, const Scalar vy, const Scalar vz, |
| 206 | + const Scalar t |
| 207 | +) : SGal3( |
| 208 | + Translation(x,y,z), |
| 209 | + Eigen::Quaternion<Scalar>( |
| 210 | + Eigen::AngleAxis<Scalar>(yaw, Eigen::Matrix<Scalar, 3, 1>::UnitZ()) * |
| 211 | + Eigen::AngleAxis<Scalar>(pitch, Eigen::Matrix<Scalar, 3, 1>::UnitY()) * |
| 212 | + Eigen::AngleAxis<Scalar>(roll, Eigen::Matrix<Scalar, 3, 1>::UnitX()) |
| 213 | + ), |
| 214 | + LinearVelocity(vx, vy, vz), |
| 215 | + t |
| 216 | +) { |
| 217 | + // |
| 218 | +} |
| 219 | + |
| 220 | +template <typename _Scalar> |
| 221 | +SGal3<_Scalar>::SGal3( |
| 222 | + const Translation& t, |
| 223 | + const SO3<Scalar>& so3, |
| 224 | + const LinearVelocity& v, |
| 225 | + const Scalar time |
| 226 | +) : SGal3(t, so3.quat(), v, time) { |
| 227 | + // |
| 228 | +} |
| 229 | + |
| 230 | +template <typename _Scalar> |
| 231 | +SGal3<_Scalar>::SGal3( |
| 232 | + const Eigen::Transform<_Scalar, 3, Eigen::Isometry>& h, |
| 233 | + const LinearVelocity& v, |
| 234 | + const Scalar t |
| 235 | +) : SGal3(h.translation(), Eigen::Quaternion<_Scalar>(h.rotation()), v, t) { |
| 236 | + // |
| 237 | +} |
| 238 | + |
| 239 | + |
| 240 | +template <typename _Scalar> |
| 241 | +typename SGal3<_Scalar>::DataType& |
| 242 | +SGal3<_Scalar>::coeffs() { |
| 243 | + return data_; |
| 244 | +} |
| 245 | + |
| 246 | +template <typename _Scalar> |
| 247 | +const typename SGal3<_Scalar>::DataType& |
| 248 | +SGal3<_Scalar>::coeffs() const { |
| 249 | + return data_; |
| 250 | +} |
| 251 | + |
| 252 | +} // namespace manif |
| 253 | + |
| 254 | +#endif // _MANIF_MANIF_SGAL3_H_ |
0 commit comments