Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ForTeaching/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
dependencies {
implementation project(':FtcRobotController')
// Uncomment this to use a local version of TechnoLib
// implementation project(':RobotLibrary') // FLIP: TechnoLibLocal
// implementation project(':Path') // FLIP: TechnoLibLocal
// implementation project(':Vision') // FLIP: TechnoLibLocal
implementation project(':RobotLibrary') // FLIP: TechnoLibLocal
implementation project(':Path') // FLIP: TechnoLibLocal
implementation project(':Vision') // FLIP: TechnoLibLocal
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

import com.technototes.library.command.CommandScheduler;
import com.technototes.library.command.ParallelCommandGroup;
import com.technototes.library.command.SimpleCommand;
import com.technototes.library.command.SimpleRequiredCommand;
import com.technototes.library.control.CommandAxis;
import com.technototes.library.control.CommandButton;
import com.technototes.library.control.CommandGamepad;
import com.technototes.library.control.Stick;
import com.technototes.library.util.Alliance;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.CloseClawCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.LiftDownCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.LiftUpCommand;

import org.firstinspires.ftc.forteaching.TechnoBot.Commands.MecDriveCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.OpenClawCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.Operations;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.TestEncodedMotorCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.TestMotorCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Commands.TestServoCommand;
import org.firstinspires.ftc.forteaching.TechnoBot.Subsystems.ClawSubsystem;
import org.firstinspires.ftc.forteaching.TechnoBot.Subsystems.LiftSubsystem;
import org.firstinspires.ftc.forteaching.TechnoBot.Subsystems.MotorAsServoSubsystem;
import org.firstinspires.ftc.forteaching.TechnoBot.Subsystems.MovementTestingSubsystem;

public class Controls {

Expand Down Expand Up @@ -94,64 +93,51 @@ public Controls(CommandGamepad gpad, TheBot bot, Alliance ally) {
}

public void bindClawControls() {
openClaw.whenPressed(new OpenClawCommand(robot.clawSubsystem));
closeClaw.whenPressed(new CloseClawCommand(robot.clawSubsystem));
openClaw.whenPressed(robot.clawSubsystem, ClawSubsystem::open);
closeClaw.whenPressed(robot.clawSubsystem, ClawSubsystem::close);
}

public void bindLiftControls() {
liftUp.whenPressed(new LiftUpCommand(robot.liftSubsystem));
liftDown.whenPressed(new LiftDownCommand(robot.liftSubsystem));
liftUp.whenPressed(robot.liftSubsystem, LiftSubsystem::moveUp);
liftDown.whenPressed(robot.liftSubsystem, LiftSubsystem::moveDown);
}

// Joysticks require a "scheduleJoystick" thing, so the commands are invoked all the time
private void bindDrivebaseControls() {
CommandScheduler
.getInstance()

.scheduleJoystick(
// new TankDriveCommand(robot.tankDriveBase, leftTankStick, rightTankStick, snapToAngle)
new MecDriveCommand(robot.mecanumDrivebase, leftMecDriveStick, rightMecDriveStick)
);
}

// Silly helpers to make the code more succinct below
private TestEncodedMotorCommand MakeEncCommand(Operations op) {
return new TestEncodedMotorCommand(robot.encodedMotorSubsystem, op);
}

private TestMotorCommand MakeMotorCommand(Operations op) {
return new TestMotorCommand(robot.movementTestingSubsystem, op);
}

private TestServoCommand MakeServoCommand(Operations op) {
return new TestServoCommand(robot.movementTestingSubsystem, op);
}

private void bindTesterControls() {
encMotorTestUp.whenPressed(MakeEncCommand(Operations.Increase));
encMotorTestDown.whenPressed(MakeEncCommand(Operations.Decrease));
encMotorTestUp.whenPressed(robot.encodedMotorSubsystem, MotorAsServoSubsystem::increaseEncMotor);
encMotorTestDown.whenPressed(robot.encodedMotorSubsystem, MotorAsServoSubsystem::decreaseEncMotor);

motorTestUp.whenPressed(MakeMotorCommand(Operations.Increase));
motorTestDown.whenPressed(MakeMotorCommand(Operations.Decrease));
motorTestUp.whenPressed(robot.movementTestingSubsystem, MovementTestingSubsystem::increaseMotorSpeed);
motorTestDown.whenPressed(robot.movementTestingSubsystem, MovementTestingSubsystem::decreaseMotorSpeed);

servoTestUp.whenPressed(MakeServoCommand(Operations.Increase));
servoTestDown.whenPressed(MakeServoCommand(Operations.Decrease));
servoTestUp.whenPressed(robot.movementTestingSubsystem, MovementTestingSubsystem::increaseServoMotor);
servoTestDown.whenPressed(robot.movementTestingSubsystem, MovementTestingSubsystem::decreaseServoMotor);

// For this stuff, ParallelCommandGroups or SequentialCommandGroups both work the same
// For command that take "time" you parallel command groups (as they will run at the same
// time as the other commands) but if you want "do A, then do B, then do C" you should
// use a sequential command group
stop.whenPressed(
new ParallelCommandGroup(
MakeEncCommand(Operations.Stop),
MakeMotorCommand(Operations.Stop),
MakeServoCommand(Operations.Stop)
new SimpleCommand(robot.movementTestingSubsystem::neutralMotorSpeed),
new SimpleCommand(robot.movementTestingSubsystem::neutralServoMotor),
new SimpleRequiredCommand<>(robot.encodedMotorSubsystem, MotorAsServoSubsystem::stop)
)
);
halt.whenPressed(
new ParallelCommandGroup(
MakeMotorCommand(Operations.Halt),
MakeEncCommand(Operations.Halt),
MakeServoCommand(Operations.Halt)
new SimpleCommand(robot.movementTestingSubsystem::brakeMotor),
new SimpleCommand(robot.movementTestingSubsystem::neutralServoMotor),
new SimpleRequiredCommand<>(robot.encodedMotorSubsystem, MotorAsServoSubsystem::halt)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void uponInit() {
controls = new Controls(driverGamepad, robot, Alliance.RED);

if (TheBot.Connected.Camera) CommandScheduler
.getInstance()

.scheduleInit(new VisionCommand(robot.visionSystem, Alliance.RED));
}
}
6 changes: 3 additions & 3 deletions Sixteen750/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
dependencies {
implementation project(':FtcRobotController')
// Uncomment this to use a local version of TechnoLib
// implementation project(':RobotLibrary') // FLIP: TechnoLibLocal
// implementation project(':Path') // FLIP: TechnoLibLocal
// implementation project(':Vision') // FLIP: TechnoLibLocal
implementation project(':RobotLibrary') // FLIP: TechnoLibLocal
implementation project(':Path') // FLIP: TechnoLibLocal
implementation project(':Vision') // FLIP: TechnoLibLocal
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ControlsDriver(CommandGamepad g, Robot r, Robot.SubsystemCombo combo) {
public void bindMecanumDriveControls() {
// Probably not a good idea to bind the drive controls to more than one gamepad
CommandScheduler
.getInstance()

.scheduleJoystick(new MecanumDriveCommand(robot.mecanumDriveSubsystem, gamepad.leftStick, gamepad.rightStick));
gamepad.leftStickButton.whenPressed(new ApplyTurboModeCommand(robot.mecanumDriveSubsystem));
gamepad.rightStickButton.whenPressed(new ApplyTurboModeCommand(robot.mecanumDriveSubsystem));
Expand All @@ -80,7 +80,7 @@ public void bindMecanumDriveControls() {

public void bindVisionCommand(){
CommandScheduler
.getInstance()

.scheduleForState(new VisionDuringTeleCommand(robot.visionSubsystem, gamepad.ps_share), CommandOpMode.OpModeState.RUN);
}

Expand Down
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fact that you got rid of getInstance. I'm not a fan of singletons. However, I cannot find the code reference for CommandScheduler, so my review is very limited

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the javadoc comments are all you're going to find. I've been slowly trying to get more stuff documented, but it's just me typing when that's what I feel like doing 🤣

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: You can find the source (with javadoc comments, as they are) for the custom TechnoLib branch I'm working with here: https://github.com/technototes/TechnoLib/blob/cleanup/RobotLibrary/src/main/java/com/technototes/library/command/CommandScheduler.java

Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public void uponInit() {
hardware = new Hardware(hardwareMap, Robot.SubsystemCombo.VISION_M_DRIVE);
robot = new Robot(hardware, Robot.SubsystemCombo.VISION_M_DRIVE, Alliance.BLUE, StartingPosition.AWAY);
robot.mecanumDriveSubsystem.setPoseEstimate(AutoConstantsBlue.Away.START.toPose());
CommandScheduler.getInstance()
CommandScheduler
.scheduleForState(
new SequentialCommandGroup(
new LeftParkingSelectionCommandJustPark(
robot.visionSubsystem, robot.mecanumDriveSubsystem),
CommandScheduler.getInstance()::terminateOpMode),
CommandScheduler::terminateOpMode),
CommandOpMode.OpModeState.RUN);
if (Robot.RobotConstant.CAMERA_ENABLED) {
CommandScheduler.getInstance().scheduleInit(new VisionCommand(robot.visionSubsystem));
CommandScheduler.scheduleInit(new VisionCommand(robot.visionSubsystem));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public void uponInit() {
hardware = new Hardware(hardwareMap, Robot.SubsystemCombo.VISION_M_DRIVE);
robot = new Robot(hardware, Robot.SubsystemCombo.VISION_M_DRIVE, Alliance.BLUE, StartingPosition.HOME);
robot.mecanumDriveSubsystem.setPoseEstimate(AutoConstantsBlue.Home.START.toPose());
CommandScheduler.getInstance()
CommandScheduler
.scheduleForState(
new SequentialCommandGroup(
new RightParkingSelectionCommandJustPark(
robot.visionSubsystem, robot.mecanumDriveSubsystem),
CommandScheduler.getInstance()::terminateOpMode),
CommandScheduler::terminateOpMode),
CommandOpMode.OpModeState.RUN);
if (Robot.RobotConstant.CAMERA_ENABLED) {
CommandScheduler.getInstance().scheduleInit(new VisionCommand(robot.visionSubsystem));
CommandScheduler.scheduleInit(new VisionCommand(robot.visionSubsystem));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void uponInit() {
coDriverControls = new ControlsCoDriver(codriverGamepad, robot, Robot.SubsystemCombo.DEFAULT);
telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
if (false && Robot.RobotConstant.CAMERA_ENABLED) {
CommandScheduler.getInstance().scheduleInit(new VisionCommand(robot.visionSubsystem));
CommandScheduler.scheduleInit(new VisionCommand(robot.visionSubsystem));
}
}

Expand Down
Loading