nn::hid::CTR::GyroscopeReader Classclass GyroscopeReader : private ADLFireWall::NonCopyable
Class for loading sampling data from the gyro sensor.
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.
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.
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::HidBase::WaitSampling function in the nn::hid::CTR::Gyroscope class, 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.
This class includes the following correction processing for getting information more accurately.
| Acceleration Correction | Uses the accelerometer to improve the accuracy of CTR attitude calculations. |
|---|---|
| Zero-Point Drift Correction | The gyro sensor's zero point can drift due to environmental factors. This correction automatically detects zero-point drift and adjusts angular velocity values accordingly. |
This class includes the following features to process output values.
| Zero-Point Play Tolerance | When the sampling results are within any radius centered on the zero-point, that is output as the zero-point. This is used when, for example, you don't want to reflect small movements in the output. |
|---|---|
| Axial Rotation | The sampling results are multiplied by any rotational matrix and then output. You can get output that reflects placement of the gyro sensor at an angle. |
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. |
A future update to the HOME menu will add a feature enabling users to recalibrate the accelerometer whenever they like.
As a result, correction in accordance with the user's environment may start while the user is transitioned from the application to the HOME Menu using the HOME Button.
After this operation, the values retrieved from the nn::hid::CTR::GyroscopeReader::Read and nn::hid::CTR::GyroscopeReader::ReadLatest functions will be the corrected values. In most cases, the corrected values will accurately reflect the user's environment.
The applications, however, need not take any special measures to deal with this.
This class maintains an internal instance of the nn::hid::CTR::AccelerometerReader class for acceleration correction. The accelerometer is started when an instance is generated.
| 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 to an arbitrary value the angle member of the GyroscopeStatus Structure (obtained by the Read and ReadLatest functions). |
|
SetDirection
|
Resets to an arbitrary value the direction member of the GyroscopeStatus structure (obtained by the Read and ReadLatest functions). |
|
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 and ReadLatest functions. |
|
| 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. |
|
ADLFireWall::NonCopyable
nn::hid::CTR::GyroscopeReader
CONFIDENTIAL