Skip to content

Commit

Permalink
Laid out IO systems closer to what I we'd want and made it build
Browse files Browse the repository at this point in the history
  • Loading branch information
PY44N committed Jan 31, 2025
1 parent c8c2cbc commit 57fc32d
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 72 deletions.
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/constants/ElevatorConstants.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package frc.robot.constants

object ElevatorConstants {
val kG = 0
val kS = 0
val kV = 0
val kA = 0
val kP = 0
val kI = 0
val kD = 0
val targetVelocity = 0
val targetAcceleration = 0
val targetJerk = 0
val kG = 0.0
val kS = 0.0
val kV = 0.0
val kA = 0.0
val kP = 0.0
val kI = 0.0
val kD = 0.0
val targetVelocity = 0.0
val targetAcceleration = 0.0
val targetJerk = 0.0
val id = 0
val canbus = ""
}
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/constants/IntakeConstants.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package frc.robot.constants

object IntakeConstants {
val kG = 0
val kS = 0
val kV = 0
val kA = 0
val kP = 0
val kI = 0
val kD = 0
val targetVelocity = 0
val targetAcceleration = 0
val targetJerk = 0
val kG = 0.0
val kS = 0.0
val kV = 0.0
val kA = 0.0
val kP = 0.0
val kI = 0.0
val kD = 0.0
val targetVelocity = 0.0
val targetAcceleration = 0.0
val targetJerk = 0.0
val id = 0
val canbus = ""
}
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/constants/PivotConstants.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package frc.robot.constants

object PivotConstants {
val kG = 0
val kS = 0
val kV = 0
val kA = 0
val kP = 0
val kI = 0
val kD = 0
val targetVelocity = 0
val targetAcceleration = 0
val targetJerk = 0
val kG = 0.0
val kS = 0.0
val kV = 0.0
val kA = 0.0
val kP = 0.0
val kI = 0.0
val kD = 0.0
val targetVelocity = 0.0
val targetAcceleration = 0.0
val targetJerk = 0.0
val id = 0
val canbus = ""
}
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/constants/WristConstants.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package frc.robot.constants

object WristConstants {
val kG = 0
val kS = 0
val kV = 0
val kA = 0
val kP = 0
val kI = 0
val kD = 0
val targetVelocity = 0
val targetAcceleration = 0
val targetJerk = 0
val kG = 0.0
val kS = 0.0
val kV = 0.0
val kA = 0.0
val kP = 0.0
val kI = 0.0
val kD = 0.0
val targetVelocity = 0.0
val targetAcceleration = 0.0
val targetJerk = 0.0
val id = 0
val canbus = ""
}
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/subsystems/elevator/ElevatorIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX

interface ElevatorIO {
var talonFX: TalonFX
var talonFXConfigs: TalonFXConfiguration
fun getElevatorEncoder(): Double
fun setElevatorMotor(rotations: Double)
// fun getElevatorEncoder(): Double

// fun setElevatorMotor(rotations: Double)
fun setPosition(positionMeters: Double)
}
12 changes: 10 additions & 2 deletions src/main/java/frc/robot/subsystems/elevator/ElevatorIOReal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ class ElevatorIOReal : ElevatorIO {
talonFX.getConfigurator().apply(talonFXConfigurations)
}

override fun getElevatorEncoder(): Double {
fun getElevatorEncoder(): Double {
TODO("Not yet implemented")
return 0.0;
}

override fun setMotorPosition(rotations: Double) {
fun setElevatorMotor(rotations: Double) {
TODO("Not yet implemented")
}

fun setMotorPosition(rotations: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
}

override fun setPosition(positionMeters: Double) {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import edu.wpi.first.wpilibj2.command.Command

// By making a subsystem a Kotlin object, we ensure there is only ever one instance of it.
// It also reduces the need to have reference variables for the subsystems to be passed around.
object ElevatorSystem : SubsystemBase() {
class ElevatorSystem(private val io: ElevatorIO) : SubsystemBase() {
/**
* Example command factory method.
*
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/subsystems/intake/IntakeIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX

interface IntakeIO {
var talonFX: TalonFX
var talonFXConfigs: TalonFXConfiguration
fun getIntakeEncoder(): Double
fun setIntakeMotor(x: Double)
// fun getIntakeEncoder(): Double

// fun setIntakeMotor(x: Double)
fun setCoralIntakeState(state: CoralIntakeState)
fun setAlgaeIntakeState(state: AlgaeIntakeState)
}
14 changes: 11 additions & 3 deletions src/main/java/frc/robot/subsystems/intake/IntakeIOReal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ class IntakeIOReal : IntakeIO {
talonFX.getConfigurator().apply(talonFXConfigurations)
}

override fun getIntakeEncoder(): Double {
fun getIntakeEncoder(): Double {
TODO("Not yet implemented")
return 0.0;
}

override fun setIntakeMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
fun setIntakeMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(x))
}

override fun setCoralIntakeState(state: CoralIntakeState) {
TODO("Not yet implemented")
}

override fun setAlgaeIntakeState(state: AlgaeIntakeState) {
TODO("Not yet implemented")
}
}
13 changes: 13 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package frc.robot.subsystems.intake

enum class CoralIntakeState {
Intaking,
Idle,
Scoring
}

enum class AlgaeIntakeState {
Intaking,
Idle,
Scoring
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/intake/IntakeSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase

// By making a subsystem a Kotlin object, we ensure there is only ever one instance of it.
// It also reduces the need to have reference variables for the subsystems to be passed around.
object IntakeSystem : SubsystemBase() {
class IntakeSystem(private val io: IntakeIO) : SubsystemBase() {
/**
* Example command factory method.
*
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/subsystems/pivot/PivotIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX

interface PivotIO {
var talonFX: TalonFX
var talonFXConfigs: TalonFXConfiguration
fun getPivotEncoder(): Double
fun setPivotMotor(x: Double)
// fun getPivotEncoder(): Double

// fun setPivotMotor(x: Double)
fun setAngle(angleDegrees: Double)
}
10 changes: 7 additions & 3 deletions src/main/java/frc/robot/subsystems/pivot/PivotIOReal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ class PivotIOReal : PivotIO {
talonFX.getConfigurator().apply(talonFXConfigurations)
}

override fun getPivotEncoder(): Double {
fun getPivotEncoder(): Double {
TODO("Not yet implemented")
return 0.0;
}

override fun setPivotMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
fun setPivotMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(x))
}

override fun setAngle(angleDegrees: Double) {
TODO("Not yet implemented")
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/pivot/PivotSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase

// By making a subsystem a Kotlin object, we ensure there is only ever one instance of it.
// It also reduces the need to have reference variables for the subsystems to be passed around.
object PivotSystem : SubsystemBase() {
class PivotSystem(private val io: PivotIO) : SubsystemBase() {
/**
* Example command factory method.
*
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/frc/robot/subsystems/wrist/WristIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX

interface WristIO {
var talonFX: TalonFX
var talonFXConfigs: TalonFXConfiguration
fun getWristEncoder(): Double
fun setWristMotor(x: Double)
// fun getWristEncoder(): Double
// fun setWristMotor(x: Double)
fun setAngle(angleDegrees: Double)
}
12 changes: 8 additions & 4 deletions src/main/java/frc/robot/subsystems/wrist/WristIOReal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.ctre.phoenix6.hardware.TalonFX
import com.ctre.phoenix6.controls.MotionMagicVoltage
import frc.robot.constants.WristConstants

class WristIOReal : WristIO {
class WristIOReal() : WristIO {

var talonFX = TalonFX(WristConstants.id, WristConstants.canbus)
var talonFXConfigurations = TalonFXConfiguration()
Expand All @@ -24,12 +24,16 @@ class WristIOReal : WristIO {
talonFX.getConfigurator().apply(talonFXConfigurations)
}

override fun getWristEncoder(): Double {
fun getWristEncoder(): Double {
TODO("Not yet implemented")
return 0.0;
}

override fun setWristMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
fun setWristMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(x))
}

override fun setAngle(angleDegrees: Double) {
TODO("Not yet implemented")
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/wrist/WristSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase

// By making a subsystem a Kotlin object, we ensure there is only ever one instance of it.
// It also reduces the need to have reference variables for the subsystems to be passed around.
object WristSystem : SubsystemBase() {
class WristSystem(private val io: WristIO) : SubsystemBase() {
/**
* Example command factory method.
*
Expand Down

0 comments on commit 57fc32d

Please sign in to comment.