7#include "wpi/units/angle.hpp"
8#include "wpi/units/length.hpp"
9#include "wpi/units/math.hpp"
27 wpi::units::meter_t
dx = 0_m;
32 wpi::units::meter_t
dy = 0_m;
37 wpi::units::meter_t
dz = 0_m;
42 wpi::units::radian_t
rx = 0_rad;
47 wpi::units::radian_t
ry = 0_rad;
52 wpi::units::radian_t
rz = 0_rad;
79 return wpi::units::math::abs(
dx - other.
dx) < 1E-9_m &&
80 wpi::units::math::abs(
dy - other.
dy) < 1E-9_m &&
81 wpi::units::math::abs(
dz - other.
dz) < 1E-9_m &&
82 wpi::units::math::abs(
rx - other.
rx) < 1E-9_rad &&
83 wpi::units::math::abs(
ry - other.
ry) < 1E-9_rad &&
84 wpi::units::math::abs(
rz - other.
rz) < 1E-9_rad;
95 rx * factor,
ry * factor,
rz * factor};
109 auto impl = [
this]<
typename Matrix3d,
typename Vector3d>() ->
Transform3d {
110 Vector3d u{{
dx.value(),
dy.value(),
dz.value()}};
111 Vector3d rvec{{
rx.value(),
ry.value(),
rz.value()}};
113 Matrix3d omegaSq = omega * omega;
114 double theta = rvec.norm();
115 double thetaSq = theta * theta;
132 A = 1 - thetaSq / 6 + thetaSq * thetaSq / 120;
133 B = 1 / 2.0 - thetaSq / 24 + thetaSq * thetaSq / 720;
134 C = 1 / 6.0 - thetaSq / 120 + thetaSq * thetaSq / 5040;
141 C = (1 - A) / thetaSq;
144 Matrix3d R = Matrix3d::Identity() + A * omega + B * omegaSq;
145 Matrix3d V = Matrix3d::Identity() + B * omega + C * omegaSq;
147 Vector3d translation_component = V * u;
151 wpi::units::meter_t{translation_component(1)},
152 wpi::units::meter_t{translation_component(2)}},
158 if (std::is_constant_evaluated()) {
161 return impl.template operator()<Eigen::Matrix3d, Eigen::Vector3d>();
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
A rotation in a 3D coordinate frame, represented by a quaternion.
Definition Rotation3d.hpp:69
Represents a translation in 3D space.
Definition Translation3d.hpp:31
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
Definition RobotBase.hpp:26
constexpr ct_matrix3d RotationVectorToMatrix(const ct_vector3d &rotation)
Definition RotationVectorToMatrix.hpp:13
Definition LinearSystem.hpp:20
ct_vector< double, 3 > ct_vector3d
Definition ct_matrix.hpp:387
ct_matrix< double, 3, 3 > ct_matrix3d
Definition ct_matrix.hpp:385
A change in distance along a 3D arc since the last pose update.
Definition Twist3d.hpp:23
constexpr Transform3d Exp() const
Obtain a new Transform3d from a (constant curvature) velocity.
Definition Twist3d.hpp:106
wpi::units::meter_t dy
Linear "dy" component.
Definition Twist3d.hpp:32
constexpr Twist3d operator*(double factor) const
Scale this by a given factor.
Definition Twist3d.hpp:93
constexpr bool operator==(const Twist3d &other) const
Checks equality between this Twist3d and another object.
Definition Twist3d.hpp:78
wpi::units::radian_t rx
Rotation vector x component.
Definition Twist3d.hpp:42
wpi::units::meter_t dz
Linear "dz" component.
Definition Twist3d.hpp:37
wpi::units::meter_t dx
Linear "dx" component.
Definition Twist3d.hpp:27
wpi::units::radian_t rz
Rotation vector z component.
Definition Twist3d.hpp:52
wpi::units::radian_t ry
Rotation vector y component.
Definition Twist3d.hpp:47