StudicaLib
Loading...
Searching...
No Matches
studica::Navx Class Reference

#include <Navx.h>

Public Types

enum class  Port : int { kUSB1 = 2 , kUSB2 = 3 }
 Enum for the user to select which USB port they connect the. More...

Public Member Functions

 Navx (int deviceId)
 NavX3 object constructor with default 100Hz update rate.
 Navx (Port port)
 NavX3 object constructor for USB communication with default 100Hz update rate.
 Navx (int deviceId, int updateRate)
 NavX3 object constructor with custom update rate.
 Navx (Port port, int updateRate)
 NavX3 object constructor for USB communication.
 Navx (Navx &&)=default
Navxoperator= (Navx &&)=default
 ~Navx ()
 Default destructor.
units::degree_t GetYaw ()
 Gets the converted yaw angle from the IMU filtering algorithm.
units::degree_t GetPitch ()
 Gets the converted pitch angle from the IMU filtering algorithm.
units::degree_t GetRoll ()
 Gets the converted roll angle from the IMU filtering algorithm.
units::degree_t GetAngle ()
 Gets the converted continous angle from the IMU filtering algorithm.
bool GetAlgoStates (float states[9])
 Get selected filtering algorithm parameters to observe settings or calibration.
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.
bool GetQuat6D (frc::Quaternion &quat)
 Get 6-axis quaternions from filter i.e.
bool GetQuat9D (frc::Quaternion &quat)
 Get 9-axis quaternions from filter i.e.
bool GetRotation2D (frc::Rotation2d &rotation)
 Get the heading of the robot as a Rotation2d.
bool GetRotation3D (frc::Rotation3d &rotation)
 Constructs a Rotation3d from the NavX Quaternion.
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.
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.
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.
bool SelfTest (int ret[8])
 Trigger IMU self test functionality on gyroscope and accelerometer unit.
bool ResetYaw ()
 Reset IMU Yaw back to 0.
bool SetODRHz (uint16_t odr_hz)
 Set the CAN and USB user data output rate, must be less than 1000Hz (IMU update rate).
bool GetSensorUUID (int uuid[3])
 Get internal sensor UUID.
units::celsius_t GetTemperature ()
 Get the gyroscope chip temperature.
bool Enable9DYaw (bool enable)
 Enable Yaw to use 9D instead of 6D.

Member Enumeration Documentation

◆ Port

enum class studica::Navx::Port : int
strong

Enum for the user to select which USB port they connect the.

Enumerator
kUSB1 
kUSB2 

Constructor & Destructor Documentation

◆ Navx() [1/5]

Navx::Navx ( int deviceId)
explicit

NavX3 object constructor with default 100Hz update rate.

Parameters
[in]deviceIdCAN ID of the IMU.

◆ Navx() [2/5]

Navx::Navx ( Port port)
explicit

NavX3 object constructor for USB communication with default 100Hz update rate.

Parameters
[in]portThe USB port in use

◆ Navx() [3/5]

Navx::Navx ( int deviceId,
int updateRate )

NavX3 object constructor with custom update rate.

Parameters
[in]deviceIdCAN ID of the IMU.
[in]updateRateCAN message output rate.

◆ Navx() [4/5]

Navx::Navx ( Port port,
int updateRate )

NavX3 object constructor for USB communication.

Parameters
[in]portThe USB port in use
[in]updateRateUSB update rate

◆ Navx() [5/5]

studica::Navx::Navx ( Navx && )
default

◆ ~Navx()

Navx::~Navx ( )

Default destructor.

Member Function Documentation

◆ Enable9DYaw()

bool Navx::Enable9DYaw ( bool enable)

Enable Yaw to use 9D instead of 6D.

Returns
true on error

◆ EnableOptionalMessages()

bool Navx::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.

Parameters
yawBoolean value to enable yaw messages.
angleBoolean value to enable angle messages.
quat6dBoolean value to enable 6-axis quaternion messages.
quat9dBoolean value to enable 9-axis quaternion messages.
algoStatesBoolean value to enable algorithm states messages.
pitchRollBoolean value to enable pitch and roll messages.
angularVelBoolean value to enable angular velocity messages.
linearAccelBoolean value to enable linear acceleration messages.
compassBoolean value to enable mag compass measurement messages.
temperatureBoolean value to enable temperature messages.
Returns
true on error

◆ GetAlgoStates()

bool Navx::GetAlgoStates ( float states[9])

Get selected filtering algorithm parameters to observe settings or calibration.

Parameters
[out]statesArray of 9 elements:
  • [0..2] Estimated gyroscope bias (x,y,z)
  • [3] 1 if detected at rest, else 0
  • [4] 1 if no magnetic disturbance, else 0
  • [5] mag_ref_norm
  • [6] mag_candidate_norm
  • [7] mag_ref_dip
  • [8] mag_candidate_dip
Returns
true on error

◆ GetAngle()

units::degree_t Navx::GetAngle ( )

Gets the converted continous angle from the IMU filtering algorithm.

Returns
The angle in degrees (typically infinite). A NaN indicates an error.

◆ GetAngularVel()

bool Navx::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.

Parameters
[out]xX-axis angluar velocity.
[out]yY-axis angluar velocity.
[out]zZ-axis angluar velocity.
Returns
true on error

◆ GetCompass()

bool Navx::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.

Parameters
[out]xX-axis magnetic flux density.
[out]yX-axis magnetic flux density.
[out]zX-axis magnetic flux density.
[out]normField vector magnitude.
Returns
true on error

◆ GetLinearAccel()

bool Navx::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.

Parameters
[out]xX-axis acceleration.
[out]yY-axis acceleration.
[out]zZ-axis acceleration.
Returns
true on error

◆ GetPitch()

units::degree_t Navx::GetPitch ( )

Gets the converted pitch angle from the IMU filtering algorithm.

Returns
The pitch angle in degrees (typically between [90 and -90]). A value of 360 deg indicates an error.

◆ GetQuat6D()

bool Navx::GetQuat6D ( frc::Quaternion & quat)

Get 6-axis quaternions from filter i.e.

without mag integration.

Parameters
[out]quatOutput quaternion {w, x, y, z}.
Returns
true on error

◆ GetQuat9D()

bool Navx::GetQuat9D ( frc::Quaternion & quat)

Get 9-axis quaternions from filter i.e.

with mag integration included.

Parameters
[out]quatOutput quaternion {w, x, y, z}.
Returns
true on error

◆ GetRoll()

units::degree_t Navx::GetRoll ( )

Gets the converted roll angle from the IMU filtering algorithm.

Returns
The roll angle in degrees (typically between [180 and -180]). A value of 360 deg indicates an error.

◆ GetRotation2D()

bool Navx::GetRotation2D ( frc::Rotation2d & rotation)

Get the heading of the robot as a Rotation2d.

Parameters
[out]rotationOutput heading.
Returns
true on error

◆ GetRotation3D()

bool Navx::GetRotation3D ( frc::Rotation3d & rotation)

Constructs a Rotation3d from the NavX Quaternion.

Parameters
[out]rotationOutput rotation.
Returns
true on error

◆ GetSensorUUID()

bool Navx::GetSensorUUID ( int uuid[3])

Get internal sensor UUID.

Parameters
[out]uuidRetrieved 96-bit UUID
Returns
true on error

◆ GetTemperature()

units::celsius_t Navx::GetTemperature ( )

Get the gyroscope chip temperature.

Returns
The temperature in C.

◆ GetYaw()

units::degree_t Navx::GetYaw ( )

Gets the converted yaw angle from the IMU filtering algorithm.

Returns
The yaw angle in degrees (typically between [180 and -180]). A value of 360 deg indicates an error.

◆ operator=()

Navx & studica::Navx::operator= ( Navx && )
default

◆ ResetYaw()

bool Navx::ResetYaw ( )

Reset IMU Yaw back to 0.

Returns
true on error

◆ SelfTest()

bool Navx::SelfTest ( int ret[8])

Trigger IMU self test functionality on gyroscope and accelerometer unit.

Parameters
[out]retArray of 8 elements:
  • [0] Gyroscope status.
  • [1..3] Gyroscope status (x,y,z).
  • [4] Accelerometer status.
  • [5..7] Accelerometer status (x,y,z).
Returns
true on error

◆ SetODRHz()

bool Navx::SetODRHz ( uint16_t odr_hz)

Set the CAN and USB user data output rate, must be less than 1000Hz (IMU update rate).

Returns
true on error

The documentation for this class was generated from the following files: