Skip to content

Commit

Permalink
Fix FieldCentricMecanumTeleop imperfect strafing code (#388)
Browse files Browse the repository at this point in the history
The Field Centric Mecanum code applied a "imperfect strafing" factor of 1.1 to the left_stick_x value, when it should be applied to the robot-centric strafing value (which is different in a Field Centric model).
  • Loading branch information
pmichaud authored Aug 25, 2023
1 parent 5ae9413 commit 2faf6d7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/docs/software/tutorials/mecanum-drive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Field-Centric Final Sample Code
while (opModeIsActive()) {
double y = -gamepad1.left_stick_y; // Remember, Y stick value is reversed
double x = gamepad1.left_stick_x * 1.1; // Counteract imperfect strafing
double x = gamepad1.left_stick_x;
double rx = gamepad1.right_stick_x;
// This button choice was made so that it is hard to hit on accident,
Expand All @@ -351,6 +351,8 @@ Field-Centric Final Sample Code
double rotX = x * Math.cos(-botHeading) - y * Math.sin(-botHeading);
double rotY = x * Math.sin(-botHeading) + y * Math.cos(-botHeading);
rotX = rotX * 1.1; // Counteract imperfect strafing
// Denominator is the largest motor power (absolute value) or 1
// This ensures all the powers maintain the same ratio,
// but only if at least one is out of the range [-1, 1]
Expand Down

0 comments on commit 2faf6d7

Please sign in to comment.