I’ve started trying to understand how programming with the gyro works. I have a program that fails miserably. But the Driver Control program on the same robot works great! That tells me that my sensors are working as they should be. I am kinda stumped.
I wrote a separate piece of test code that just prints out the angle and rotation. The angle value shown on the LCD started at 360, but dropped a degree or two every second or so with the robot sitting still on the floor. Similarly, the rotation value increased by the exact amount.
Is the code for the Driver Control sample program available? Studying it would help me more than anything else I can think of at this point.
It would also answer another question I have. I tried to write a piece of code to slow a robot down. Every half-second or so, I changed the speed to the motor from 100% to 75%, then 50%, then 25% and finally zero. But it seemed like the robot needed to stop to change its speed setting. I ended p with some very jerky motion. Is that how it really works? if so, is there a simple way to write a routine that slows a robot down? I notice that the sample program rotates the bot slower if it doesn’t have as far to go to get back to 0° as it does when it has a long way to rotate. I am very curious as to how this was programmed. I am using Modkit for Vex.
Hi HawaiiThad,
We’re sorry that you have encountered these issues.
All electronic gyro sensors have a phenomenon called “drift”. What happens when a gyro drifts, is that even though the gyro is sitting still, the angle will slowly move (drift) over time. Some of this drift can be calibrated for, and some is random.
The VEX IQ Gyro Sensors are factory calibrated to reduce as much drift as possible, but it is helpful at the start of every program to calibrate your gyro (it is a function inside Modkit and ROBOTC that you can add to your program).
What calibration does is that it monitors the Gyro for about two seconds, during which time the robot must sit perfectly still. Since the robot assumes that the robot is sitting still, it uses any difference in Gyro Sensor angles during this two second time to neutralize as much of the drift as possible. Since some aspect of gyro drift is random, this is helpful to run every time your program starts if you would like the highest accuracy readings.
A calibrated VEX IQ Gyro Sensor should drift a very small amount, such as under 1 degree every minute. If the gyro sensor was moving at any time during the calibration time period in your program, it will wrongly neutralize drift and the sensor readings may appear to be constantly spinning even through the gyro is sitting still.
Unfortunately the Driver Control program was not written in ROBOTC or Modkit, so it would be difficult to share. Instead, I have created a sample Modkit program and have attached the screenshot. This program will use a Gyro Sensor, calibrate it, then continuously list the current angle on the screen.
Regards,
- Art