Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superstructure implementation #2

Merged
merged 14 commits into from
Feb 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Warren's changes to this branch
PY44N committed Jan 31, 2025
commit c8c2cbc4dc081b0b4949f6a1e0bb0aac3990f0c5
16 changes: 16 additions & 0 deletions src/main/java/frc/robot/constants/ElevatorConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +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 id = 0
val canbus = ""
}
16 changes: 16 additions & 0 deletions src/main/java/frc/robot/constants/IntakeConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +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 id = 0
val canbus = ""
}
16 changes: 16 additions & 0 deletions src/main/java/frc/robot/constants/PivotConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +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 id = 0
val canbus = ""
}
16 changes: 16 additions & 0 deletions src/main/java/frc/robot/constants/WristConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +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 id = 0
val canbus = ""
}
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/subsystems/elevator/ElevatorIO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package frc.robot.subsystems.elevator

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)
}
35 changes: 35 additions & 0 deletions src/main/java/frc/robot/subsystems/elevator/ElevatorIOReal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frc.robot.subsystems.elevator

import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX
import com.ctre.phoenix6.controls.MotionMagicVoltage
import frc.robot.constants.ElevatorConstants

class ElevatorIOReal : ElevatorIO {

var talonFX = TalonFX(ElevatorConstants.id, ElevatorConstants.canbus)
var talonFXConfigurations = TalonFXConfiguration()

init {
talonFXConfigurations.Slot0.kG = ElevatorConstants.kG
talonFXConfigurations.Slot0.kS = ElevatorConstants.kS
talonFXConfigurations.Slot0.kV = ElevatorConstants.kV
talonFXConfigurations.Slot0.kA = ElevatorConstants.kA
talonFXConfigurations.Slot0.kP = ElevatorConstants.kP
talonFXConfigurations.Slot0.kI = ElevatorConstants.kI
talonFXConfigurations.Slot0.kD = ElevatorConstants.kD
talonFXConfigurations.MotionMagic.MotionMagicCruiseVelocity = ElevatorConstants.targetVelocity
talonFXConfigurations.MotionMagic.MotionMagicAcceleration = ElevatorConstants.targetAcceleration
talonFXConfigurations.MotionMagic.MotionMagicJerk = ElevatorConstants.targetJerk
talonFX.getConfigurator().apply(talonFXConfigurations)
}

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

override fun setMotorPosition(rotations: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
}
}
51 changes: 51 additions & 0 deletions src/main/java/frc/robot/subsystems/elevator/ElevatorSystem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package frc.robot.subsystems.elevator

import edu.wpi.first.wpilibj2.command.SubsystemBase
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() {
/**
* Example command factory method.
*
* @return a command
*/
// fun exampleMethodCommand(): Command = runOnce {
// // Subsystem.runOnce() implicitly add `this` as a required subsystem.
// // TODO: one-time action goes here
// }

/**
* An example method querying a boolean state of the subsystem (for example, a digital sensor).
*
* @return value of some boolean subsystem state, such as a digital sensor.
*/
// fun exampleCondition(): Boolean {
// // Query some boolean state, such as a digital sensor.
// return false
// }

override fun periodic() {
// This method will be called once per scheduler run
}

override fun simulationPeriodic() {
// This method will be called once per scheduler run during simulation
}

// fun exampleAction()
// {
// // This action is called by the ExampleCommand
// println("ExampleSubsystem.exampleAction has been called")
// }

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

fun setPos(x: Double) {
TODO("Not yet implemented")
}
}
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeIO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package frc.robot.subsystems.intake

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)
}
35 changes: 35 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeIOReal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frc.robot.subsystems.intake

import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX
import com.ctre.phoenix6.controls.MotionMagicVoltage
import frc.robot.constants.IntakeConstants

class IntakeIOReal : IntakeIO {

var talonFX = TalonFX(IntakeConstants.id, IntakeConstants.canbus)
var talonFXConfigurations = TalonFXConfiguration()

init {
talonFXConfigurations.Slot0.kG = IntakeConstants.kG
talonFXConfigurations.Slot0.kS = IntakeConstants.kS
talonFXConfigurations.Slot0.kV = IntakeConstants.kV
talonFXConfigurations.Slot0.kA = IntakeConstants.kA
talonFXConfigurations.Slot0.kP = IntakeConstants.kP
talonFXConfigurations.Slot0.kI = IntakeConstants.kI
talonFXConfigurations.Slot0.kD = IntakeConstants.kD
talonFXConfigurations.MotionMagic.MotionMagicCruiseVelocity = IntakeConstants.targetVelocity
talonFXConfigurations.MotionMagic.MotionMagicAcceleration = IntakeConstants.targetAcceleration
talonFXConfigurations.MotionMagic.MotionMagicJerk = IntakeConstants.targetJerk
talonFX.getConfigurator().apply(talonFXConfigurations)
}

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

override fun setIntakeMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
}
}
50 changes: 50 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeSystem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package frc.robot.subsystems.intake

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() {
/**
* Example command factory method.
*
* @return a command
*/
// fun exampleMethodCommand(): Command = runOnce {
// // Subsystem.runOnce() implicitly add `this` as a required subsystem.
// // TODO: one-time action goes here
// }

/**
* An example method querying a boolean state of the subsystem (for example, a digital sensor).
*
* @return value of some boolean subsystem state, such as a digital sensor.
*/
// fun exampleCondition(): Boolean {
// // Query some boolean state, such as a digital sensor.
// return false
// }

override fun periodic() {
// This method will be called once per scheduler run
}

override fun simulationPeriodic() {
// This method will be called once per scheduler run during simulation
}

// fun exampleAction()
// {
// // This action is called by the ExampleCommand
// println("ExampleSubsystem.exampleAction has been called")
// }

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

fun setPos(x: Double) {
TODO("Not yet implemented")
}
}
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/subsystems/pivot/PivotIO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package frc.robot.subsystems.pivot

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)
}
35 changes: 35 additions & 0 deletions src/main/java/frc/robot/subsystems/pivot/PivotIOReal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frc.robot.subsystems.pivot

import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX
import com.ctre.phoenix6.controls.MotionMagicVoltage
import frc.robot.constants.PivotConstants

class PivotIOReal : PivotIO {

var talonFX = TalonFX(PivotConstants.id, PivotConstants.canbus)
var talonFXConfigurations = TalonFXConfiguration()

init {
talonFXConfigurations.Slot0.kG = PivotConstants.kG
talonFXConfigurations.Slot0.kS = PivotConstants.kS
talonFXConfigurations.Slot0.kV = PivotConstants.kV
talonFXConfigurations.Slot0.kA = PivotConstants.kA
talonFXConfigurations.Slot0.kP = PivotConstants.kP
talonFXConfigurations.Slot0.kI = PivotConstants.kI
talonFXConfigurations.Slot0.kD = PivotConstants.kD
talonFXConfigurations.MotionMagic.MotionMagicCruiseVelocity = PivotConstants.targetVelocity
talonFXConfigurations.MotionMagic.MotionMagicAcceleration = PivotConstants.targetAcceleration
talonFXConfigurations.MotionMagic.MotionMagicJerk = PivotConstants.targetJerk
talonFX.getConfigurator().apply(talonFXConfigurations)
}

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

override fun setPivotMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
}
}
50 changes: 50 additions & 0 deletions src/main/java/frc/robot/subsystems/pivot/PivotSystem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package frc.robot.subsystems.pivot

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() {
/**
* Example command factory method.
*
* @return a command
*/
// fun exampleMethodCommand(): Command = runOnce {
// // Subsystem.runOnce() implicitly add `this` as a required subsystem.
// // TODO: one-time action goes here
// }

/**
* An example method querying a boolean state of the subsystem (for example, a digital sensor).
*
* @return value of some boolean subsystem state, such as a digital sensor.
*/
// fun exampleCondition(): Boolean {
// // Query some boolean state, such as a digital sensor.
// return false
// }

override fun periodic() {
// This method will be called once per scheduler run
}

override fun simulationPeriodic() {
// This method will be called once per scheduler run during simulation
}

// fun exampleAction()
// {
// // This action is called by the ExampleCommand
// println("ExampleSubsystem.exampleAction has been called")
// }

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

fun setPos(x: Double) {
TODO("Not yet implemented")
}
}
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/subsystems/wrist/WristIO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package frc.robot.subsystems.wrist

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)
}
35 changes: 35 additions & 0 deletions src/main/java/frc/robot/subsystems/wrist/WristIOReal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frc.robot.subsystems.wrist

import com.ctre.phoenix6.configs.TalonFXConfiguration
import com.ctre.phoenix6.hardware.TalonFX
import com.ctre.phoenix6.controls.MotionMagicVoltage
import frc.robot.constants.WristConstants

class WristIOReal : WristIO {

var talonFX = TalonFX(WristConstants.id, WristConstants.canbus)
var talonFXConfigurations = TalonFXConfiguration()

init {
talonFXConfigurations.Slot0.kG = WristConstants.kG
talonFXConfigurations.Slot0.kS = WristConstants.kS
talonFXConfigurations.Slot0.kV = WristConstants.kV
talonFXConfigurations.Slot0.kA = WristConstants.kA
talonFXConfigurations.Slot0.kP = WristConstants.kP
talonFXConfigurations.Slot0.kI = WristConstants.kI
talonFXConfigurations.Slot0.kD = WristConstants.kD
talonFXConfigurations.MotionMagic.MotionMagicCruiseVelocity = WristConstants.targetVelocity
talonFXConfigurations.MotionMagic.MotionMagicAcceleration = WristConstants.targetAcceleration
talonFXConfigurations.MotionMagic.MotionMagicJerk = WristConstants.targetJerk
talonFX.getConfigurator().apply(talonFXConfigurations)
}

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

override fun setWristMotor(x: Double) {
talonFX.setControl(MotionMagicVoltage(rotations))
}
}
50 changes: 50 additions & 0 deletions src/main/java/frc/robot/subsystems/wrist/WristSystem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package frc.robot.subsystems.wrist

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() {
/**
* Example command factory method.
*
* @return a command
*/
// fun exampleMethodCommand(): Command = runOnce {
// // Subsystem.runOnce() implicitly add `this` as a required subsystem.
// // TODO: one-time action goes here
// }

/**
* An example method querying a boolean state of the subsystem (for example, a digital sensor).
*
* @return value of some boolean subsystem state, such as a digital sensor.
*/
// fun exampleCondition(): Boolean {
// // Query some boolean state, such as a digital sensor.
// return false
// }

override fun periodic() {
// This method will be called once per scheduler run
}

override fun simulationPeriodic() {
// This method will be called once per scheduler run during simulation
}

// fun exampleAction()
// {
// // This action is called by the ExampleCommand
// println("ExampleSubsystem.exampleAction has been called")
// }

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

fun setPos(x: Double) {
TODO("Not yet implemented")
}
}