Robot spins in circles with inertial sensor

What do you mean by “built in drivetrain”? Here are my declarations:

competition Competition;
brain Brain;
motor LeftDrive = motor(PORT11, ratio36_1, true);
motor RightDrive = motor(PORT7, ratio36_1, false);
controller Controller1 = controller(primary);
inertial Inertial = inertial(PORT12);
smartdrive Drivetrain = smartdrive (LeftDrive, RightDrive, Inertial, 319.19, 295, 40, mm, 1);

I wrote them myself if that makes a difference.

Devices menu show inertial sensor in port 12. I can calibrate it and when I turn the robot, the heading value changes as it should.

1 Like

I don’t know exactly but we had the same problem with our inertial sensor, all we had to do was instead of putting something like turn till
inertial_15 = 30 which more often then not it will over turn every time causing it to spin forever, to fix this we put spin motor till inertial_15 > 29
And inertial_15< 31. That way it will stop in time and wont over turn. It has been very accurate for me.

We are using the turnToRotation command which works perfectly on other robots programs. The question is why isn’t it working with the code I provided above?

I don’t know but our inertial sensor is separate from the drivetrain because every time I setup the drivetrain with the inertial sensor it didn’t work so I made it separate.

What do you mean by “separate from the drivetrain”?

this is included

1 Like

1 Like

Well, in order to use the smartdrive commands, don’t you have to include the inertial sensor in the smartdrive declaration? I want to use the smartdrive commands.

When you do this does it turn to the left ? If not, then left and right motors are configured backwards, that is, change the reverse flag on them.

2 Likes

Solved the problem. The other thread is where I found the answer:

Inertial Sensor Problem Turning

Old code that is broken:

smartdrive Drivetrain = smartdrive (LeftDrive, RightDrive, Inertial, 319.19, 295, 40, mm, 1);

New code that works:

smartdrive Drivetrain = smartdrive (RightDrive, LeftDrive, Inertial, 319.19, 295, 40, mm, 1);

The right side has to be declared first in the smartdrive statement. Problem solved.

Well, that’s actually not true, see my previous post. What you have done is have two “wrongs” making a “right”. The constructors for the smartdrive are as follows.

smartdrive( motor_group &l, motor_group &r, vex::guido &g, double wheelTravel=320, double trackWidth=320, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio = 1.0 );
smartdrive( vex::motor &l, vex::motor &r, vex::guido &g, double wheelTravel=320, double trackWidth=320, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio = 1.0 );

left motor or motor group is always first.
because your left and right motors are configured backwards, swapping the order you send to the smartdrive gives the illusion of fixing. but whatever works for you I guess…

5 Likes

Got it. I don’t have access to the bot right now, but I will switch my smartdrive declaration back to the way it was and then reverse my true/false statements on my motor declaration and see what happens.

Just revisited this and your solution worked. I think the problem was that this was a test auton program and we never tested the user controls. So, the drive was messed up but they didn’t know it. Glad to have solved the problem.