-
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
3b8daac
commit d6f610e
Showing
5 changed files
with
86 additions
and
4 deletions.
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
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
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/com/frcteam3636/frc2025/subsystems/climb/Climb.kt
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,40 @@ | ||
package com.frcteam3636.frc2025.subsystems.climb | ||
|
||
import com.frcteam3636.frc2025.Robot | ||
import edu.wpi.first.wpilibj2.command.Command | ||
import edu.wpi.first.wpilibj2.command.Subsystem | ||
import org.littletonrobotics.junction.Logger | ||
|
||
object Climb : Subsystem { | ||
private val io: ClimbIO = when (Robot.model) { | ||
Robot.Model.SIMULATION -> TODO() | ||
Robot.Model.COMPETITION -> ClimbIOReal() | ||
Robot.Model.PROTOTYPE -> TODO() | ||
} | ||
|
||
var inputs = LoggedClimbInputs() | ||
|
||
override fun periodic() { | ||
io.updateInputs(inputs) | ||
Logger.processInputs("Climb", inputs) | ||
} | ||
|
||
fun up(): Command = startEnd( | ||
{ | ||
io.setSpeed(0.50) | ||
}, | ||
{ | ||
io.setSpeed(0.0) | ||
} | ||
) | ||
|
||
fun down(): Command = startEnd( | ||
{ | ||
io.setSpeed(-0.50) | ||
}, | ||
{ | ||
io.setSpeed(0.0) | ||
} | ||
) | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/frcteam3636/frc2025/subsystems/climb/ClimbIO.kt
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,39 @@ | ||
package com.frcteam3636.frc2025.subsystems.climb | ||
|
||
import com.ctre.phoenix6.configs.TalonFXConfiguration | ||
import com.ctre.phoenix6.signals.NeutralModeValue | ||
import com.frcteam3636.frc2025.CTREDeviceId | ||
import com.frcteam3636.frc2025.TalonFX | ||
import edu.wpi.first.units.Units.Amps | ||
import org.team9432.annotation.Logged | ||
|
||
@Logged | ||
open class ClimbInputs { | ||
var climberCurrent = Amps.zero()!! | ||
} | ||
|
||
interface ClimbIO { | ||
fun setSpeed(percent: Double) | ||
fun updateInputs(inputs: ClimbInputs) | ||
} | ||
|
||
class ClimbIOReal : ClimbIO { | ||
private var climbMotor = TalonFX(CTREDeviceId.ClimbMotor).apply { | ||
configurator.apply( | ||
TalonFXConfiguration().apply { | ||
MotorOutput.apply { | ||
NeutralMode = NeutralModeValue.Brake | ||
} | ||
} | ||
) | ||
} | ||
|
||
override fun setSpeed(percent: Double) { | ||
assert(percent in -1.0..1.0) | ||
climbMotor.set(percent) | ||
} | ||
|
||
override fun updateInputs(inputs: ClimbInputs) { | ||
inputs.climberCurrent = climbMotor.supplyCurrent.value | ||
} | ||
} |
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