Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Add controller deadzones to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jack60612 committed Jan 24, 2024
1 parent 02c41a7 commit 40aa157
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public static final class CANConstants {
// USB Devices
public static final int CONTROLLERUSBINDEX = 0;
public static final int FLIGHTSTICKUSBINDEX = 1;
// On-Controller joystick deadzone
public static final double CONTROLLERDEADZONE = 0.1;

// Game Controller Buttons
// Now In RobotContainer as Native Triggers.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/commands/ArmCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Constants;
import frc.robot.HelperFunctions;
import frc.robot.ShooterState;
import frc.robot.subsystems.ArmSubsystem;
Expand Down Expand Up @@ -40,7 +41,7 @@ public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if (!HelperFunctions.inDeadzone(m_yAxis.getAsDouble(), 0.1)) {
if (!HelperFunctions.inDeadzone(m_yAxis.getAsDouble(), Constants.CONTROLLERDEADZONE)) {
m_ArmSubsystem.MoveArmRelative(m_yAxis.getAsDouble() * kMaxRadiansPerInput);

} else if (m_shooterState.isLoaded & !m_shooterState.isLowered) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/commands/DefaultDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void initialize() {}
public void execute() {
// we include a limit on the drivers speed for safety.
// Additonally the axis's on the
if (!HelperFunctions.inDeadzone(m_left_y.getAsDouble(), 0.1)
|| !HelperFunctions.inDeadzone(m_right_y.getAsDouble(), 0.1)) {
if (!HelperFunctions.inDeadzone(m_left_y.getAsDouble(), Constants.CONTROLLERDEADZONE)
|| !HelperFunctions.inDeadzone(m_right_y.getAsDouble(), Constants.CONTROLLERDEADZONE)) {
this.m_driveSubsystem.tankDrive(
Constants.MAX_SPEED * m_left_y.getAsDouble(),
Constants.MAX_SPEED * m_right_y.getAsDouble());
Expand Down

0 comments on commit 40aa157

Please sign in to comment.