Gyro Acting Weird (V5)

@Joshua_L does the gyro do it by itself with a specific command or do u need to do it manually?

Theres a method called startCalibration

Gyro performs an automatic calibration every time you start your program, there’s no real need to call startCalibration unless you want/need to recalibrate.

Doing calibration outside of startup could be useful when you know your startup conditions were unstable, like you were carrying it to a field or similar.

true, but all you should have to do is stop and restart the program.

@jpearman @John TYler so the recalibration is just a safety net?

No it’s just a way to relcalibrate your gyro mid program if you need to.

@Joshua_L ok thx

I was troubleshooting the gyro problem by posting the real-time values of the gyros in degrees to the brain screen. I noticed that the gyro values would suddenly change from single digit changes to ten’s digit changes and occasionally hundred’s digit changes while maintaining their one’s digit or ten’s digit values. In other words, the displayed values will randomly start changing by 10s or 100s as a multiple of the gyro’s single digit degree change.

@Ben.162A What units are you using?

Ok, so today I got ahold of the robot again and after following the suggestions (not putting any arguments in startCalibration and changing units to analog) I found that there was in fact nothing wrong with the gyro at all.

I was using degrees. I looked into the actual inputs on the brain and it was returning wonky values as well.

Hmm are you clearing the screen of the brain every time you update the value?

  while (true) {
    Brain.Screen.clearLine(1, vex::color::black);
    Brain.Screen.setCursor(1, 0);

Try this code. This is one that we’ve been using to test our gyro values.

Yeah, if you dont clear the screen then the values will print on top of each other, which may be why youre getting weird values.


look at these Posts about gyros and use the code that Josh posted up there to test

Post 1 Analog Value instead of degrees
Post 2 on how to implement that

and the comment by kselva

Btw make sure you make your own changes because the second post wasn’t the correct code, the discussion just helped me understand how to use it.

The previous digit jumping issue is now gone but now the values climb without stopping, resetting at 360.

@Ben.162A Don’t forget that the analog value gives u the degrees *10 so if it is a 180 turn, it should give you 1800 analogUnits at range12bit

Also since the gyro cant reset, u have to add the value that u want to turn to the current gyro value and turn the motors until it reaches that value

Looks like the problem is solved. But why isn’t it possible to reset gyros?

because we didn’t program that functionality into the V5, I’m not sure that ROBOTC could reset the gyro either, I forget.

@Ben.162A I don’t know my self, there’s not a preset class or function for it. You should ask a guy like @jpearman