Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Commit

Permalink
implemented the new SelectableBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
devsamuelv committed May 6, 2022
1 parent ce350da commit 4c0bfbe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
15 changes: 11 additions & 4 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.ThePinkAlliance.core.joystick.Joystick;
import com.ThePinkAlliance.core.joystick.JoystickAxis;
import com.ThePinkAlliance.core.pathweaver.PathChooser;
import com.ThePinkAlliance.core.selectable.CommandSelectable;
import com.ThePinkAlliance.core.selectable.SelectableBuilder;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
Expand Down Expand Up @@ -42,6 +44,11 @@ public class RobotContainer {

private final PathChooser m_pathChooser = new PathChooser("drivers", 2, 0);

private final CommandSelectable defaultSelectable = SelectableBuilder.buildCommand(
"Drive Straight",
new InstantCommand()
);

// The robot's subsystems and commands are defined here...
private final Base m_base = new Base();

Expand All @@ -55,8 +62,8 @@ public RobotContainer() {
}

public void configureDashboard() {
m_pathChooser.register(new DriveStraight());
m_pathChooser.registerDefault(new DriveStraight());
m_pathChooser.register(defaultSelectable);
m_pathChooser.registerDefault(defaultSelectable);
}

/**
Expand All @@ -75,7 +82,7 @@ private void configureButtonBindings() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
// An ExampleCommand will run in autonomous
return new InstantCommand();
// Resolves the selected command that will run in autonomous
return m_pathChooser.get();
}
}
32 changes: 16 additions & 16 deletions src/main/java/frc/robot/subsystems/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,6 @@ public Base() {
this.configurePods();
}

public void configurePods() {
this.frontLeftModule.configRampRate(
Constants.frontLeftConfig.getDriveRampRate()
);
this.frontRightModule.configRampRate(
Constants.frontRightConfig.getDriveRampRate()
);

this.backLeftModule.configRampRate(
Constants.backLeftConfig.getDriveRampRate()
);
this.backRightModule.configRampRate(
Constants.backRightConfig.getDriveRampRate()
);
}

/**
* Takes ChassisSpeed object and converts it to swerve module states to send to all the modules.
*
Expand Down Expand Up @@ -300,4 +284,20 @@ public void periodic() {
// This method will be called once per scheduler run
setStates(this.states);
}

private void configurePods() {
this.frontLeftModule.configRampRate(
Constants.frontLeftConfig.getDriveRampRate()
);
this.frontRightModule.configRampRate(
Constants.frontRightConfig.getDriveRampRate()
);

this.backLeftModule.configRampRate(
Constants.backLeftConfig.getDriveRampRate()
);
this.backRightModule.configRampRate(
Constants.backRightConfig.getDriveRampRate()
);
}
}

0 comments on commit 4c0bfbe

Please sign in to comment.