Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better driver controls #30

Merged
merged 6 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions src/main/java/frc/robot/InputtedDriverControls.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frc.robot;

import edu.wpi.first.wpilibj.XboxController;
import frc.robot.RobotComponents.DriveTrain;

public class InputtedDriverControls {

Expand All @@ -11,6 +12,7 @@ public static void setDriverController(XboxController xboxController) {
}

public static void onEveryFrame() {
DriveTrain.driveTank(controller.getLeftY(), controller.getRightY());
if (controller.getBButtonPressed()) {
stopAtFeedingDistance();
}
Expand All @@ -20,11 +22,6 @@ public static void onEveryFrame() {
if (controller.getXButtonPressed()) {
stopAtShootingDistance();
}
driveTank(controller.getLeftY(), controller.getRightY());
}

private static void driveTank(double leftY, double rightY) {
throw new UnsupportedOperationException("Unimplemented method 'driveTank'");
}

private static void stopAtShootingDistance() {
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.RobotComponents.DriveTrain;
import frc.robot.Vision.AprilTagHighlighter;
import frc.robot.auton.AutonAction;
import frc.robot.auton.AutonRoutes;
Expand Down Expand Up @@ -114,6 +115,7 @@ public void robotInit() {
System.out.println("Is drive right parent inverted at end?? " + driveRightParent.getInverted());

InputtedCoDriverControls.setCoDriverController(coDriverController);
InputtedDriverControls.setDriverController(driverController);
}

/**
Expand Down Expand Up @@ -207,17 +209,7 @@ public void teleopInit() {}
@Override
public void teleopPeriodic() {
teleopActionRunner.onEveryFrame();
// TODO: make slow mode
double leftY = driverController.getLeftY();
double rightY = driverController.getRightY();
QuickActions.stopDriveMotors();
if (Math.abs(leftY) > Constants.CONTROLLER_DEADZONE) {
driveLeftParent.set(leftY);
}
if (Math.abs(rightY) > Constants.CONTROLLER_DEADZONE) {
driveRightParent.set(rightY);
}
// aprilTagHighlighter.doEveryTeleopFrame(driverController);
InputtedDriverControls.onEveryFrame();
InputtedCoDriverControls.onEveryFrame();
}

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/RobotComponents/DriveTrain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.RobotComponents;

import frc.robot.Constants;
import frc.robot.QuickActions;
import frc.robot.Robot;

public class DriveTrain {

public static void driveTank(double leftY, double rightY) {
QuickActions.stopDriveMotors();
Copy link
Member

Choose a reason for hiding this comment

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

Why are we always stopping the motors?

if (Math.abs(leftY) > Constants.CONTROLLER_DEADZONE) {
Robot.motors.getDriveLeftChild().set(leftY);
}
if (Math.abs(rightY) > Constants.CONTROLLER_DEADZONE) {
Robot.motors.getDriveRightParent().set(rightY);
}
}
}