nn::hid::CTR::GyroscopeReader Class

Syntax

class GyroscopeReader : private ADLFireWall::NonCopyable

Description

Class for loading sampling data from the gyro sensor.

Sampling Rate

Samples the angular velocity of the gyro sensor an average of every 10 milliseconds. Use the nn::hid::CTR::Gyroscope class to know when sampling occurs, allowing you to accurately monitor sampling timing.

Output Value Details

This class stores sampling results as a nn::hid::CTR::GyroscopeStatus structure. This structure contains not just the angular velocity, but also information about the attitude calculated from the angular velocity. Attitude is calculated when the nn::hid::CTR::GyroscopeReader::Read or nn::hid::CTR::GyroscopeReader::ReadLatest functions are called, and either one must be called regularly (ideally every frame). Data stored in the internal buffer can become discontinuous, resulting in less accurate attitude information, if too much time elapses between calls to either of these functions.

Conditions to Start Sampling

Gyro sensor sampling halts in two cases: when the system is in Sleep Mode, and when there are no instances of the GyroscopeReader class. You must destroy all instances to explicitly stop sampling.
It takes up to approximately 160 milliseconds for the system to transition to a state where sampling is possible. No sampling is done during this transition time, and calls to the nn::hid::CTR::GyroscopeReader::Read or nn::hid::CTR::GyroscopeReader::ReadLatest functions have no effect. To be sure to obtain sampling results, Nintendo recommends calling the nn::hid::CTR::Gyroscope::WaitSampling function, which waits until results have been sampled at least once. Starting from the second instance, this sampling wait time is the same as the wait until the next sample, which is a maximum of approximately 10 milliseconds.

Correction Processing

This class includes the following correction processing for getting information more accurately.

Acceleration CorrectionUses the accelerometer to improve the accuracy of CTR attitude calculations.
Zero-Point Drift CorrectionThe gyro sensor's zero point can drift due to environmental factors. This correction automatically detects zero-point drift and adjusts angular velocity values accordingly.

All correction processes are enabled by default, but can be configured or disabled as necessary. For details, see the various function references.

Output Value Processing Features

This class includes the following features to process output values.

Zero-Point Play ToleranceSampling results within an optional radius from the zero point are output as the zero point. Use this to avoid outputting small movements.
Axial RotationApply an optional rotational matrix to sampling results before output. Allows for the output of values as if the gyro sensor were on an incline.

All processing features are disabled by default. Configure and enable them as needed. For details, see the various function references.

Axis Orientation

The default gyro sensor axes are as follows.

X+A clockwise rotation about the direction indicated by the Left Button on the +Control Pad.
Y+A clockwise rotation about the direction normal to and outward from the Touch Screen.
Z+A clockwise rotation about the direction indicated by the Up Button on the +Control Pad.

Miscellaneous Notes

This class maintains an internal instance of the AccelerometerReader class for acceleration correction. The accelerometer is consequently started up once this instance is generated.

Member Functions

Constructors/Destructors
GyroscopeReader Constructor.
~GyroscopeReader Destructor.
Reading Sampling Data
Read Loads sampling data from the gyro sensor, starting with the most recent data. Does not load any data that has been previously loaded.
ReadLatest Loads the most recent sampling data from the gyro sensor. This function, unlike the nn::hid::CTR::GyroscopeReader::Read function, can load the same sampling data more than once.
Reset
Reset Initializes the internal state.
Output Value Settings
SetAngle Resets the angle member of the GyroscopeStatus structure (obtained by the Read function) to an arbitrary value.
SetDirection Resets the direction member of the GyroscopeStatus structure (obtained by the Read function) to an arbitrary value.
SetAngleMagnification Sets individual scaling factors to apply for each axis when calculating angular velocity.
SetDirectionMagnification Sets the scaling factor to apply to the angular velocity used when calculating the direction member of the GyroscopeStatus structure, which is obtained by the Read function.
Zero-Point Play Tolerance
EnableZeroPlay Enables zero-point play tolerance.
DisableZeroPlay Disables the zero-point play tolerance.
IsEnableZeroPlay Checks whether zero-point play tolerance is enabled.
GetZeroPlayEffect Gets the strength of correction applied by the zero-point play tolerance.
SetZeroPlayParam Sets the zero-point (at-rest) play tolerance.
GetZeroPlayParam Gets the zero-point play tolerance.
ResetZeroPlayParam Initializes the zero-point play tolerance.
Zero-Point Drift Correction
EnableZeroDrift Enables zero-point drift correction.
DisableZeroDrift Disables zero-point drift correction.
IsEnableZeroDrift Checks whether zero-point drift correction is enabled.
GetZeroDriftEffect Gets the strength of zero-point drift correction.
ResetZeroDriftMode Initializes the zero-point drift correction mode.
SetZeroDriftMode Sets the zero-point drift correction mode.
GetZeroDriftMode Gets the zero-point drift correction mode.
Acceleration Correction
EnableAccRevise Enables acceleration correction.
DisableAccRevise Disables acceleration correction.
IsEnableAccRevise Checks whether acceleration correction is enabled.
GetAccReviseEffect Gets the strength of acceleration correction.
SetAccReviseParam Sets the weight and enabled range for acceleration correction.
GetAccReviseParam Gets the weight and enabled range for acceleration correction.
ResetAccReviseParam Initializes the weight and enabled range for acceleration correction.
Axial Rotation
EnableAxisRotation Enables axial rotation.
DisableAxisRotation Disables axial rotation.
IsEnableAxisRotation Checks whether axial rotation is enabled or disabled.
SetAxisRotationMatrix Sets the rotation matrix used for axial rotation.
GetAxisRotationMatrix Gets the rotation matrix used for axial rotation.
ResetAxisRotationMatrix Initializes the rotation matrix used for axial rotation. When this function is called, the rotation matrix is set to a nn::math::MTX34 identity matrix. This setting is equivalent to disabling axial rotation.

Class Hierarchy

ADLFireWall::NonCopyable
  nn::hid::CTR::GyroscopeReader

Revision History

2010/12/06
Added explanation of conditions under which sampling stops.
2010/10/20
Initial version.

CONFIDENTIAL