2020import static frc .robot .Constants .DriveConstants .*;
2121
2222public class CANDriveSubsystem extends SubsystemBase {
23- // --8<-- [start: motors]
23+ // --8<-- [start:motors]
2424 private final SparkMax leftLeader ;
2525 private final SparkMax leftFollower ;
2626 private final SparkMax rightLeader ;
2727 private final SparkMax rightFollower ;
2828
29- // --8<-- [end: motors]
29+ // --8<-- [end:motors]
3030
31- // --8<-- [start: differential-drive-variable]
31+ // --8<-- [start:differential-drive-variable]
3232 private final DifferentialDrive drive ;
33- // --8<-- [end: differential-drive-variable]
33+ // --8<-- [end:differential-drive-variable]
3434
35- // --8<-- [start: constructor]
35+ // --8<-- [start:constructor]
3636
3737 public CANDriveSubsystem () {
3838 // create brushed motors for drive
@@ -47,58 +47,58 @@ public CANDriveSubsystem() {
4747 // Set can timeout. Because this project only sets parameters once on
4848 // construction, the timeout can be long without blocking robot operation. Code
4949 // which sets or gets parameters during operation may need a shorter timeout.
50- // --8<-- [start: can-timeout]
50+ // --8<-- [start:can-timeout]
5151 leftLeader .setCANTimeout (250 );
5252 rightLeader .setCANTimeout (250 );
5353 leftFollower .setCANTimeout (250 );
5454 rightFollower .setCANTimeout (250 );
55- // --8<-- [end: can-timeout]
55+ // --8<-- [end:can-timeout]
5656
5757 // Create the configuration to apply to motors. Voltage compensation
5858 // helps the robot perform more similarly on different
5959 // battery voltages (at the cost of a little bit of top speed on a fully charged
6060 // battery). The current limit helps prevent tripping
6161 // breakers.
62- // --8<-- [start: voltage-compensation]
62+ // --8<-- [start:voltage-compensation]
6363 SparkMaxConfig config = new SparkMaxConfig ();
6464 config .voltageCompensation (12 );
6565 config .smartCurrentLimit (DRIVE_MOTOR_CURRENT_LIMIT );
66- // --8<-- [end: voltage-compensation]
66+ // --8<-- [end:voltage-compensation]
6767
6868 // Set configuration to follow each leader and then apply it to corresponding
6969 // follower. Resetting in case a new controller is swapped
7070 // in and persisting in case of a controller reset due to breaker trip
71- // --8<-- [start: follower-config]
71+ // --8<-- [start:follower-config]
7272 config .follow (leftLeader );
7373 leftFollower .configure (config , ResetMode .kResetSafeParameters , PersistMode .kPersistParameters );
7474 config .follow (rightLeader );
7575 rightFollower .configure (config , ResetMode .kResetSafeParameters , PersistMode .kPersistParameters );
76- // --8<-- [end: follower-config]
76+ // --8<-- [end:follower-config]
7777
7878 // Remove following, then apply config to right leader
79- // --8<-- [start: right-leader-config]
79+ // --8<-- [start:right-leader-config]
8080 config .disableFollowerMode ();
8181 rightLeader .configure (config , ResetMode .kResetSafeParameters , PersistMode .kPersistParameters );
82- // --8<-- [end: right-leader-config]
82+ // --8<-- [end:right-leader-config]
8383 // Set config to inverted and then apply to left leader. Set Left side inverted
8484 // so that postive values drive both sides forward
85- // --8<-- [start: left-inversion]
85+ // --8<-- [start:left-inversion]
8686 config .inverted (true );
8787 leftLeader .configure (config , ResetMode .kResetSafeParameters , PersistMode .kPersistParameters );
88- // --8<-- [end: left-inversion]
88+ // --8<-- [end:left-inversion]
8989 }
9090
91- // --8<-- [end: constructor]
91+ // --8<-- [end:constructor]
9292
9393 @ Override
9494 public void periodic () {
9595 }
9696
9797 // Command factory to create command to drive the robot with joystick inputs.
98- // --8<-- [start: drive-arcade-method]
98+ // --8<-- [start:drive-arcade-method]
9999 public Command driveArcade (DoubleSupplier xSpeed , DoubleSupplier zRotation ) {
100100 return this .run (
101101 () -> drive .arcadeDrive (xSpeed .getAsDouble (), zRotation .getAsDouble ()));
102102 }
103- // --8<-- [end: drive-arcade-method]
103+ // --8<-- [end:drive-arcade-method]
104104}
0 commit comments