Calibration
Overview
Section titled “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 0Canandgyro canandgyro = new Canandgyro(0);
//Starts calibrating the gyroscope asynchronouslycanandgyro.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 asynchronouslyif (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 0Canandgyro canandgyro{0};
//Starts calibrating the gyroscope asynchronouslycanandgyro.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 asynchronouslyif (canandgyro.IsCalibrating()) { // Run code if device is calibrating}else{ // Run code if device is not calibrating}