Vladimirtrif / Team-949z_Pelmen_Vex_21-22

0 stars 0 forks source link

Improve speed & accuracy of autonomous #8

Open vladsud opened 2 years ago

vladsud commented 2 years ago

Today, we set the speed for drive & lift, but use delay to finish each step:

        //moving forward to goal
        Move(4100, 200);

        lift_Front.move_relative(-2900, 100);
        //lift_Back.move_relative(5000, 90);

        pros::delay(1450);

Leveraging delays is not great as delay setting will change depending on

I'd suggest changing it to be more input driven. Starting point is documentation: https://pros.cs.purdue.edu/v5/api/cpp/motors.html#move-relative, click on Example tab.

I suggest the following strategy:

  1. Create a function (member of Autonomous class) that returns average position of all 6 motors. Averaging (over asking single motor) helps gain a bit of precision.
    • even better, create 3 functions - one for left motors, one for right motors, and one average of two previous functions
    • See pros:Motor:get_position() function.
  2. Capture position before any move steps
  3. Give motors command to drive - either using move() or move_relative(). I'd suggest using move() as I'm not sure if move_relative() does any slow down at the end to more accurately stop at precise end point - our current aton does not need it at the moment, so moving as fast as possible (and overshooting target) is Ok.
  4. In while() cycle, check every 10ms if current position minus initial position is over target. If it is, bail out of while loop
  5. stop motors, move to next step.

Optional: