StudicaLib
Loading...
Searching...
No Matches
Navx.h
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3#include <frc/geometry/Quaternion.h>
4#include <frc/geometry/Rotation2d.h>
5#include <frc/geometry/Rotation3d.h>
6#include <units/angular_velocity.h>
7#include <units/acceleration.h>
8#include <units/angle.h>
9#include <units/temperature.h>
10#include <units/magnetic_field_strength.h>
11
12namespace studica
13{
14 class Navx;
15}
16
26{
27 public:
28
32 enum class Port : int {
33 kUSB1 = 2,
35 };
36
41 explicit Navx(int deviceId);
42
47 explicit Navx(Port port);
48
54 Navx(int deviceId, int updateRate);
55
61 Navx(Port port, int updateRate);
62 Navx(Navx&&) = default;
63 Navx& operator=(Navx&&) = default;
64
68 ~Navx();
69
74 units::degree_t GetYaw();
75
80 units::degree_t GetPitch();
81
86 units::degree_t GetRoll();
87
92 units::degree_t GetAngle();
93
106 bool GetAlgoStates(float states[9]);
107
122 bool EnableOptionalMessages(bool yaw, bool angle, bool quat6d, bool quat9d, bool algoStates, bool pitchRoll,
123 bool angularVel, bool linearAccel, bool compass, bool temperature);
124
130 bool GetQuat6D(frc::Quaternion& quat);
131
137 bool GetQuat9D(frc::Quaternion& quat);
138
144 bool GetRotation2D(frc::Rotation2d& rotation);
145
151 bool GetRotation3D(frc::Rotation3d& rotation);
152
160 bool GetAngularVel(units::degrees_per_second_t& x,
161 units::degrees_per_second_t& y,
162 units::degrees_per_second_t& z);
163
171 bool GetLinearAccel(units::meters_per_second_squared_t& x,
172 units::meters_per_second_squared_t& y,
173 units::meters_per_second_squared_t& z);
174
183 bool GetCompass(units::tesla_t& x,
184 units::tesla_t& y,
185 units::tesla_t& z,
186 units::tesla_t& norm);
187
197 bool SelfTest(int ret[8]);
198
203 bool ResetYaw();
204
209 bool SetODRHz(uint16_t odr_hz);
210
216 bool GetSensorUUID(int uuid[3]);
217
222 units::celsius_t GetTemperature();
223
228 bool Enable9DYaw(bool enable);
229
230};
Definition Navx.h:26
bool SetODRHz(uint16_t odr_hz)
Set the CAN and USB user data output rate, must be less than 1000Hz (IMU update rate).
Definition Navx.cpp:155
Port
Enum for the user to select which USB port they connect the.
Definition Navx.h:32
@ kUSB2
Definition Navx.h:34
@ kUSB1
Definition Navx.h:33
bool EnableOptionalMessages(bool yaw, bool angle, bool quat6d, bool quat9d, bool algoStates, bool pitchRoll, bool angularVel, bool linearAccel, bool compass, bool temperature)
Used to pick what sort of data is needed to be sent via the CAN bus.
Definition Navx.cpp:159
bool ResetYaw()
Reset IMU Yaw back to 0.
Definition Navx.cpp:151
bool GetCompass(units::tesla_t &x, units::tesla_t &y, units::tesla_t &z, units::tesla_t &norm)
Get yaw offset magnetic field values from the magnetometer.
Definition Navx.cpp:131
units::celsius_t GetTemperature()
Get the gyroscope chip temperature.
Definition Navx.cpp:188
units::degree_t GetRoll()
Gets the converted roll angle from the IMU filtering algorithm.
Definition Navx.cpp:36
~Navx()
Default destructor.
Definition Navx.cpp:22
bool GetQuat9D(frc::Quaternion &quat)
Get 9-axis quaternions from filter i.e.
Definition Navx.cpp:88
units::degree_t GetAngle()
Gets the converted continous angle from the IMU filtering algorithm.
Definition Navx.cpp:41
units::degree_t GetYaw()
Gets the converted yaw angle from the IMU filtering algorithm.
Definition Navx.cpp:26
bool GetQuat6D(frc::Quaternion &quat)
Get 6-axis quaternions from filter i.e.
Definition Navx.cpp:73
Navx(Navx &&)=default
bool GetAngularVel(units::degrees_per_second_t &x, units::degrees_per_second_t &y, units::degrees_per_second_t &z)
Get angular velocity measurements from the gyroscope when not at rest.
Definition Navx.cpp:103
Navx & operator=(Navx &&)=default
bool GetSensorUUID(int uuid[3])
Get internal sensor UUID.
Definition Navx.cpp:184
bool GetRotation3D(frc::Rotation3d &rotation)
Constructs a Rotation3d from the NavX Quaternion.
Definition Navx.cpp:57
bool SelfTest(int ret[8])
Trigger IMU self test functionality on gyroscope and accelerometer unit.
Definition Navx.cpp:147
Navx(int deviceId)
NavX3 object constructor with default 100Hz update rate.
Definition Navx.cpp:6
bool Enable9DYaw(bool enable)
Enable Yaw to use 9D instead of 6D.
Definition Navx.cpp:193
units::degree_t GetPitch()
Gets the converted pitch angle from the IMU filtering algorithm.
Definition Navx.cpp:31
bool GetRotation2D(frc::Rotation2d &rotation)
Get the heading of the robot as a Rotation2d.
Definition Navx.cpp:46
bool GetAlgoStates(float states[9])
Get selected filtering algorithm parameters to observe settings or calibration.
Definition Navx.cpp:69
bool GetLinearAccel(units::meters_per_second_squared_t &x, units::meters_per_second_squared_t &y, units::meters_per_second_squared_t &z)
Get linear acceleration measurements from the accelerometer when not at rest.
Definition Navx.cpp:117
Definition Navx.h:13