-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02a9ca6
commit c631574
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Robot2024/src/main/java/com/team2813/commands/DefaultShooterCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.team2813.commands; | ||
|
||
import java.util.function.DoubleSupplier; | ||
|
||
import com.team2813.lib2813.control.ControlMode; | ||
import com.team2813.subsystems.Shooter; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class DefaultShooterCommand extends Command { | ||
private Shooter shooter; | ||
private DoubleSupplier controll; | ||
public DefaultShooterCommand(Shooter shooter, DoubleSupplier controll) { | ||
this.shooter = shooter; | ||
this.controll = controll; | ||
} | ||
/** | ||
* The number to multiply results from {@link #controll}. Multiplies by {@value #MULTIPLIER} | ||
*/ | ||
private static final double MULTIPLIER = 1; | ||
private static final double DEADZONE = 0.01; | ||
/** | ||
* Sets the motor to the value from the {@link DoubleSupplier} {@link #controll}. | ||
* Multiplies the result by {@value #MULTIPLIER}. The return from {@link #controll} MUST be less than or equal to 1. | ||
*/ | ||
public void excecute() { | ||
double val = controll.getAsDouble(); | ||
if (Math.abs(val) > DEADZONE) { | ||
shooter.set(ControlMode.DUTY_CYCLE, val * MULTIPLIER); | ||
} else { | ||
shooter.set(ControlMode.DUTY_CYCLE, 0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters