Turning with Brain Inertial Sensor issue with Drivetrain Settings

We recently had a team working on programming their robot to make precise turns using the Gen2 Brain’s Inertial Sensor. Despite their best efforts, they encountered an issue where the robot wouldn’t stop turning. They experimented with several approaches, learning a lot along the way, but couldn’t get it to work as expected.

After a lot of troubleshooting, they discovered that the problem was related to the Drivetrain settings. Specifically, the direction was set to “reverse.” Once they adjusted this setting to “forward,” the robot stopped the continuous spin and began turning accurately.

The main takeaway (and the reason for this post) is understanding why this happened. From what they observed, it seems like the inertial sensor may only function correctly when the Drivetrain direction is set to “forward.”

Has anyone else experienced this, and can you offer an explanation that might make sense to the students? Are the sensor’s readings linked to the Drivetrain’s default direction? Any insights would be appreciated!

That’s very odd… Our team experienced the very same problem, except when we set the drivetrain direction to forward. As soon as we changed the direction to reverse, it was working properly.

In the spirit of full discolusure, GBR and I are coaches in the same program. We were were both struggling with the same issue and found the fix at about the same time. I was writing n email to tell him what I found when his arrived for me! Thanks GBR! :+1:

I will add that several hours of working onn this over several days, my adherence to ther scientific method sliiped and I made 2 changes at once. Set the drive train from forward to reverse AND changed where the left and right drive train motors were plugged in, to accomodate for the direction change.

Since the herobot calls for the brain to be mounted on it’s side, so to speak, so my students just plugged the motors into ports and when the robot drove backwards, flipped the direction from forward to reverse. Perhaps this helps explain 2422A’s experience.

For whoever at VEX needs to hear this, if that forwards orientation is critical to make the “Turn to Heading” command work, it should be added to
this article in the Vex library. I’m sure it would save a lot oc students and coaches a lot of frustration.

I’ll explain some details about this when I get a chance later, F1 to watch first.

Sorry if I’m misunderstanding the problem, but I believe we had a similar issue with ours. If we had the direction of the turn set to right it would work, but if we had the turn set to left, it would go in circles. We figured out our issue was (if you are coding with C++) that you had to set the turn value to a negative and put it as [turn>=-90.0] instead of changing the direction of the wheels during the turn. Yet again, so sorry if I misunderstood the problem.

The drivetrain code has to make certain assumptions.

It assumes the motors provided as left and right motors are in fact the left and right motors.

It assumes that if it spins the motors forward (ie. positive velocity) the robot will move forwards, it has no idea if the motors are driving the wheels directly or if you have 15 gears between the motor and the wheels.

Along with the above, it has to assume that if it spins the left motor forwards and the right motor reverse, the robot will turn clockwise and (with IQ gen 2 inertial sensor) the heading will increase.

So let’s look at the generated code for a 2 motor drivetrain with the direction arrow set to forward (ie. pointing up in the UI)

// Robot configuration code.
inertial BrainInertial = inertial();
motor LeftDriveSmart = motor(PORT1, 1, false);
motor RightDriveSmart = motor(PORT6, 1, true);

smartdrive Drivetrain = smartdrive(LeftDriveSmart, RightDriveSmart, BrainInertial, 200);

A standard setup for a 2 motor direct drive drivetrain, the right motor is reversed.

If the UI arrow is set to reverse (ie. pointing down) this is what happens.

// Robot configuration code.
inertial BrainInertial = inertial();
motor LeftDriveSmart = motor(PORT1, 1, true);
motor RightDriveSmart = motor(PORT6, 1, false);

smartdrive Drivetrain = smartdrive(LeftDriveSmart, RightDriveSmart, BrainInertial, 200);

The left and right motor reverse flags have been reversed, you would need to do this if there was a single stage of gearing (ie. a gear on motor driving a gear on the wheels) to make the robot drive forwards when positive velocities are used in spin commands.

In both the above cases the drivetrain turns should work correctly, however, things will go wrong if you start to physically swap cables around and the motors provided to the drivetrain class are not in fact the correct left and right. motors.