Can you reset Gyro in mid autonomous?

I heard that you have to keep the robot still while reseting, is that true?

You want to initialize while sitting still for a while. For resetting, my understanding is it depends what system you’re using. But ultimately it doesn’t really matter. In PROS initializing and resetting are two different things (gyroInit v. gyroReset). Even if you can’t reset in RobotC, you can create a variable target roughly like this:

targetAngle = gyroscope’s value + 90;
while (gyroscope’s value < targetAngle) {

Regardless, you really should sit still for a moment during the reset or reading to set targetAngle above to make sure it doesn’t change between that and when you start using it. But this would be a short time, not the kind of time the initialization takes.

Yes, you can reset the gyro in RobotC. Here is what some of my teams have been using for years, assuming the gyro is in analog port 8.

void ResetGyro()
  SensorType[in8] = sensorNone;
  //Reconfigure Analog Port 8 as a Gyro sensor and allow time for ROBOTC to calibrate it
  SensorType[in8] = sensorGyro;

I would recommend against that solution. First, you’ve just used up 3 s of your 15 s of autonomous. That’s 20% of your time doing something that could be handled differently in a ms or so. Second, your robot is supposed to remain still while calibrating the gyro, and you have no way to know for sure that another robot isn’t going to shove you; there are three others of them moving around in the same 12’x12’ region while you’re expecting to be stationary.

This is why I explained the difference between resetting and reinitializing in PROS. Even if you can’t reset, only reinitialize, in RobotC, you can effectively reset with a slightly different approach.

If all you want is to make the gyro return zero in its current orientation, you can do that in RobotC with:

SensorValue[gyro] = 0;

This will not recalibrate at all, but can be helpful in planning turns. This lets you easily think about turns relative to current orientation instead of absolute orientation from last recalibration.

Note that my teams didn’t use this during autonomous. It was used to provide a manual way to reset the gyro in case it was too far off. This came into play mainly with my teams that were using a field-oriented drive which uses the gyro constantly while driving or in programming skills by backing into a wall to straighten up then resetting the gyro. One of my teams used this heavily in Gateway with great success.