WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
RomiGyro.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <hal/SimDevice.h>
8#include <units/angle.h>
10
11namespace frc {
12
13/**
14 * @ingroup romi_api
15 * @{
16 */
17
18/**
19 * Use a rate gyro to return the robots heading relative to a starting position.
20 *
21 * This class is for the Romi onboard gyro, and will only work in
22 * simulation/Romi mode. Only one instance of a RomiGyro is supported.
23 */
24class RomiGyro {
25 public:
27
28 /**
29 * Return the actual angle in radians that the robot is currently facing.
30 *
31 * The angle is based on integration of the returned rate form the gyro.
32 * The angle is continuous, that is, it will continue from 2π->3π radians.
33 * This allows algorithms that wouldn't want to see a discontinuity in the
34 * gyro output as it sweeps from 2π to 0 on the second time around.
35 *
36 * @return The current heading of the robot.
37 */
38 units::radian_t GetAngle() const;
39
40 /**
41 * Return the rate of rotation of the gyro
42 *
43 * The rate is based on the most recent reading of the gyro.
44 *
45 * @return The current rate.
46 */
47 units::radians_per_second_t GetRate() const;
48
49 /**
50 * Get the rate of turn in around the X-axis.
51 *
52 * @return Rate of turn.
53 */
54 units::radians_per_second_t GetRateX() const;
55
56 /**
57 * Get the rate of turn in around the Y-axis.
58 *
59 * @return Rate of turn.
60 */
61 units::radians_per_second_t GetRateY() const;
62
63 /**
64 * Get the rate of turn around the Z-axis.
65 *
66 * @return Rate of turn.
67 */
68 units::radians_per_second_t GetRateZ() const;
69
70 /**
71 * Get the currently reported angle around the X-axis.
72 *
73 * @return Current angle around X-axis.
74 */
75 units::radian_t GetAngleX() const;
76
77 /**
78 * Get the currently reported angle around the Y-axis.
79 *
80 * @return Current angle around Y-axis.
81 */
82 units::radian_t GetAngleY() const;
83
84 /**
85 * Get the currently reported angle around the Z-axis.
86 *
87 * @return Current angle around Z-axis.
88 */
89 units::radian_t GetAngleZ() const;
90
91 /**
92 * Resets the gyro
93 */
94 void Reset();
95
96 private:
97 hal::SimDevice m_simDevice;
98 hal::SimDouble m_simRateX;
99 hal::SimDouble m_simRateY;
100 hal::SimDouble m_simRateZ;
101 hal::SimDouble m_simAngleX;
102 hal::SimDouble m_simAngleY;
103 hal::SimDouble m_simAngleZ;
104
105 double m_angleXOffset = 0;
106 double m_angleYOffset = 0;
107 double m_angleZOffset = 0;
108};
109
110/** @} */
111
112} // namespace frc
Use a rate gyro to return the robots heading relative to a starting position.
Definition RomiGyro.h:24
void Reset()
Resets the gyro.
units::radians_per_second_t GetRate() const
Return the rate of rotation of the gyro.
units::radians_per_second_t GetRateZ() const
Get the rate of turn around the Z-axis.
units::radian_t GetAngleX() const
Get the currently reported angle around the X-axis.
units::radians_per_second_t GetRateX() const
Get the rate of turn in around the X-axis.
units::radians_per_second_t GetRateY() const
Get the rate of turn in around the Y-axis.
units::radian_t GetAngle() const
Return the actual angle in radians that the robot is currently facing.
units::radian_t GetAngleZ() const
Get the currently reported angle around the Z-axis.
units::radian_t GetAngleY() const
Get the currently reported angle around the Y-axis.
A move-only C++ wrapper around a HAL simulator device handle.
Definition SimDevice.h:645
C++ wrapper around a HAL simulator double value handle.
Definition SimDevice.h:536
Definition CAN.h:11