VEX IQ BaseBot · closed loop control
Measure.
Correct. Repeat.
Hi Explorer. Your BaseBot's two motors are not twins, so it drifts. In these missions you read the gyro, work out the error, and steer it back, first with an if, then with P, I, and D. Every block here has the same name in VEXcode IQ.
The control loop, in one breath
- Read the sensor. BrainInertial rotation says how far the robot has turned.
- Find the error. error = target minus reading.
- Push back. correction = Kp × error. Later add Ki × integral and Kd × derivative.
- Wait a little, then repeat. The wait keeps the loop timing steady, on the Brain and in this lab.
Hints are always free, stars never go down, and every mission is checked on more than one robot so a fix that only works for one is caught.
Flight path // mission log
Six units, from drift to full PID
Unit
Mission
Drag a block near the bottom of another to snap it. Drag it back to the palette to delete it. Tap a palette block to add it to the end of your program. Select a block and press Copy, then Paste here or in another Logicnaut lab.
- time
- 0.00 s
- x forward
- 0 mm
- y sideways
- 0 mm
- rotation
- 0.0°
- LeftMotor
- 0%
- RightMotor
- 0%
BrainInertial rotation in degrees over time. Positive is a right turn. Dashed line is the target.
Test bench: nothing is checked here. Try the same program on all three robots.
The robot
BaseBot setup
- LeftMotor and RightMotor are separate motor devices, so nothing hides the drift. “spin”, “set velocity”, and “position in degrees” talk to one motor each.
- BrainInertial is the gyro built into the IQ 2nd gen Brain. “rotation” counts total turn in degrees, right is positive. “heading” is the same turn wrapped to 0 to 359.
- Encoders live inside each motor and count wheel degrees. One wheel turn is 360 degrees and 200 mm of travel.
- The Brain screen shows whatever your print blocks send. Printing a number every loop is the fastest way to see what a controller is thinking.
On the real robot
In VEXcode IQ
Not yet? Trace one loop by hand
Hints are always free
Read it, then close it and build your own. Tuning numbers are a starting point, not the only answer.