Hi,
my students are wondering how you code to check if your bot is driving straight and correct it if not, we also want to correct for over turning when we code to turn 90 degrees…
Hi,
my students are wondering how you code to check if your bot is driving straight and correct it if not, we also want to correct for over turning when we code to turn 90 degrees…
Hi Maria!
I think one of the best ways to approach this would be something with a series of If Else statements. That way the robot could constantly be assessing the current heading and adjust as needed. Almost like a line follower.
Here’s the sketch I made to think about when and how I would want the robot to move.
Then I tried a couple different things in VEXcode. I tried multiple When Started’s as Broadcasts, but the simplest solution I came up with was just using the Else If expandable block. So I made my robot turn to the right (for easy heading numbers), then used the Inertial sensor to constantly see if my robot was headed in that direction in the right range. If it was somewhat out of range, then it would slightly turn and continue through the loop.
There are definitely more ways to accomplish something like this with the inertial sensor (even making the turn left and rights more accurate), but I think this could be a cool starting point for you to then help inspire your students.
Also a quick video of my robot when I ran the code!