Gyroscope Code


#1

Hey everybody,
I am seeing a lot of people having trouble with the gyroscope. I would just like to share that using rotationUnits with the gyroscope will require scaling the gyroscope which is a very long process. I would recommend using analogUnits when obtaining gyroscope values. Also, use rang12bit for more accuracy. It outputs the gyroscope value in tenths of a degree, so 180 degrees will actually be 1800. My team has had a lot of success with this method. I hope this helps anybody who needs assistance.


#2

@Kselva20 Do the analog units dont require the calibration of the gyro?

So if im understanding it correctly, you can do this?


if(Gyro.value(vex::analogUnits::rang12bit) > degrees_to_rotate){
while( Gyro.value(vex::analogUnits::rang12bit) > degrees_to_rotate){
   turn left

}
}else if (Gyro.value(vex::analogUnits::rang12bit) <degrees_to_rotate){
turn right
}

Also is there a way to rest them or no?


#3

Could you elaborate why one unit would be calibrated and the other not? They ‘should’ be the same number just in different formats.


#4

Not sure, just worked out for us to switch to analog units. It could be because the rotation units can be formatted. I would reach out to vex if you would like to know the reasoning.


#5

They do require to be calibrated @Lukyan_1. There is no way to reset them. You would have to find your error using the current value and the target value. It is not too hard to work around, but if you need help I can post my code.


#6

@Kselva20, thank you, i figured out the gyro.

Do you know by any chance how to choose different autonomous on the brain and whichever you choose would be imported into the main program to run?


#7

@Lukyan_1 You could have all autons on a competition template. In pre auton, I have the gyro calibrate and then have an auton selection printing on the brain waiting for input. Then, the loop breaks once input has been received, a global variable will be declared. Then, use a switch loop to go through the variable in the auton task. Depending on the value, it will call a specific auton task. I have not attempted to use the #include command to incorporate files and call the methods from a separate file, so I am not sure if it as simple as that. If you end up figuring it out, please let me know because that sounds like it is much more efficient and easier to read for tech journals.


Autonomous Programs On the brain
#8

@Kselva20 that is my goal, I don’t want to have a bunch of programs with the same constants and void but different autons, I’m trying to make it simpler.

If I do figure it out, ill contact you.