Extra auto w/o roadrunner#24
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new emergency autonomous mode that operates without the RoadRunner library, providing a fallback option for autonomous operation. The implementation uses basic encoder-based positioning and time-based movement commands.
Key Changes
- New
RedEmergencyAutoNonRRclass implementing a basic autonomous routine using encoder targets and timed movements - Updated MeepMeepTesting trajectories to test different starting positions and paths
- Modified red alliance starting coordinates and path waypoints in the testing configuration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| TeamCode/src/main/java/org/firstinspires/ftc/teamcode/auto/nonRoadrunner/RedEmergencyAutoNonRR.java | New emergency autonomous OpMode with encoder-based initial movement followed by time-based directional movements |
| MeepMeepTesting/src/main/java/com/example/meepmeeptesting/MeepMeepTesting.java | Updated red alliance trajectory testing with new starting position and refined waypoints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| frontLeftDrive.setPower(.5); | ||
|
|
||
| while(frontLeftDrive.isBusy() && frontRightDrive.isBusy() && backLeftDrive.isBusy() && backRightDrive.isBusy()) { | ||
| telemetry.addData("Positions", "frontLeft (%d), backLeft (%d), frontRight (%d), backRight (%d)", frontLeftDrive.getCurrentPosition(), frontRightDrive.getCurrentPosition(), backLeftDrive.getCurrentPosition(), backRightDrive.getCurrentPosition()); |
There was a problem hiding this comment.
The telemetry data format string has incorrect parameter order. The format shows "frontLeft, backLeft, frontRight, backRight" but the parameters are ordered as "frontLeft, frontRight, backLeft, backRight". This will display misleading position data. Either fix the format string or reorder the parameters to match.
| telemetry.addData("Positions", "frontLeft (%d), backLeft (%d), frontRight (%d), backRight (%d)", frontLeftDrive.getCurrentPosition(), frontRightDrive.getCurrentPosition(), backLeftDrive.getCurrentPosition(), backRightDrive.getCurrentPosition()); | |
| telemetry.addData("Positions", "frontLeft (%d), backLeft (%d), frontRight (%d), backRight (%d)", frontLeftDrive.getCurrentPosition(), backLeftDrive.getCurrentPosition(), frontRightDrive.getCurrentPosition(), backRightDrive.getCurrentPosition()); |
| moveLinear(.3,2000, "forward"); | ||
| moveRotation(3,2000, "right"); | ||
| moveLinear(.3,2000, "forward"); | ||
| moveLinear(.3,2000, "left"); | ||
| moveLinear(.3,2000, "backward"); | ||
| moveStop(); |
There was a problem hiding this comment.
After switching motors to RUN_TO_POSITION mode (lines 88-91), the motors should have their mode reset before the subsequent moveLinear and moveRotation calls which use direct power control. The motors are still in RUN_TO_POSITION mode, which will cause the subsequent movement commands to not work as expected. Add code to reset the motors to RUN_USING_ENCODER or RUN_WITHOUT_ENCODER mode after line 102.
| if (direction.equalsIgnoreCase("Right")) { | ||
| setPower(speed, -speed, speed, -speed); | ||
| } | ||
| Thread.sleep(time); |
There was a problem hiding this comment.
Using Thread.sleep() in FTC autonomous code is not a best practice. The OpMode doesn't check for opModeIsActive() during the sleep, which means the robot will continue to move even if the OpMode is stopped. Use an ElapsedTime timer with a loop that checks opModeIsActive() instead.
| public void moveLinear(double speed, int time, String direction) throws InterruptedException { | ||
| if (direction.equalsIgnoreCase("Forward")) { | ||
| setPower(speed, speed, speed, speed); | ||
| } | ||
| if (direction.equalsIgnoreCase("Backward")) { | ||
| setPower(-speed, -speed, -speed, -speed); | ||
| } | ||
| if (direction.equalsIgnoreCase("Left")) { | ||
| setPower(-speed, speed, speed, -speed); | ||
| } | ||
| if (direction.equalsIgnoreCase("Right")) { | ||
| setPower(speed, -speed, -speed, speed); | ||
| } | ||
| Thread.sleep(time); | ||
| } |
There was a problem hiding this comment.
The moveLinear and moveRotation methods don't call moveStop() after the movement completes. This means motors will continue running after the time delay unless explicitly stopped. Consider adding moveStop() at the end of these methods to ensure motors stop after each movement.
| double FLposition = frontLeftDrive.getCurrentPosition(); | ||
| double FRposition = frontRightDrive.getCurrentPosition(); | ||
| double BLposition = backLeftDrive.getCurrentPosition(); | ||
| double BRposition = backRightDrive.getCurrentPosition(); | ||
|
|
There was a problem hiding this comment.
These position variables are declared but never used. The encoder positions are reset to 0 on lines 68-71, making these initial readings unnecessary. Consider removing these unused variables.
| double FLposition = frontLeftDrive.getCurrentPosition(); | |
| double FRposition = frontRightDrive.getCurrentPosition(); | |
| double BLposition = backLeftDrive.getCurrentPosition(); | |
| double BRposition = backRightDrive.getCurrentPosition(); |
| if (direction.equalsIgnoreCase("Right")) { | ||
| setPower(speed, -speed, -speed, speed); | ||
| } | ||
| Thread.sleep(time); |
There was a problem hiding this comment.
Using Thread.sleep() in FTC autonomous code is not a best practice. The OpMode doesn't check for opModeIsActive() during the sleep, which means the robot will continue to move even if the OpMode is stopped. Use an ElapsedTime timer with a loop that checks opModeIsActive() instead, similar to the pattern on lines 98-101.
| * This file contains an minimal example of a Linear "OpMode". An OpMode is a 'program' that runs in either | ||
| * the autonomous or the teleop period of an Fh * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list |
There was a problem hiding this comment.
This comment appears to be truncated or malformed. The sentence is incomplete: "the autonomous or the teleop period of an Fh * Remove or comment out...". This should be fixed to provide clear documentation.
| * This file contains an minimal example of a Linear "OpMode". An OpMode is a 'program' that runs in either | |
| * the autonomous or the teleop period of an Fh * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list | |
| * This file contains a minimal example of a Linear "OpMode". An OpMode is a 'program' that runs during either | |
| * the autonomous or the teleop period of an FTC match. | |
| * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list. |
| waitForStart(); | ||
|
|
||
| frontLeftDrive.setDirection(DcMotor.Direction.REVERSE); | ||
| frontRightDrive.setDirection(DcMotor.Direction.FORWARD); | ||
| backLeftDrive.setDirection(DcMotor.Direction.REVERSE); | ||
| backRightDrive.setDirection(DcMotor.Direction.FORWARD); | ||
|
|
There was a problem hiding this comment.
Motor directions should be set before calling waitForStart(). Currently, if the OpMode is stopped between waitForStart() and the direction configuration, the motors may operate with incorrect directions. Move lines 63-66 before line 61.
| waitForStart(); | |
| frontLeftDrive.setDirection(DcMotor.Direction.REVERSE); | |
| frontRightDrive.setDirection(DcMotor.Direction.FORWARD); | |
| backLeftDrive.setDirection(DcMotor.Direction.REVERSE); | |
| backRightDrive.setDirection(DcMotor.Direction.FORWARD); | |
| frontLeftDrive.setDirection(DcMotor.Direction.REVERSE); | |
| frontRightDrive.setDirection(DcMotor.Direction.FORWARD); | |
| backLeftDrive.setDirection(DcMotor.Direction.REVERSE); | |
| backRightDrive.setDirection(DcMotor.Direction.FORWARD); | |
| waitForStart(); |
Before issuing a pull request, please see the contributing page.