Skip to content

Commit

Permalink
fix the wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan Ghaskadbi authored and Ishaan Ghaskadbi committed Nov 3, 2024
1 parent b2184aa commit eae297c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.firstinspires.ftc.teamcode.commands.drive
import com.arcrobotics.ftclib.command.CommandBase
import org.firstinspires.ftc.teamcode.subsystems.drive.DriveSubsystem
import java.util.function.DoubleSupplier
import kotlin.math.pow

class DriveCommand(
private val subsystem: DriveSubsystem,
Expand All @@ -17,9 +18,9 @@ class DriveCommand(

override fun execute() {
subsystem.drive(
leftY = zonedDrive(-leftY.asDouble, zoneVal),
leftX = zonedDrive(leftX.asDouble, zoneVal),
rightX = zonedDrive(rightX.asDouble, zoneVal),
leftY = zonedDrive(-leftY.asDouble, zoneVal).pow(3),
leftX = zonedDrive(leftX.asDouble, zoneVal).pow(3),
rightX = zonedDrive(rightX.asDouble, zoneVal).pow(3),
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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
import com.arcrobotics.ftclib.hardware.motors.Motor
Expand Down Expand Up @@ -42,8 +44,8 @@ class MainTeleOp: CommandOpMode() {

elevatorRight = Motor(hardwareMap, ControlBoard.SLIDES_RIGHT.deviceName)
elevatorLeft = Motor(hardwareMap, ControlBoard.SLIDES_LEFT.deviceName)
armRight = Motor(hardwareMap, ControlBoard.ARM_RIGHT.deviceName)
armLeft = Motor(hardwareMap, ControlBoard.ARM_LEFT.deviceName)
armRight = Motor(hardwareMap, ControlBoard.ARM_RIGHT.deviceName, Motor.GoBILDA.RPM_435)
armLeft = Motor(hardwareMap, ControlBoard.ARM_LEFT.deviceName, Motor.GoBILDA.RPM_435)

slidesSubsystem = SlidesSubsystem(elevatorRight, elevatorLeft)
armSubsystem = ArmSubsystem(armRight, armLeft)
Expand All @@ -53,13 +55,18 @@ class MainTeleOp: CommandOpMode() {
spinDownCommand = SpinDownCommand(slidesSubsystem)
armUpCommand = ArmCommand(armSubsystem, true)
armDownCommand = ArmCommand(armSubsystem, false)
driveCommand = DriveCommand(driveSubsystem, driver::getLeftX, driver::getLeftY, driver::getRightX, 0.1)
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.RIGHT_BUMPER).whileHeld(armUpCommand)
operator.getGamepadButton(GamepadKeys.Button.LEFT_BUMPER).whileHeld(armDownCommand)

driveSubsystem.defaultCommand = driveCommand

RunCommand({
telemetry.addData("Arm Position: ", armSubsystem.armAngle)
telemetry.update()
}).perpetually().schedule()
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.firstinspires.ftc.teamcode.subsystems.arm

import com.acmerobotics.dashboard.config.Config
import com.arcrobotics.ftclib.command.SubsystemBase
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

@Config
class ArmSubsystem(
// Here I am just declaring the motors and what they are called on our driver hub.
private val armRight : Motor,
Expand All @@ -14,6 +18,8 @@ class ArmSubsystem(
//Here I am making a motor group, as the arm motors are going to work together to to turn the slides.

private val turnMotors = MotorGroup(armRight, armLeft)
val armAngle: Double
get() = turnMotors.positions[0] / GoBILDA.RPM_435.cpr * 2 * PI

init {
armLeft.inverted = true
Expand All @@ -32,8 +38,11 @@ class ArmSubsystem(
}

fun stop() {
turnMotors.set(0.0)
turnMotors.set(kCos * Math.cos(armAngle))
}


companion object {
@JvmField
var kCos = 0.3
}
}

0 comments on commit eae297c

Please sign in to comment.