From f5a1d3ad3f657ac97a61c1cc215739df9590104c Mon Sep 17 00:00:00 2001 From: Sachet Korada Date: Thu, 7 Nov 2024 15:42:08 -0500 Subject: [PATCH] cleanup --- TeamCode/build.gradle | 2 +- .../ftc/teamcode/commands/drive/ArmCommand.kt | 4 ++-- .../commands/drive/SpinDownCommand.kt | 4 ++-- .../teamcode/commands/drive/SpinUpCommand.kt | 4 ++-- .../ftc/teamcode/opModes/teleOp/MainTeleOp.kt | 20 +++++++++---------- .../teamcode/subsystems/arm/ArmSubsystem.kt | 11 +++++----- .../subsystems/drive/DriveSubsystem.kt | 2 +- .../subsystems/slides/SlidesSubsystem.kt | 8 ++++---- .../utils/roadrunner/drive/DriveConstants.kt | 6 ++++-- 9 files changed, 32 insertions(+), 29 deletions(-) diff --git a/TeamCode/build.gradle b/TeamCode/build.gradle index 1b5e83c..b7b3b13 100644 --- a/TeamCode/build.gradle +++ b/TeamCode/build.gradle @@ -19,7 +19,7 @@ apply from: '../build.dependencies.gradle' apply plugin: 'kotlin-android' kotlin { - jvmToolchain(17) + jvmToolchain(17) } android { diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/ArmCommand.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/ArmCommand.kt index c590585..1757da7 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/ArmCommand.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/ArmCommand.kt @@ -4,8 +4,8 @@ import com.arcrobotics.ftclib.command.CommandBase import org.firstinspires.ftc.teamcode.subsystems.arm.ArmSubsystem class ArmCommand( - private val subsystem: ArmSubsystem, - private val turn : Boolean, + private val subsystem: ArmSubsystem, + private val turn: Boolean, ) : CommandBase() { override fun execute() { diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinDownCommand.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinDownCommand.kt index 648ef84..62c81f2 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinDownCommand.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinDownCommand.kt @@ -3,8 +3,8 @@ package org.firstinspires.ftc.teamcode.commands.drive import com.arcrobotics.ftclib.command.CommandBase import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsystem -class SpinDownCommand ( - private val subsystem: SlidesSubsystem +class SpinDownCommand( + private val subsystem: SlidesSubsystem ) : CommandBase() { diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinUpCommand.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinUpCommand.kt index c847526..7bf40c7 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinUpCommand.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/commands/drive/SpinUpCommand.kt @@ -3,8 +3,8 @@ package org.firstinspires.ftc.teamcode.commands.drive import com.arcrobotics.ftclib.command.CommandBase import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsystem -class SpinUpCommand ( - private val subsystem: SlidesSubsystem +class SpinUpCommand( + private val subsystem: SlidesSubsystem ) : CommandBase() { override fun execute() { diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/opModes/teleOp/MainTeleOp.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/opModes/teleOp/MainTeleOp.kt index 461bb75..65c4586 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/opModes/teleOp/MainTeleOp.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/opModes/teleOp/MainTeleOp.kt @@ -1,7 +1,6 @@ package org.firstinspires.ftc.teamcode.opModes.teleOp import com.arcrobotics.ftclib.command.CommandOpMode -import com.arcrobotics.ftclib.command.InstantCommand import com.arcrobotics.ftclib.command.RunCommand import com.arcrobotics.ftclib.gamepad.GamepadEx import com.arcrobotics.ftclib.gamepad.GamepadKeys @@ -17,12 +16,12 @@ import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsystem @TeleOp -class MainTeleOp: CommandOpMode() { +class MainTeleOp : CommandOpMode() { - private lateinit var elevatorLeft : Motor - private lateinit var elevatorRight : Motor - private lateinit var armLeft : Motor - private lateinit var armRight : Motor + private lateinit var elevatorLeft: Motor + private lateinit var elevatorRight: Motor + private lateinit var armLeft: Motor + private lateinit var armRight: Motor private lateinit var slidesSubsystem: SlidesSubsystem @@ -35,8 +34,8 @@ class MainTeleOp: CommandOpMode() { private lateinit var armDownCommand: ArmCommand private lateinit var driveCommand: DriveCommand - private lateinit var driver : GamepadEx - private lateinit var operator : GamepadEx + private lateinit var driver: GamepadEx + private lateinit var operator: GamepadEx override fun initialize() { driver = GamepadEx(gamepad1) @@ -55,10 +54,11 @@ class MainTeleOp: CommandOpMode() { spinDownCommand = SpinDownCommand(slidesSubsystem) armUpCommand = ArmCommand(armSubsystem, true) armDownCommand = ArmCommand(armSubsystem, false) - driveCommand = DriveCommand(driveSubsystem, driver::getLeftX, driver::getLeftY, driver::getRightX, 0.0) + driveCommand = + DriveCommand(driveSubsystem, driver::getLeftX, driver::getLeftY, driver::getRightX, 0.0) //operator.getGamepadButton(GamepadKeys.Button.DPAD_UP).whileHeld(spinUpCommand) - // operator.getGamepadButton(GamepadKeys.Button.DPAD_DOWN).whileHeld(spinDownCommand) + // operator.getGamepadButton(GamepadKeys.Button.DPAD_DOWN).whileHeld(spinDownCommand) operator.getGamepadButton(GamepadKeys.Button.RIGHT_BUMPER).whileHeld(armUpCommand) operator.getGamepadButton(GamepadKeys.Button.LEFT_BUMPER).whileHeld(armDownCommand) diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/arm/ArmSubsystem.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/arm/ArmSubsystem.kt index 05afc8b..cd8982e 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/arm/ArmSubsystem.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/arm/ArmSubsystem.kt @@ -6,14 +6,15 @@ import com.arcrobotics.ftclib.hardware.motors.Motor import com.arcrobotics.ftclib.hardware.motors.Motor.GoBILDA import com.arcrobotics.ftclib.hardware.motors.MotorGroup import kotlin.math.PI +import kotlin.math.cos @Config class ArmSubsystem( // Here I am just declaring the motors and what they are called on our driver hub. - private val armRight : Motor, - private val armLeft : Motor, + private val armRight: Motor, + private val armLeft: Motor, -) : SubsystemBase() { + ) : SubsystemBase() { //Here I am making a motor group, as the arm motors are going to work together to to turn the slides. @@ -28,7 +29,7 @@ class ArmSubsystem( } -// Here are functions that work the motor, and the double is the speed of the motor, 1 being 100%. + // Here are functions that work the motor, and the double is the speed of the motor, 1 being 100%. fun clockwise() { turnMotors.set(0.35) } @@ -38,7 +39,7 @@ class ArmSubsystem( } fun stop() { - turnMotors.set(kCos * Math.cos(armAngle)) + turnMotors.set(kCos * cos(armAngle)) } companion object { diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/drive/DriveSubsystem.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/drive/DriveSubsystem.kt index ed6b1bd..dc83904 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/drive/DriveSubsystem.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/drive/DriveSubsystem.kt @@ -97,7 +97,7 @@ class DriveSubsystem @JvmOverloads constructor( setPIDFCoefficients(DcMotor.RunMode.RUN_USING_ENCODER, DriveConstants.MOTOR_VELO_PID) } - // leftFront.direction = DcMotorSimple.Direction.REVERSE + // leftFront.direction = DcMotorSimple.Direction.REVERSE leftRear.direction = DcMotorSimple.Direction.REVERSE localizer = StandardTrackingWheelLocalizer(hardwareMap) diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/slides/SlidesSubsystem.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/slides/SlidesSubsystem.kt index f6681ce..34734be 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/slides/SlidesSubsystem.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/subsystems/slides/SlidesSubsystem.kt @@ -5,11 +5,11 @@ import com.arcrobotics.ftclib.hardware.motors.Motor import com.arcrobotics.ftclib.hardware.motors.MotorGroup class SlidesSubsystem( - //sets them as a private variable thats a motor (same name as in driver hub) - private val elevatorLeft : Motor, - private val elevatorRight : Motor, + //sets them as a private variable thats a motor (same name as in driver hub) + private val elevatorLeft: Motor, + private val elevatorRight: Motor, -) : SubsystemBase() { + ) : SubsystemBase() { //makes a motor group bc you have to move them at the same time private val elevatorMotors = MotorGroup(elevatorLeft, elevatorRight) diff --git a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/utils/roadrunner/drive/DriveConstants.kt b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/utils/roadrunner/drive/DriveConstants.kt index 5fec70e..e663bd7 100644 --- a/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/utils/roadrunner/drive/DriveConstants.kt +++ b/TeamCode/src/main/kotlin/org/firstinspires/ftc/teamcode/utils/roadrunner/drive/DriveConstants.kt @@ -33,8 +33,10 @@ object DriveConstants { * from DriveVelocityPIDTuner. */ const val RUN_USING_ENCODER = false - var MOTOR_VELO_PID = PIDFCoefficients(0.0, 0.0, 0.0, - getMotorVelocityF(MAX_RPM / 60 * TICKS_PER_REV)) + var MOTOR_VELO_PID = PIDFCoefficients( + 0.0, 0.0, 0.0, + getMotorVelocityF(MAX_RPM / 60 * TICKS_PER_REV) + ) /* * These are physical constants that can be determined from your robot (including the track