Calibration

Overview

It is sometimes useful to programmatically trigger calibration of the Canandgyro. Calibration must be done while the device remains still.

The following code excerpt shows how to utilize the calibration system.

// Creates a Canandgyro object referencing a Canandgyro with CAN ID 0
Canandgyro canandgyro = new Canandgyro(0);

//Starts calibrating the gyroscope asynchronously
canandgyro.startCalibration();

// Block the thread until calibration has finished, or until 7 seconds
// have passed.
// We recommend waiting at least 7 seconds for the calibration routine.
// Because of this long wait, we recommend you do not do this
// on a main thread.
canandgyro.waitForCalibrationToFinish(7);

//Alternatively, use isCalibrating to detect calibration asynchronously
if (canandgyro.isCalibrating()) {
    // Run code if device is calibrating
} else{
    // Run code if device is not calibrating
}
// Creates a Canandgyro object referencing a Canandgyro with CAN ID 0
Canandgyro canandgyro{0};

//Starts calibrating the gyroscope asynchronously
canandgyro.StartCalibration();

// Block the thread until calibration has finished, or until 7 seconds
// have passed.
// We recommend waiting at least 7 seconds for the calibration routine.
// Because of this long wait, we recommend you do not do this
// on a main thread.
canandgyro.WaitForCalibrationToFinish(7_s);

//Alternatively, use isCalibrating to detect calibration asynchronously
if (canandgyro.IsCalibrating()) {
    // Run code if device is calibrating
}else{
    // Run code if device is not calibrating
}