Skip to content

Commit

Permalink
chore: added toggle functionality for the color sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammingSR committed Mar 23, 2024
1 parent 8dcdd3f commit c3c2c86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,16 @@ public RobotContainer() {
m_robotDrive));
}

/** Scales joystick values so that diagonal driving is faster
/**
* Scales joystick values so that diagonal driving is faster
*
* @see https://www.desmos.com/calculator/uycqqtkumk
*
* @param a The primary joystick axis value being scaled
* @param b The other joystick axis value being scaled
*/
private double scaleJoysticks(double a, double b) {
return a * Math.min(1/Math.abs(a),1/Math.abs(b))*Math.sqrt(a*a+b*b);
return a * Math.min(1 / Math.abs(a), 1 / Math.abs(b)) * Math.sqrt(a * a + b * b);
}

/**
Expand Down Expand Up @@ -229,7 +230,7 @@ private void configureBindings() {
// Toggle Distance Sensor, Operator Controller Left Bumper + Start Button
new Trigger(() -> {
return m_operatorController.getLeftBumper() && m_operatorController.getStartButton();
}).onTrue(new InstantCommand(() -> m_intakeSubsystem.toggleDistanceSensor()));
}).onTrue(new InstantCommand(() -> m_intakeSubsystem.colorSensorToggle()));

// Toggle Compressor, Operator Controller Right Bumper + Menu
new Trigger(() -> {
Expand All @@ -246,7 +247,7 @@ public void resetAllSubsystems() {
m_robotDrive.reset();
}

public void compressorInit(){
public void compressorInit() {
m_climberSubsystem.toggleCompressor();
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public void periodic() {
SmartDashboard.putNumber("Arm Angle", m_armEncoder.getDistance());
SmartDashboard.putNumber("Arm Absolute Angle", m_armEncoder.getAbsolutePosition());
SmartDashboard.putBoolean("Have Note?", haveNote);
// SmartDashboard.putNumber("distance sensor", m_distanceSensorToggle ? m_distanceSensor.getRange() : -1);
// SmartDashboard.putNumber("distance sensor", m_distanceSensorToggle ?
// m_distanceSensor.getRange() : -1);
// SmartDashboard.putBoolean("distance sensor toggle", m_distanceSensorToggle);
// SmartDashboard.putNumber("pid output", armMotorSpeed);
// SmartDashboard.putNumber("Get offset", m_armEncoder.getPositionOffset());
Expand All @@ -129,4 +130,12 @@ public static enum ArmPosition {
Retracted,
Amp
}

/**
* Toggles the uage of color sensor
*/

public void colorSensorToggle() {
m_colorSensorToggle = !m_colorSensorToggle;
}
}

0 comments on commit c3c2c86

Please sign in to comment.