How to Properly Initialize Gyro on PROS V5 (URGENT)

Hello, I do not know if i am properly initializing the gyro on pros because our values when outputting are counting up and not at a stable value when standing still. However, when i initialize the gyro on Vex Coding Studio the gyro does not count up and it stays at a stable value when not moving. I followed the code on PROS API. Any help would be appreciated.

We have a competition coming up and the Gyro is crucial to our autonomous routine. Any help would be appreciated since the problem is not yet resolved.

here is code i have so far

main.h

extern pros::ADIGyro Gyrox;

Init.cpp

void initialize() {

  pros::ADIGyro Gyrox( 3, 1);
  pros::delay(2000);

}

operator.cpp

extern pros::ADIGyro Gyrox;

void opcontrol() {

while (true) {

	std::cout << "value: " << Gyrox.get_value();

	pros::delay(20);
}

}

Move your initialization of Gyrox outside of initialize and you’ll be fine. What you’re doing right now is declaring a local-scope version of Gyrox in initialize and never declaring nor initializing the global scoped version.

1 Like

main.h

extern pros::ADIGyro Gyrox;

Init.cpp

pros::ADIGyro Gyrox( 3, 1);
pros::delay(2000);
void initialize() {

}

operator.cpp

void opcontrol() {

while (true) {

	std::cout << "value: " << Gyrox.get_value();

	pros::delay(20);
}

}

like this?

from this post you don’t need to wait for the gyro to calibrate. The wait is built in.

You can’t delay outside of a function or method.