Here’s some code I threw together for GYRO turns.
By making the velocity dependent on the rotation, you get a nice slowdown so you don’t overshoot your target. If you did, the bot would correct.
Here’s a video of the code running:
Here’s some code I threw together for GYRO turns.
By making the velocity dependent on the rotation, you get a nice slowdown so you don’t overshoot your target. If you did, the bot would correct.
Here’s a video of the code running:
A couple of questions:
I think i get it…if the gyro is on the top then it goes from 360 to 270 - so the value is reducing.
Ours oscillates.
Even if we reduce our multiplier to 0.5…i don’t think it comes out of the forever loop to do the next step in the code. Will a ‘while gyro < 90’ work the same way, instead of a forever.
How can we get the Gyro Rotation to be a range rather than it trying to accurately turn 90. So if it is between 89 and 91…then break out of the forever loop.
This will only work if you are aiming for zero… So as the value gets closer to zero it will slow down. You are trying to get the bot to get to and stay on 0.
You also need to be sure to use rotation, not heading.
Rotation will go 3, 2, 1, 0, -1, -2, -3
Heading will go 3, 2, 1, 0, 355, 354, 353…