# I dont want -degree in my gyroscope

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.

6 Likes

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.

5 Likes

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

1 Like

We are using c++ and it gives
use of uncleared identifier âMODâ
What should we do ?

Use headings since their domain is [0, 360).

1 Like

The % operator is the mod operator

Display = (360 + gyroscope-value) % 360;

1 Like

You shouldnât need the â360+â, or do you???

Display = gyroscope-value % 360;

1 Like

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
-72 288 288
-29 331 331
14 14 14
57 57 57
100 100 100
143 143 143
186 186 186
229 229 229
272 272 272
315 315 315
358 358 358
401 41 41
444 84 84
487 127 127
530 170 170
2 Likes

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.

1 Like