VexCode IQ drivetrain turning functions broken

Recently, I’ve been creating my Vex IQ auton for my upcoming competition. I tried making a PID but VEX IQ doesn’t really work that well with PIDs IMO (another topic). I’m using the built-in Vexcode IQ Drivetrain class in C++ to turn my auton, which turns forever. Drivetrain#turnToHeading, Drivetrain#turnToRotation, and Drivetrain#turnFor keep the robot spinning indefinitely. I’m using a Gen 1 Brain with an external Gyro (configured w/ the Drivetrain).

All topics related to this online have been unhelpful, thus I am referring to the Vex Forum to ask for help.

Any help would be greatly appreciated, thank you so much :slight_smile:

1 Like

Step one is to use the Devices menu on the Brain to ensure the Gyro is working properly.
Step two is to ensure left is right and right is left. On the drivetrain, make sure that your motors are configured correctly for the left port and right port otherwise the gyro will never hit it’s target.

PID in IQ is not really any different to any other platform and many teams use it very successfully for both turning and distance movements.

Generally speaking, if the robot is turning indefinitely, then it’s a sign that the robot is not configured properly in regards to motor reversal (using the Reversed? slider).

One of either your left motor or right motor has to be reversed. If one is not, try the right side first; if the right side is already reversed, unreverse it and make the left side reverse.

Also meant to include the in the original response, but my not-yet-fully-awake brain hit post already. Vex IQ can do PIDs just fine, even with Gen 1 hardware. I was curious about this myself and implemented a full distance+heading PID in VexCode (blocks) on a Gen 1 brain that was able to drive 9 feet in one direction, turn 180 degrees, drive 9 feet back, turn another 180 degrees and be within half an inch of its starting position. Now, it also helps that my day job is a SW engineer and in my past I’ve implemented a number of different PID loops, so I know what’s involved with tuning and how to diagnose quickly how they need adjusted (and no, I won’t be sharing that code :slight_smile: ).

It’s important to note that the built-in control via Drivetrain is supposed to get you close, but it’s a building block. Just like blocks is an easier starting point, getting the most out of everything would require you moving up to Python and possibly even C/C++. The steps are there for those that are driven to learn.

Gyro is working properly.
Left is right, right is left. This is the same code for the driver control, all works fine there. Driving with the Drivetrain also works, just not the turning.

The robot is configured properly, the left motor polarity is normal, right is reversed.

Oops, I meant Left is left, Right is right.

How/where is the gyro mounted ? It’s not upside down is it ?


No, the gyro is mounted in the exact center of the robot (not at the bottom, closer to the top, however). It is facing right-side up.

Height doesn’t matter with the Gyro, right?

I had the same issue! apparently reattaching them to a different location in the dead center fixed the issue. I know your gyro is in the center, but try remounting it. (Hope this works for you and I did not waste your time lol)