9#include "units/angle.h"
10#include "units/length.h"
11#include "units/math.h"
28 units::meter_t dx = 0_m;
33 units::meter_t dy = 0_m;
38 units::meter_t dz = 0_m;
43 units::radian_t rx = 0_rad;
48 units::radian_t ry = 0_rad;
53 units::radian_t rz = 0_rad;
80 return units::math::abs(dx - other.dx) < 1E-9_m &&
81 units::math::abs(dy - other.dy) < 1E-9_m &&
82 units::math::abs(dz - other.dz) < 1E-9_m &&
83 units::math::abs(rx - other.rx) < 1E-9_rad &&
84 units::math::abs(ry - other.ry) < 1E-9_rad &&
85 units::math::abs(rz - other.rz) < 1E-9_rad;
95 return Twist3d{dx * factor, dy * factor, dz * factor,
96 rx * factor, ry * factor, rz * factor};
110 auto impl = [
this]<
typename Matrix3d,
typename Vector3d>() ->
Transform3d {
111 Vector3d u{{
dx.value(),
dy.value(),
dz.value()}};
112 Vector3d rvec{{
rx.value(),
ry.value(),
rz.value()}};
114 Matrix3d omegaSq = omega * omega;
115 double theta = rvec.norm();
116 double thetaSq = theta * theta;
133 A = 1 - thetaSq / 6 + thetaSq * thetaSq / 120;
134 B = 1 / 2.0 - thetaSq / 24 + thetaSq * thetaSq / 720;
135 C = 1 / 6.0 - thetaSq / 120 + thetaSq * thetaSq / 5040;
142 C = (1 - A) / thetaSq;
145 Matrix3d R = Matrix3d::Identity() + A * omega + B * omegaSq;
146 Matrix3d V = Matrix3d::Identity() + B * omega + C * omegaSq;
148 Vector3d translation_component = V * u;
152 units::meter_t{translation_component(1)},
153 units::meter_t{translation_component(2)}},
159 if (std::is_constant_evaluated()) {
162 return impl.template operator()<Eigen::Matrix3d, Eigen::Vector3d>();
#define WPILIB_DLLEXPORT
Definition SymbolExports.h:36
A rotation in a 3D coordinate frame represented by a quaternion.
Definition Rotation3d.h:29
Represents a translation in 3D space.
Definition Translation3d.h:31
Compile-time wrapper for Eigen::Matrix.
Definition ct_matrix.h:26
constexpr ct_matrix3d RotationVectorToMatrix(const ct_vector3d &rotation)
Definition RotationVectorToMatrix.h:13
Definition SystemServer.h:9
ct_matrix< double, 3, 3 > ct_matrix3d
Definition ct_matrix.h:385
constexpr T abs(const T x) noexcept
Compile-time absolute value function.
Definition abs.hpp:40
constexpr return_t< T > cos(const T x) noexcept
Compile-time cosine function.
Definition cos.hpp:83
constexpr return_t< T > sin(const T x) noexcept
Compile-time sine function.
Definition sin.hpp:85
A change in distance along a 3D arc since the last pose update.
Definition Twist3d.h:24
constexpr Twist3d operator*(double factor) const
Scale this by a given factor.
Definition Twist3d.h:94
units::meter_t dx
Linear "dx" component.
Definition Twist3d.h:28
units::radian_t ry
Rotation vector y component.
Definition Twist3d.h:48
constexpr bool operator==(const Twist3d &other) const
Checks equality between this Twist3d and another object.
Definition Twist3d.h:79
units::meter_t dy
Linear "dy" component.
Definition Twist3d.h:33
constexpr Transform3d Exp() const
Obtain a new Transform3d from a (constant curvature) velocity.
Definition Twist3d.h:107
units::radian_t rz
Rotation vector z component.
Definition Twist3d.h:53
units::meter_t dz
Linear "dz" component.
Definition Twist3d.h:38
units::radian_t rx
Rotation vector x component.
Definition Twist3d.h:43