Skip to content

Commit

Permalink
RR 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SachetK committed Dec 13, 2024
1 parent c253e9f commit 26713f9
Show file tree
Hide file tree
Showing 60 changed files with 1,897 additions and 2,009 deletions.
1 change: 1 addition & 0 deletions TeamCode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')

implementation 'org.apache.commons:commons-math3:3.6.1'
implementation "com.acmerobotics.roadrunner:ftc:0.1.14"
implementation 'com.acmerobotics.roadrunner:core:1.0.0'
implementation 'com.acmerobotics.roadrunner:actions:1.0.0'
implementation 'org.ftclib.ftclib:core:2.1.1' // core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import org.firstinspires.ftc.teamcode.messages.DriveCommandMessage
import org.firstinspires.ftc.teamcode.messages.MecanumCommandMessage
import org.firstinspires.ftc.teamcode.messages.MecanumLocalizerInputsMessage
import org.firstinspires.ftc.teamcode.messages.PoseMessage
import java.util.Arrays
import java.util.LinkedList
import kotlin.math.ceil
import kotlin.math.max
Expand Down Expand Up @@ -102,7 +101,7 @@ class MecanumDrive(hardwareMap: HardwareMap, var pose: Pose2d) {
PARAMS.maxAngVel, -PARAMS.maxAngAccel, PARAMS.maxAngAccel
)
val defaultVelConstraint: VelConstraint = MinVelConstraint(
Arrays.asList(
listOf(
kinematics.WheelVelConstraint(PARAMS.maxWheelVel),
AngularVelConstraint(PARAMS.maxAngVel)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.firstinspires.ftc.teamcode.constants

import com.acmerobotics.roadrunner.geometry.Pose2d
import com.acmerobotics.roadrunner.Pose2d

enum class AutoStartPose(val startPose: Pose2d) {
BLUE_LEFT(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.firstinspires.ftc.teamcode.constants

import com.acmerobotics.roadrunner.geometry.Pose2d
import com.acmerobotics.roadrunner.Pose2d

object PoseStorage {
var poseEstimate = Pose2d()
var poseEstimate = Pose2d(0.0, 0.0, 0.0)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.config.Config
//import com.acmerobotics.roadrunner.geometry.Pose2d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.config.Config
//import com.acmerobotics.roadrunner.geometry.Pose2d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.roadrunner.geometry.Pose2d
//import com.qualcomm.robotcore.eventloop.opmode.Disabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.telemetry.MultipleTelemetry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.dashboard.FtcDashboard
//import com.acmerobotics.dashboard.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning
//
//import com.acmerobotics.roadrunner.geometry.Pose2d
//import com.acmerobotics.roadrunner.geometry.Vector2d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/*
* This is a simple routine to test translational drive capabilities.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/*
* This is a simple routine to test translational drive capabilities.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/*
* This routine determines the effective track width. The procedure works by executing a point turn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/**
* This routine determines the effective forward offset for the lateral tracking wheel.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/**
* Opmode designed to assist the user in tuning the `StandardTrackingWheelLocalizer`'s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner
package org.firstinspires.ftc.teamcode.legacy.roadrunner.tuning

/*
* This is a simple routine to test turning capabilities.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner.utils.roadrunner.drive

//class AprilTagThreeWheelLocalizer(
// private val odometry: StandardTrackingWheelLocalizer,
//) : Localizer {
// private var _poseEstimate: Pose2d = Pose2d()
//
// override var poseEstimate: Pose2d
// get() = _poseEstimate
// set(value) {
// _poseEstimate = value
// }
//
// override val poseVelocity: Pose2d? = null
//
// override fun update() {
// // Return a kalman filter that takes the pose estimate from the odometry and april tags to combine
// odometry.update()
// TODO("Not yet implemented")
// }
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner.utils.roadrunner.drive

/*
* 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
//object DriveConstants {
// /*
// * These are motor constants that should be listed online for your motors.
// */
// 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.
// * Set this flag to false if drive encoders are not present and an alternative localization
// * method is in use (e.g., tracking wheels).
// *
// * If using the built-in motor velocity PID, update MOTOR_VELO_PID with the tuned coefficients
// * 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)
// )
//
// /*
// * These are physical constants that can be determined from your robot (including the track
// * width; it will be tune empirically later although a rough estimate is important). Users are
// * free to chose whichever linear distance unit they would like so long as it is consistently
// * used. The default values were selected with inches in mind. Road runner uses radians for
// * 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.
// */
// var WHEEL_RADIUS = 1.88976 // in`
// var GEAR_RATIO = 1.0 // output (wheel) speed / input (motor) speed
// @JvmField
// var TRACK_WIDTH = 13.94 // 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.
// */
// @JvmField
// var kV = 0.0144
// @JvmField
// var kA = 0.0015
// @JvmField
// var kStatic = 0.012
//
// /*
// * These values are used to generate the trajectories for you robot. To ensure proper operation,
// * the constraints should never exceed ~80% of the robot's actual capabilities. While Road
// * Runner is designed to enable faster autonomous motion, it is a good idea for testing to start
// * small and gradually increase them later after everything is working. All distance units are
// * inches.
// */
// /*
// * Note from LearnRoadRunner.com:
// * The velocity and acceleration constraints were calculated based on the following equation:
// * ((MAX_RPM / 60) * GEAR_RATIO * WHEEL_RADIUS * 2 * Math.PI) * 0.85
// * Resulting in 73.17330064499293 in/s.
// * This is only 85% of the theoretical maximum velocity of the bot, following the recommendation above.
// * This is capped at 85% because there are a number of variables that will preve nt your bot from actually
// * reaching this maximum velocity: voltage dropping over the game, bot weight, general mechanical inefficiencies, etc.
// * However, you can push this higher yourself if you'd like. Perhaps raise it to 90-95% of the theoretically
// * max velocity. The theoretically maximum velocity is 86.08623605293286 in/s.
// * Just make sure that your bot can actually reach this maximum velocity. Path following will be detrimentally
// * affected if it is aiming for a velocity not actually possible.
// *
// * The maximum acceleration is somewhat arbitrary and it is recommended that you tweak this yourself based on
// * actual testing. Just set it at a reasonable value and keep increasing until your path following starts
// * to degrade. As of now, it simply mirrors the velocity, resulting in 73.17330064499293 in/s/s
// *
// * Maximum Angular Velocity is calculated as: maximum velocity / trackWidth * (180 / Math.PI) but capped at 360°/s.
// * You are free to raise this on your own if you would like. It is best determined through experimentation.
//
// */
// @JvmField
// var MAX_VEL = 30.0
// @JvmField
// var MAX_ACCEL = 30.0
// @JvmField
// var MAX_ANG_VEL = Math.toRadians(170.0)
// @JvmField
// var MAX_ANG_ACCEL = Math.toRadians(170.0)
// fun encoderTicksToInches(ticks: Double): Double {
// return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV
// }
//
// fun rpmToVelocity(rpm: Double): Double {
// return rpm * GEAR_RATIO * 2 * Math.PI * WHEEL_RADIUS / 60.0
// }
//
// 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
@@ -0,0 +1,81 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner.utils.roadrunner.drive

/*
* Sample tracking wheel localizer implementation assuming the standard configuration:
*
* /--------------\
* | ____ |
* | ---- |
* | || || |
* | || || |
* | |
* | |
* \--------------/
*
*/
//@Config
//class StandardTrackingWheelLocalizer(hardwareMap: HardwareMap) : ThreeTrackingWheelLocalizer(
// listOf(
// Pose2d(0.0, LATERAL_DISTANCE / 2, 0.0), // left
// Pose2d(0.0, -LATERAL_DISTANCE / 2, 0.0), // right
// Pose2d(FORWARD_OFFSET, 0.0, Math.toRadians(90.0)) // front
// )
//) {
// private val leftEncoder: Encoder
// private val rightEncoder: Encoder
// private val strafeEncoder: Encoder
//
// init {
// leftEncoder = Encoder(
// hardwareMap.get(
// DcMotorEx::class.java, ControlBoard.ODO_LEFT_ENCODER.deviceName
// )
// )
//
//
// rightEncoder = Encoder(
// hardwareMap.get(
// DcMotorEx::class.java, ControlBoard.ODO_RIGHT_ENCODER.deviceName
// )
// )
// strafeEncoder = Encoder(
// hardwareMap.get(
// DcMotorEx::class.java, ControlBoard.ODO_STRAFE_ENCODER.deviceName
// )
// )
//// strafeEncoder.direction = Encoder.Direction.REVERSE
// }
//
// override fun getWheelPositions() = listOf(
// encoderTicksToInches(leftEncoder.currentPosition.toDouble()) * X_MULTIPLIER,
// encoderTicksToInches(rightEncoder.currentPosition.toDouble()) * X_MULTIPLIER,
// encoderTicksToInches(strafeEncoder.currentPosition.toDouble()) * Y_MULTIPLIER
// )
//
// override fun getWheelVelocities() = listOf(
// encoderTicksToInches(leftEncoder.correctedVelocity) * X_MULTIPLIER,
// encoderTicksToInches(rightEncoder.correctedVelocity) * X_MULTIPLIER,
// encoderTicksToInches(strafeEncoder.correctedVelocity) * Y_MULTIPLIER
// )
//
// companion object {
// val TICKS_PER_REV = 2000.0
// val WHEEL_RADIUS = 0.944882 // in
// val GEAR_RATIO = 1.0 // output (wheel) speed / input (encoder) speed
//
// @JvmField
// var LATERAL_DISTANCE = 15.45 // in; distance between the left and right wheels
//
// @JvmField
// var FORWARD_OFFSET = -2.1 // in; offset of the lateral wheel
//
// @JvmField
// var X_MULTIPLIER = 0.9944039016245 // Multiplier in the X direction
// @JvmField
// var Y_MULTIPLIER = 0.99960646480333// Multiplier in the Y direction
// fun encoderTicksToInches(ticks: Double): Double {
// return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.firstinspires.ftc.teamcode.legacy.roadrunner.utils.roadrunner.trajectorysequence

//class EmptySequenceException : RuntimeException()
Loading

0 comments on commit 26713f9

Please sign in to comment.