Driving Straight in RMS Vex IQ Mimic

Hi! My students and I are having trouble with getting the mimic simulation in RMS to drive straight. Their code is written correctly, but the actual simulation tends to veer to one side. Is there anything that can be done to fix this? We’re coding using Blockly and have built the standard drivetrain robot in Mimic.

The code is probably not drift-correcting (i.e. you are most likely just sending speed commands to the motors). RMS is a real-world physics simulation; if you’d like something easier and more repeatable I’d suggest Vex VR. Alternatively, you can program your robot to correct for drift using a simple P-loop, or, at a higher level, motion profiling or odometry.

What do you mean by P-loop? Is this a Python term?

P loop is a part of a PID-

The P stands for proportional and it makes the robot start moving fast.

In this case, I would set the wheel speed to a constant plus a multiple of the error between the two sides of the drive (P - proportional - the difference in input speed is proportional to the error). Here’s some pseudocode if that didn’t make much sense:

kP = 1.8; //constant proportional factor
driveSpeed = 50; //average drive speed

while(1) {
  error = leftDrive - rightDrive;
  leftDrive.spin(driveSpeed- (kP * error)); //if the drive is veering left, slow down the left side
  rightDrive.spin(driveSpeed + (kP*error)); //if the drive is veering right, slow down the right side
}

This works because the more the robot has veered, the harder it will try to correct itself, and once it gets closer to straight, it doesn’t try as hard.

EDIT: While it’s essentially the same thing, here is the blockly version of the code:

image

6 Likes

Not to bring you down or anything, but they said they are using Blockly. So How would that help them if you wrote it in text?

Uh p loops are kinda the exact opposite. P loops slow down the robot at the end of the motion. Unless your motion is very small the robot will usually start at the maximum speed that you allow and as the robot approaches the target the loop will lower the speed until the error reaches zero or another stipulation is reached. The goal is to reduce overshoot and make smoother motions.

Edit: The target of a p loops does not have to be a linear distance. it can be a velocity, angle, or position. basically any thing that can be measured and compared.

Thank you! This is very helpful!

1 Like