I’m trying to program an autonomous using a vex IQ gyro. I am using modkit.
The gyro works fine for the first turn but then when it’s about to do the second turn the robot just turns in continuous circles.
This is the code i have;
The code works up to the point where it says “While gyro rotation in deg = 50”
What does the gyro output right after you reset it?
what do you mean?
If you asked the sensor for the current rotation in degrees after resetting it, what does it say?
so i did some experimenting and i found that I’ve told the robot to spin right until it reaches 50 degrees but when the robot spins it spins forever because it goes into negative degrees. How do I combat this? I’ve tried changing the orientation of the gyro but it doesn’t make a difference.
what do I do?
Maybe try setting the 50 to -50?
With the gyro, positive values are when turning left, and negative is when turning right (arrow on top of gyro turns counter clockwise). Looking at your code, you can fix that by setting the while loop to a value of less than negative X degrees ( < -100) when turning right. When turning left it will be less than positive X degrees.
BTW, VexCode IQ Blocks has replaced Modkit.
I don’t have any experience with Modkit (I use PROS for V5), but I’ll try my best to help. To me, it appears that there are two issues in the turn.
The first issue I notice is minor, but would cause this problem, you never tell the robot to “stop”, unless that is cut off by the screenshot.
The second issue is slightly more complex. In the first two-stage turn, you have your robot turn right until the position is at 135 degrees, which in this system is considered a “positive” turn. So, a turn in the opposite direction, or left, will because the gyro value to decrease, or be a “negative” turn. Because when the robot turns left, the gyro value is negative, the gyro will never go above 50 because it will keep decreasing, resulting in a never-ending loop. I take it you may be in elementary or middle school, so if you need help understanding negative numbers, I would look it up on YouTube or Khan Academy. A simple fix would be to turn the “< 50” to a “> -50”, so the robot turns until the gyro value reaches -50 degrees, or a 50 degree left turn. Also, make sure to add a “stop” afterwards, I can’t tell if you have one or not in your code.
Hope I was able to help!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.