diff --git a/examples/stage1/stage1a/solutions/ctre/src/main/java/first/robot/Robot.java b/examples/stage1/stage1a/solutions/ctre/src/main/java/first/robot/Robot.java index d6f041d7..160160f3 100644 --- a/examples/stage1/stage1a/solutions/ctre/src/main/java/first/robot/Robot.java +++ b/examples/stage1/stage1a/solutions/ctre/src/main/java/first/robot/Robot.java @@ -32,14 +32,12 @@ public class Robot extends OpModeRobot { // [DriveMotorsLeft] - private final int leftLeaderID = 0; - public TalonFX leftLeader = new TalonFX(leftLeaderID, CANBus.systemcore(0)); + private TalonFX leftLeader = new TalonFX(0, CANBus.systemcore(0)); private TalonFX leftFollower = new TalonFX(1, CANBus.systemcore(0)); // [/DriveMotorsLeft] // [DriveMotorsRight] - private final int rightLeaderID = 2; - public TalonFX rightLeader = new TalonFX(rightLeaderID, CANBus.systemcore(0)); + private TalonFX rightLeader = new TalonFX(2, CANBus.systemcore(0)); private TalonFX rightFollower = new TalonFX(3, CANBus.systemcore(0)); // [/DriveMotorsRight] @@ -88,7 +86,7 @@ public Robot() { leftLeader.getConfigurator().apply(leftConfig); leftFollower.getConfigurator().apply(leftConfig); - leftFollower.setControl(new Follower(leftLeaderID, MotorAlignmentValue.Aligned)); + leftFollower.setControl(new Follower(leftLeader.getDeviceID(), MotorAlignmentValue.Aligned)); // [/MotorConfigLeft] // [MotorConfig] @@ -97,7 +95,7 @@ public Robot() { rightLeader.getConfigurator().apply(rightConfig); rightFollower.getConfigurator().apply(rightConfig); - rightFollower.setControl(new Follower(rightLeaderID, MotorAlignmentValue.Aligned)); + rightFollower.setControl(new Follower(rightLeader.getDeviceID(), MotorAlignmentValue.Aligned)); // [/MotorConfig] } diff --git a/src/content/docs/learning-course/stage1/stage1a/kitbot-drivetrain.mdx b/src/content/docs/learning-course/stage1/stage1a/kitbot-drivetrain.mdx index ace25cac..bd750cc9 100644 --- a/src/content/docs/learning-course/stage1/stage1a/kitbot-drivetrain.mdx +++ b/src/content/docs/learning-course/stage1/stage1a/kitbot-drivetrain.mdx @@ -56,10 +56,6 @@ This is how the motor controller objects for the left motors will look. ```java {ctreRobot}#DriveMotorsLeft ``` -For the CTRE code, the CAN ID of the leader motors are stored as a variable since they will be used later on to tell the follower which motor controller to follow. -This helps prevent errors by ensuring a single source of truth for the correct CAN ID. -Additionally, CTRE uses a CANBus object to store the CANBus instead of just an integer. - ```java {revRobot}#DriveMotorsLeft @@ -173,7 +169,9 @@ It's important to remember that settings only get changed when the configuration - For CTRE Motor Controllers, becoming a follower is a `ControlRequest` instead of a configuration. + For CTRE Motor Controllers, following a different motor controller is a `ControlRequest` instead of a configuration. + `leaderMotor.getDeviceID()` is used to get the CAN Id to follow so their is a single source of truth. + The helps prevent errors because if the leader CAN Id ever changes, the code only needs to be updated in one spot. ```java {ctreRobot}#MotorConfigLeft ``` @@ -181,7 +179,7 @@ It's important to remember that settings only get changed when the configuration For REV Motor Controllers, becoming a follower is a configuration so the follower setting gets changed before being applied to the follower motor using the leader motor as the function parameter. - This must happen after the configuration is applied to the Leader so the motor controller doesn't want to follow itself. + This must happen after the configuration is applied to the Leader so the Leading motor controller doesn't want to follow itself. `ResetMode.kResetSafeParameters` gets to tell the motor controller to reset all unchanged configurations to their default value. This prevents old configurations from being left on the controller. `PersistMode.kPersistParameters` is used so the configuration gets saved on the motor control so it persists even after power is removed. @@ -330,10 +328,10 @@ By extending `PeriodicOpMode` these classes gain a few useful functions that are Two blank `PeriodicOpMode`s, `MyTeleop.java` and `MyAuto.java` are provided under the `opmode` folder. To control the robot with joysticks a Teleop OpMode needs to be created that periodically gives the `DifferentialDrive` instance new values from the controller. -First a instance of `NiDsXboxController` needs to be created. +First a instance of `XboxController` needs to be created. This class has functions that provide the state of different buttons on the controller. Multiple controllers can be used at once so the Driver Station gives each a slot. -The index provided in the constructor tells the `NiDsXboxController`which slot to listen too. +The index provided in the constructor tells the `XboxController`which slot to listen too.