Can anyone suggest how to use the gyro to control turning of a bot? The problem I am having is that I compare the current heading with the target heading to control the turn. The problem I am having is when the gyro goes from 0 to 360, or 360 to 0. I have a Vex IQ bot, and am programming using Vex IQ Blocks.
Hi Ernest, welcome to the VEX Forum!
The easy solution, assuming your drivetrain only has two motors, is to create a drivetrain object, rather than setting up the drive motors and gyro independently. Then you get the functionality you want pretty much for free:
Thanks for the suggestion. I am familiar with the use of two drive motors and a gyro. My bot has one drive motor, that drives two wheels through a differential. It has two steering wheels that are driven by the steering motor. So for this design, I cannot use the drive train capability. Here is a picture of my bot.
My questions really is about how to use the gyro, when programming using Vex IQ Blocks.
Here are some of the blocks you can use once you add the gyro by itself. You will not use the drivetrain at all.
So you would set your steering wheels and then make the drive motor go. You could then use a waituntil block to wait for a certain heading, then stop the drive motor after that.
Try it out and post what you have so far if you have additional questions.
How weird. I can’t upload the share file I created from the project, but here is a screen grab with part of the program listing. I included several comments in the attached note, but the file from the share does not include notes.
You will see that I repeatedly reset the Gyro to keep the value from going over 360 or less than 0 when I turn left or right.
I have an idea now of what I can try when the gyro reading goes from 360 to 0, or from 0 to 359. I will post it if it works.
Here is another attempt to upload a more readable copy of the program listing.
It looks like I have to post more messages before I can upload the share file.
RazAutoF8Rev1.0.iqblocks (37.1 KB)
I have attached a copy of the RazAutoF8Rev1.0 program. It drives the bot in a figure 8 pattern. I am still working on a better approach to using the gyro.
Here is how I resolved the problem of when the Gyro rolls over. RazAutoF12Rev1.0.iqblocks (56.4 KB)
What I do is when I detect the rollover, I add or subtract 360 from the gyro reading. Pretty easy, now that I have figured out how to do it.
This version of the figure8 pattern does a full 360 turn to the right, followed by a 360 turn to the left.