Skip to content

Commit

Permalink
slides pid tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaP241 committed Nov 28, 2024
1 parent 6b6bad1 commit 34accb4
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.firstinspires.ftc.teamcode.commands.elevator

import com.arcrobotics.ftclib.command.CommandBase
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenSlidesSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenElevatorSubsystem

class SpinDownCommand(
private val subsystem: OpenSlidesSubsystem
private val subsystem: OpenElevatorSubsystem
) : CommandBase() {


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.firstinspires.ftc.teamcode.commands.elevator

import com.arcrobotics.ftclib.command.CommandBase
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenSlidesSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenElevatorSubsystem

class SpinUpCommand(
private val subsystem: OpenSlidesSubsystem
private val subsystem: OpenElevatorSubsystem
) : CommandBase() {

override fun execute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.firstinspires.ftc.teamcode.constants

enum class SlidesConstants(val value: Double) {
kP(0.0),
kP(0.03),
kI(0.0),
kD(0.0),
kD(0.0004),
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Blue High Basket Left", group = "Basket", preselectTeleOp = "MainTeleOp")
class BlueHighBasketLeft: OpMode() {
Expand All @@ -23,7 +23,7 @@ class BlueHighBasketLeft: OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
// intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,29 +37,29 @@ class BlueHighBasketLeft: OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
// intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.BLUE_LEFT.startPose)
.turn(Math.toRadians(90.0))
.forward(60.0)
.turn(Math.toRadians(-90.0))
.back(60.0)
.addTemporalMarker(3.0) {
armSubsystem.setpoint = Math.toRadians(95.0)
}
.waitSeconds(1.0)
.addTemporalMarker(6.0) {
elevatorSubsystem.setpoint = 250.0
elevatorSubsystem.setpoint = 1000.0
}
.waitSeconds(2.0)
// .addTemporalMarker(5.0){
// intakeSubsystem.outtake()
// }
.waitSeconds(1.0)
.addTemporalMarker(10.0) {
elevatorSubsystem.setpoint = 0.0
elevatorSubsystem.setpoint = 50.0
}
.waitSeconds(2.0)
.addTemporalMarker(13.0) {
armSubsystem.setpoint = Math.toRadians(0.0)
armSubsystem.setpoint = Math.toRadians(5.0)
}
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem


@Autonomous(name = "Blue High Basket Right", group = "Basket", preselectTeleOp = "MainTeleOp")
Expand All @@ -25,7 +25,7 @@ class BlueHighBasketRight() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -39,17 +39,17 @@ class BlueHighBasketRight() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.BLUE_RIGHT.startPose)
.turn(Math.toRadians(90.0))
.forward(35.0)
.addTemporalMarker(2.0) {
armSubsystem.setpoint = Math.toRadians(150.0)
armSubsystem.setpoint = Math.toRadians(90.0)
}
.waitSeconds(1.0)
.addTemporalMarker(3.0) {
elevatorSubsystem.setpoint = 2.0
elevatorSubsystem.setpoint = 200.0
}
.waitSeconds(2.0)
.addTemporalMarker(5.0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Blue High Chamber Left", group = "Chamber", preselectTeleOp = "MainTeleOp")
class BlueHighChamberLeft() : OpMode() {
Expand All @@ -23,7 +23,7 @@ class BlueHighChamberLeft() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,7 +37,7 @@ class BlueHighChamberLeft() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.BLUE_LEFT.startPose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Blue High Chamber Right", group = "Chamber", preselectTeleOp = "MainTeleOp")
class BlueHighChamberRight() : OpMode() {
Expand All @@ -23,7 +23,7 @@ class BlueHighChamberRight() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,7 +37,7 @@ class BlueHighChamberRight() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.BLUE_RIGHT.startPose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Red High Basket Left", group = "Basket", preselectTeleOp = "MainTeleOp")
class RedHighBasketLeft() : OpMode() {
Expand All @@ -24,7 +24,7 @@ class RedHighBasketLeft() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -38,7 +38,7 @@ class RedHighBasketLeft() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.RED_LEFT.startPose)
.turn(Math.toRadians(90.0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Red High Basket Right", group = "Basket", preselectTeleOp = "MainTeleOp")
class RedHighBasketRight() : OpMode() {
Expand All @@ -23,7 +23,7 @@ class RedHighBasketRight() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,7 +37,7 @@ class RedHighBasketRight() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.RED_RIGHT.startPose)
.turn(Math.toRadians(90.0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Red High Chamber Left", group = "Chamber", preselectTeleOp = "MainTeleOp")
class RedHighChamberLeft() : OpMode() {
Expand All @@ -23,7 +23,7 @@ class RedHighChamberLeft() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,7 +37,7 @@ class RedHighChamberLeft() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.RED_LEFT.startPose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@Autonomous(name = "Red High Chamber Right", group = "Chamber", preselectTeleOp = "MainTeleOp")
class RedHighChamberRight() : OpMode() {
Expand All @@ -23,7 +23,7 @@ class RedHighChamberRight() : OpMode() {
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
private lateinit var armSubsystem: ArmSubsystem
private lateinit var elevatorSubsystem: SlidesSubsytem
private lateinit var elevatorSubsystem: ElevatorSubsystem

override fun init() {
intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)
Expand All @@ -37,7 +37,7 @@ class RedHighChamberRight() : OpMode() {
driveSubsystem = DriveSubsystem(hardwareMap)
intakeSubsystem = IntakeSubsystem(intake)
armSubsystem = ArmSubsystem(armRight, armLeft)
elevatorSubsystem = SlidesSubsytem(elevatorRight, elevatorLeft)
elevatorSubsystem = ElevatorSubsystem(elevatorRight, elevatorLeft)

val trajectory = driveSubsystem.trajectorySequenceBuilder(AutoStartPose.RED_RIGHT.startPose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.arm.OpenArmSubsystem
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import org.firstinspires.ftc.teamcode.subsystems.intake.IntakeSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenSlidesSubsystem
import org.firstinspires.ftc.teamcode.subsystems.slides.OpenElevatorSubsystem

@TeleOp
class MainTeleOp : CommandOpMode() {
Expand All @@ -25,7 +25,7 @@ class MainTeleOp : CommandOpMode() {
private lateinit var armRight: Motor
//private lateinit var intake: CRServo

private lateinit var slidesSubsystem: OpenSlidesSubsystem
private lateinit var slidesSubsystem: OpenElevatorSubsystem
private lateinit var armSubsystem: OpenArmSubsystem
private lateinit var driveSubsystem: DriveSubsystem
private lateinit var intakeSubsystem: IntakeSubsystem
Expand Down Expand Up @@ -54,7 +54,7 @@ class MainTeleOp : CommandOpMode() {

//intake = CRServo(hardwareMap, ControlBoard.INTAKE.deviceName)

slidesSubsystem = OpenSlidesSubsystem(elevatorRight, elevatorLeft)
slidesSubsystem = OpenElevatorSubsystem(elevatorRight, elevatorLeft)
armSubsystem = OpenArmSubsystem(armRight, armLeft)
driveSubsystem = DriveSubsystem(hardwareMap)
//intakeSubsystem = IntakeSubsystem(intake)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import com.arcrobotics.ftclib.command.RunCommand
import com.arcrobotics.ftclib.hardware.motors.Motor
import com.qualcomm.robotcore.eventloop.opmode.TeleOp
import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsytem
import org.firstinspires.ftc.teamcode.subsystems.slides.ElevatorSubsystem

@TeleOp
@Config
class SlidesPIDTuner : CommandOpMode() {
private lateinit var armLeft: Motor
private lateinit var armRight: Motor

private lateinit var slidesSubsystem: SlidesSubsytem
private lateinit var slidesSubsystem: ElevatorSubsystem

override fun initialize() {
telemetry = MultipleTelemetry(telemetry, FtcDashboard.getInstance().telemetry)

armLeft = Motor(hardwareMap, ControlBoard.SLIDES_LEFT.deviceName, Motor.GoBILDA.RPM_1150)
armRight = Motor(hardwareMap, ControlBoard.SLIDES_RIGHT.deviceName, Motor.GoBILDA.RPM_1150)

slidesSubsystem = SlidesSubsytem(armRight, armLeft)
slidesSubsystem = ElevatorSubsystem(armRight, armLeft)

RunCommand({
slidesSubsystem.setpoint = target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.firstinspires.ftc.teamcode.constants.SlidesConstants
import org.firstinspires.ftc.teamcode.utils.PIDSubsystem

@Config
class SlidesSubsytem(
class ElevatorSubsystem(
elevatorRight : Motor,
elevatorLeft : Motor
) : PIDSubsystem(
Expand All @@ -28,14 +28,27 @@ class SlidesSubsytem(

init {
elevatorRight.inverted = true
elevatorRight.encoder.setDirection(Motor.Direction.REVERSE)

extendMotors.resetEncoder()
extendMotors.setZeroPowerBehavior(Motor.ZeroPowerBehavior.BRAKE)
}

override fun useOutput(output: Double, setpoint: Double) {
controller.setPIDF(kP, kI, kD, 0.0)
extendMotors.set(output)
}

override fun getMeasurement() = slidePos

companion object {
@JvmField
var kP = 0.0

@JvmField
var kI = 0.0

@JvmField
var kD = 0.0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.arcrobotics.ftclib.command.SubsystemBase
import com.arcrobotics.ftclib.hardware.motors.Motor
import com.arcrobotics.ftclib.hardware.motors.MotorGroup

class OpenSlidesSubsystem(
class OpenElevatorSubsystem(
//sets them as a private variable thats a motor (same name as in driver hub)
elevatorLeft: Motor,
elevatorRight: Motor,
Expand Down

0 comments on commit 34accb4

Please sign in to comment.