Skip to content

Commit

Permalink
fixed big problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan Ghaskadbi authored and Ishaan Ghaskadbi committed Oct 28, 2024
1 parent 5af7472 commit 5ca8677
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 134 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
) : CommandBase() {


override fun execute() {
subsystem.down()
}

override fun end(interrupted: Boolean) {
subsystem.stop()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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
) : CommandBase() {

override fun execute() {
subsystem.up()
}

override fun end(interrupted: Boolean) {
subsystem.stop()
}


}
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
package org.firstinspires.ftc.teamcode.opModes.teleOp

import com.arcrobotics.ftclib.command.CommandOpMode
import com.arcrobotics.ftclib.gamepad.GamepadEx
import com.arcrobotics.ftclib.gamepad.GamepadKeys
import com.arcrobotics.ftclib.hardware.motors.Motor
import com.qualcomm.robotcore.eventloop.opmode.TeleOp
import org.firstinspires.ftc.teamcode.commands.drive.SpinDownCommand
import org.firstinspires.ftc.teamcode.commands.drive.SpinUpCommand
import org.firstinspires.ftc.teamcode.constants.ControlBoard
import org.firstinspires.ftc.teamcode.subsystems.slides.SlidesSubsystem

@TeleOp
class MainTeleOp: CommandOpMode() {

private lateinit var leftSlideString : Motor
private lateinit var rightSlideString : Motor


private lateinit var slidesSubsystem: SlidesSubsystem


private lateinit var spinUpCommand: SpinUpCommand
private lateinit var spinDownCommand: SpinDownCommand


private lateinit var driver : GamepadEx
private lateinit var operator : GamepadEx

override fun initialize() {
TODO("Not yet implemented")
driver = GamepadEx(gamepad1)
operator = GamepadEx(gamepad2)

rightSlideString = Motor(hardwareMap, ControlBoard.SLIDES_RIGHT.deviceName)
leftSlideString = Motor(hardwareMap, ControlBoard.SLIDES_LEFT.deviceName)


slidesSubsystem = SlidesSubsystem(rightSlideString, leftSlideString)


spinUpCommand = SpinUpCommand(slidesSubsystem)
spinDownCommand = SpinDownCommand(slidesSubsystem)

operator.getGamepadButton(GamepadKeys.Button.DPAD_UP).whileHeld(spinUpCommand)
operator.getGamepadButton(GamepadKeys.Button.DPAD_DOWN).whileHeld(spinDownCommand)
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
package org.firstinspires.ftc.teamcode.roadrunner.drive;
package org.firstinspires.ftc.teamcode.utils.roadrunner.drive

import com.acmerobotics.dashboard.config.Config;
import com.qualcomm.robotcore.hardware.PIDFCoefficients;
import com.acmerobotics.dashboard.config.Config
import com.qualcomm.robotcore.hardware.PIDFCoefficients

/*
* Constants shared between multiple drive types.
*
* Constants generated by LearnRoadRunner.com/drive-constants
*
* TODO: Tune or adjust the following constants to fit your robot. Note that the non-final
* fields may also be edited through the dashboard (connect to the robot's WiFi network and
* navigate to https://192.168.49.1:8080/dash). Make sure to save the values here after you
* adjust them in the dashboard; **config variable changes don't persist between app restarts**.
*
* These are not the only parameters; some are located in the localizer classes, drive base classes,
* and op modes themselves.
*/
* Constants shared between multiple drive types.
*
* Constants generated by LearnRoadRunner.com/drive-constants
*
* TODO: Tune or adjust the following constants to fit your robot. Note that the non-final
* fields may also be edited through the dashboard (connect to the robot's WiFi network and
* navigate to https://192.168.49.1:8080/dash). Make sure to save the values here after you
* adjust them in the dashboard; **config variable changes don't persist between app restarts**.
*
* These are not the only parameters; some are located in the localizer classes, drive base classes,
* and op modes themselves.
*/
@Config
public class DriveConstants {

object DriveConstants {
/*
* These are motor constants that should be listed online for your motors.
*/
public static final double TICKS_PER_REV = 383.6;
public static final double MAX_RPM = 435;
const val TICKS_PER_REV = 383.6
const val MAX_RPM = 435.0

/*
* Set RUN_USING_ENCODER to true to enable built-in hub velocity control using drive encoders.
Expand All @@ -33,9 +32,9 @@ public class DriveConstants {
* If using the built-in motor velocity PID, update MOTOR_VELO_PID with the tuned coefficients
* from DriveVelocityPIDTuner.
*/
public static final boolean RUN_USING_ENCODER = false;
public static PIDFCoefficients MOTOR_VELO_PID = new PIDFCoefficients(0, 0, 0,
getMotorVelocityF(MAX_RPM / 60 * TICKS_PER_REV));
const val RUN_USING_ENCODER = false
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
Expand All @@ -45,19 +44,19 @@ public class DriveConstants {
* angular distances although most angular parameters are wrapped in Math.toRadians() for
* convenience. Make sure to exclude any gear ratio included in MOTOR_CONFIG from GEAR_RATIO.
*/
public static double WHEEL_RADIUS = 1.88976; // in`
public static double GEAR_RATIO = 0.5; // output (wheel) speed / input (motor) speed
public static double TRACK_WIDTH = 13.1; // in
var WHEEL_RADIUS = 1.88976 // in`
var GEAR_RATIO = 0.5 // output (wheel) speed / input (motor) speed
var TRACK_WIDTH = 13.1 // in

/*
* These are the feedforward parameters used to model the drive motor behavior. If you are using
* the built-in velocity PID, *these values are fine as is*. However, if you do not have drive
* motor encoders or have elected not to use them for velocity control, these values should be
* empirically tuned.
*/
public static double kV = 0.024;
public static double kA = 0.003;
public static double kStatic = 0.01;
var kV = 0.024
var kA = 0.003
var kStatic = 0.01

/*
* These values are used to generate the trajectories for you robot. To ensure proper operation,
Expand Down Expand Up @@ -87,22 +86,20 @@ public class DriveConstants {
* You are free to raise this on your own if you would like. It is best determined through experimentation.
*/
public static double MAX_VEL = 38.110287416570166;
public static double MAX_ACCEL = 38.110287416570166;
public static double MAX_ANG_VEL = Math.toRadians(355.94452299662714);
public static double MAX_ANG_ACCEL = Math.toRadians(172.2983035714285);


public static double encoderTicksToInches(double ticks) {
return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV;
var MAX_VEL = 38.110287416570166
var MAX_ACCEL = 38.110287416570166
var MAX_ANG_VEL = Math.toRadians(355.94452299662714)
var MAX_ANG_ACCEL = Math.toRadians(172.2983035714285)
fun encoderTicksToInches(ticks: Double): Double {
return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV
}

public static double rpmToVelocity(double rpm) {
return rpm * GEAR_RATIO * 2 * Math.PI * WHEEL_RADIUS / 60.0;
fun rpmToVelocity(rpm: Double): Double {
return rpm * GEAR_RATIO * 2 * Math.PI * WHEEL_RADIUS / 60.0
}

public static double getMotorVelocityF(double ticksPerSecond) {
// see https://docs.google.com/document/d/1tyWrXDfMidwYyP_5H4mZyVgaEswhOC35gvdmP-V-5hA/edit#heading=h.61g9ixenznbx
return 32767 / ticksPerSecond;
fun getMotorVelocityF(ticksPerSecond: Double): Double {
// see https://docs.google.com/document/d/1tyWrXDfMidwYyP_5H4mZyVgaEswhOC35gvdmP-V-5hA/edit#heading=h.61g9ixenznbx
return 32767 / ticksPerSecond
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ class StandardTrackingWheelLocalizer(hardwareMap: HardwareMap) : ThreeTrackingWh

companion object {
val TICKS_PER_REV = 8192.0
val WHEEL_RADIUS = 0.74803 // in
val WHEEL_RADIUS = 0.6889764 // in
val GEAR_RATIO = 1.0 // output (wheel) speed / input (encoder) speed

@JvmField
var LATERAL_DISTANCE = 15.48986087647907 // in; distance between the left and right wheels
var LATERAL_DISTANCE = 12.3206682876705018 // in; distance between the left and right wheels

@JvmField
var FORWARD_OFFSET = 0.0 // in; offset of the lateral wheel
var FORWARD_OFFSET = 1.28125 // in; offset of the lateral wheel

var X_MULTIPLIER = 0.9943625369724665 // Multiplier in the X direction
var Y_MULTIPLIER = 0.9973390034543611 // Multiplier in the Y direction
var X_MULTIPLIER = 1.10506990189 // Multiplier in the X direction
var Y_MULTIPLIER = 1.09955932763 // Multiplier in the Y direction
fun encoderTicksToInches(ticks: Double): Double {
return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV
}
Expand Down

0 comments on commit 5ca8677

Please sign in to comment.