YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
GyroAxis.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Yet Another Software Suite
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <numbers>
7#include <wpi/math/geometry/Quaternion.hpp>
8#include <wpi/math/geometry/Rotation3d.hpp>
9#include <wpi/units/angle.hpp>
10
12
20enum class GyroAxis {
22 ROLL,
24 PITCH,
26 YAW
27};
28
37inline wpi::math::Rotation3d ToRobotAttitude(GyroAxis axis,
38 const wpi::math::Rotation3d& gyroAttitude) {
39 if (axis == GyroAxis::YAW) {
40 return gyroAttitude;
41 }
42 const wpi::units::radian_t zero{0};
43 const wpi::units::radian_t quarterTurn{std::numbers::pi / 2};
44 const wpi::math::Rotation3d gyroToRobot =
45 axis == GyroAxis::ROLL ? wpi::math::Rotation3d{zero, -quarterTurn, zero}
46 : wpi::math::Rotation3d{quarterTurn, zero, zero};
47 const auto q = gyroToRobot.GetQuaternion();
48 return wpi::math::Rotation3d{q * gyroAttitude.GetQuaternion() * q.Inverse()};
49}
50
51} // namespace yams::mechanisms::config
Definition ArmConfig.hpp:17
wpi::math::Rotation3d ToRobotAttitude(GyroAxis axis, const wpi::math::Rotation3d &gyroAttitude)
Definition GyroAxis.hpp:37
GyroAxis
Definition GyroAxis.hpp:20