Robot over-correcting during auton

I’ve been working on my auton skills recently (code here: skills.v5blocks (10.4 KB) ), and every time the robot runs the turn I have set in the beginning, it swings back and forth like it’s trying to correct itself, even though it’s perfectly lined up with where it should be before it starts correcting itself. My dad (who is a software engineer) looked at my code and didn’t see anything wrong, but he suggested adding some wait commands and see if that helps (it didn’t). We tried so many things to try and make it work, and we couldn’t figure it out. My dad suggested that it might be something with the inertial sensor, so we tried doing a full factory calibration, which still didn’t help. We also tried putting our inertial sensor on another teams bot, and our sensor worked just the same as it did with their original sensor. We also tried using a different sensor on our bot, and it still did the over-correction. We tried making our chains tighter too, and nothing seems to be working. Is there something I’m missing in my code, or is it a mechanical issue?

(Edit: I should add that sometimes the code works fine. For instance, I was tweaking the code at a recent tournament, and it worked perfectly fine when I tested it once, and then I tested it again without changing anything and it did the over-correction. It works properly maybe 1 or 2 out of 20-25 tests?)

1 Like

I think you may need to do some testing but only change one element at a time. Here are a few examples.

  • Is it more accurate if you go slower?
  • Can you print the output of the inertial sensor so you can see what it measures while its driving?
  • Do any of your chassis motors, axles, wheel assemblies have friction or spin differently. Meaning if you manually spin the left rear wheel does it spin the same as the right rear wheel.
  • If you set all chassis motors to the same speed do any wheels spin faster than others?

Also, what code are you using to run the chassis? Is it a drivetrain or custom code?

1 Like

It’s set to 10% velocity, so I don’t know if we can go any slower.
We can try printing out the output, but the robot moves so fast to correct itself that it would have to be printed on the controller to be readable (if you can do that).
As for the wheels, a few of them spin slightly longer than others; we’ve propped up the robot and used the controller to drive forward and two of them spin a little longer but nothing too drastic. We also had a motor that was slightly loose, but I highly doubt that caused such an issue.

You can add another when started block and use it to output the values to the screen. The brain will run both programs at the same time.


Actually, it might be easier if you use the console. Leave the computer hooked up to the controller and output to the console. Download and then click the Run button on the computer.


We figured it out! Turns out, the problem was that when we set up the drivetrain in devices, we inputted the gear ratio ‘wrong’ (wrong as in right for our bot, wrong for the code), so we just had to reverse the numbers and now it’s working fine.

Our robot is having the same problem, checked the gear ratio but it is the same for the robot and the code.

@JT_39599B What gear/sprocket is on your motor, and what’s on the wheel?

I have 36 tooth gears on the motor and 84 tooth gears on the wheel. All are 600 RPM cartridges (Blue cartridge)

I would expect in this case then that your drivetrain setup should have a 3:7 ratio entered.