I dont want my gyroscope to show - degree like if it is in 0 when I do -90 it should go to 270 not -90 degree,How can I do it?
My team had a similar issue but all I’ll say is try using YAW
Math is your friend MOD((ABS(360+sensor_value)),360) will do what you want. Programming language of your choice.
Edited to add: While displaying this may make sense (ie 270 vs -90) from an internal programming the robot having degrees from “North” makes some programming easier since you can use < or > zero to know which way it’s going/drifting and make the comparable change.
In VEXCode Blocks just use the heading of the gyro.
Trust me, you will have a lot less strange behavior if you work with - 90 instead of 270 degrees.
But if u wanna u can just check if it’s less than 0 and add 360, or check if it’s above 360 and subtract 360
We are using c++ and it gives
use of uncleared identifier ‘MOD’
What should we do ?
Use headings since their domain is [0, 360).
The % operator is the mod operator
Display = (360 + gyroscope-value) % 360;
You shouldn’t need the “360+”, or do you???
Display = gyroscope-value % 360;
It’s an artifact from prior sensors that would return more than 360 degrees so that’s why the mod is there. The 360+value converts -90 to 270, which was the original request
I should have made the variable gyroscope_value to make sure people don’t know there is a subtraction.
There just isn’t a difference if you add the 360…
|degrees||degrees mod 360||(degrees+360) mod 360|
So lets go back. I got asked a question how to go from -90 to 270 and I did the 360-degree. Then my brain went "what if they give number greater than 360, and the mod was added.
You are correct, for this system you won’t need the “add”. Others may.