ReduxLib C++ 2024.3.2
Loading...
Searching...
No Matches
CanandgyroData.h
1// Copyright (c) Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the 3-clause BSD license.
3
4#pragma once
5
6#include <cinttypes>
7#include <algorithm>
8#include <Eigen/Core>
9#include <units/force.h>
10#include <units/angular_velocity.h>
11
13
14/**
15 * Angular velocity data class.
16*/
18 public:
19 /** constructor
20 * @param roll roll
21 * @param pitch pitch
22 * @param yaw yaw
23 *
24 */
25 constexpr AngularVelocity(
26 const units::turns_per_second_t roll,
27 const units::turns_per_second_t pitch,
28 const units::turns_per_second_t yaw
29 ) : roll{roll}, pitch{pitch}, yaw{yaw} {};
30
31 /**
32 * Roll velocity.
33 * @return roll velocity in angular velocity units
34 */
35 constexpr units::turns_per_second_t Roll() const { return this->roll; }
36
37 /**
38 * Pitch velocity.
39 * @return pitch velocity in angular velocity units
40 */
41 constexpr units::turns_per_second_t Pitch() const { return this->pitch; }
42
43 /**
44 * Yaw velocity.
45 * @return yaw velocity in angular velocity units
46 */
47 constexpr units::turns_per_second_t Yaw() const { return this->yaw; }
48
49 /**
50 * Converts to a Eigen::Vector3d with roll/pitch/yaw velocity as the first/second/third element
51 * and the units in radians/second.
52 * @return Vector3d
53 */
54 inline Eigen::Vector3d ToVector3d() {
55 return Eigen::Vector3d {
56 this->roll.convert<units::radians_per_second>().value(),
57 this->pitch.convert<units::radians_per_second>().value(),
58 this->yaw.convert<units::radians_per_second>().value(),
59 };
60 }
61
62
63 private:
64 units::turns_per_second_t roll;
65 units::turns_per_second_t pitch;
66 units::turns_per_second_t yaw;
67
68};
69
70
71/**
72 * Acceleration data class.
73*/
75 public:
76 /**
77 * constructor
78 * @param x x-axis
79 * @param y y-axis
80 * @param z z-axis
81 */
82 constexpr Acceleration(
83 const units::standard_gravity_t x,
84 const units::standard_gravity_t y,
85 const units::standard_gravity_t z
86 ) : x{x}, y{y}, z{z} {};
87
88 /**
89 * X-axis component
90 * @return x in accelerational units
91 */
92 constexpr units::standard_gravity_t X() const { return this->x; }
93 /**
94 * Y-axis component
95 * @return y in accelerational units
96 */
97 constexpr units::standard_gravity_t Y() const { return this->y; }
98 /**
99 * Z-axis component
100 * @return z in accelerational units
101 */
102 constexpr units::standard_gravity_t Z() const { return this->z; }
103
104 /**
105 * Converts to a Eigen Vector3d with X/Y/Z-axis acceleration as the first/second/third element
106 * and standard gravities as the unit.
107 * @return a Vector3d
108 */
109 inline Eigen::Vector3d ToVector3d() {
110 return Eigen::Vector3d {
111 this->x.value(),
112 this->y.value(),
113 this->z.value()
114 };
115 }
116
117
118 private:
119 units::standard_gravity_t x;
120 units::standard_gravity_t y;
121 units::standard_gravity_t z;
122
123};
124
125}
Definition: CanandgyroData.h:74
constexpr units::standard_gravity_t Y() const
Definition: CanandgyroData.h:97
constexpr units::standard_gravity_t Z() const
Definition: CanandgyroData.h:102
Eigen::Vector3d ToVector3d()
Definition: CanandgyroData.h:109
constexpr units::standard_gravity_t X() const
Definition: CanandgyroData.h:92
constexpr Acceleration(const units::standard_gravity_t x, const units::standard_gravity_t y, const units::standard_gravity_t z)
Definition: CanandgyroData.h:82
Definition: CanandgyroData.h:17
constexpr units::turns_per_second_t Roll() const
Definition: CanandgyroData.h:35
constexpr units::turns_per_second_t Yaw() const
Definition: CanandgyroData.h:47
constexpr AngularVelocity(const units::turns_per_second_t roll, const units::turns_per_second_t pitch, const units::turns_per_second_t yaw)
Definition: CanandgyroData.h:25
constexpr units::turns_per_second_t Pitch() const
Definition: CanandgyroData.h:41
Eigen::Vector3d ToVector3d()
Definition: CanandgyroData.h:54
Definition: Canandgyro.h:32