-
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
Ishaan Ghaskadbi
authored and
Ishaan Ghaskadbi
committed
Nov 20, 2024
1 parent
fbb95c0
commit 0ecc580
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...ode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/slides/SlidesSubsytemPID.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,58 @@ | ||
package org.firstinspires.ftc.teamcode.subsystems.slides | ||
|
||
import com.acmerobotics.dashboard.config.Config | ||
import com.arcrobotics.ftclib.controller.PIDController | ||
import com.arcrobotics.ftclib.hardware.motors.Motor | ||
import com.arcrobotics.ftclib.hardware.motors.Motor.GoBILDA | ||
import com.arcrobotics.ftclib.hardware.motors.MotorGroup | ||
import org.firstinspires.ftc.teamcode.utils.PIDSubsystem | ||
import kotlin.math.PI | ||
|
||
@Config | ||
class SlidesSubsytemPID( | ||
elevatorLeft : Motor, | ||
elevatorRight : Motor | ||
) : PIDSubsystem( | ||
PIDController( | ||
0.0, | ||
0.0, | ||
0.0, | ||
) | ||
) { | ||
private val extendMotors = MotorGroup(elevatorLeft, elevatorRight) | ||
|
||
val slideAngle: Double | ||
get() = extendMotors.positions[0] / GoBILDA.RPM_435.cpr * 2 * PI | ||
|
||
val slideVelocity: Double | ||
get() = extendMotors.velocities[0] / GoBILDA.RPM_435.cpr * 2 * PI | ||
|
||
init { | ||
elevatorLeft.inverted = true | ||
elevatorLeft.encoder.setDirection(Motor.Direction.REVERSE) | ||
|
||
extendMotors.resetEncoder() | ||
extendMotors.setZeroPowerBehavior(Motor.ZeroPowerBehavior.BRAKE) | ||
} | ||
|
||
override fun useOutput(output: Double, setpoint: Double) { | ||
// For tuning only | ||
controller.setPIDF(kP, kI, kD, 0.0) | ||
|
||
extendMotors.set(output) | ||
} | ||
|
||
override fun getMeasurement() = slideAngle | ||
|
||
companion object { | ||
|
||
@JvmField | ||
var kP = 0.0 | ||
|
||
@JvmField | ||
var kI = 0.0 | ||
|
||
@JvmField | ||
var kD = 0.0 | ||
} | ||
} |