11package com.team4099.robot2026.config.constants
22
3+ import com.team4099.robot2026.subsystems.drivetrain.generated.AlphaBotTunerConstants
4+ import com.team4099.robot2026.subsystems.drivetrain.generated.CompBotTunerConstants
5+ import com.team4099.robot2026.subsystems.drivetrain.generated.TestBotTunerConstants
6+ import com.team4099.robot2026.subsystems.drivetrain.generated.TunerConstants
37import edu.wpi.first.wpilibj.RobotBase
48import kotlin.math.sqrt
59import org.team4099.lib.geometry.Pose2d
610import org.team4099.lib.units.Velocity
11+ import org.team4099.lib.units.base.Length
712import org.team4099.lib.units.base.Meter
813import org.team4099.lib.units.base.amps
914import org.team4099.lib.units.base.feet
1015import org.team4099.lib.units.base.inMeters
1116import org.team4099.lib.units.base.inches
1217import org.team4099.lib.units.base.meters
1318import org.team4099.lib.units.base.seconds
19+ import org.team4099.lib.units.derived.AccelerationFeedforward
1420import org.team4099.lib.units.derived.DerivativeGain
1521import org.team4099.lib.units.derived.IntegralGain
1622import org.team4099.lib.units.derived.ProportionalGain
23+ import org.team4099.lib.units.derived.Radian
24+ import org.team4099.lib.units.derived.VelocityFeedforward
25+ import org.team4099.lib.units.derived.Volt
1726import org.team4099.lib.units.derived.degrees
1827import org.team4099.lib.units.derived.metersPerSecondPerMetersPerSecond
1928import org.team4099.lib.units.derived.perDegreePerSecond
@@ -26,13 +35,42 @@ import org.team4099.lib.units.inMetersPerSecond
2635import org.team4099.lib.units.perSecond
2736
2837object DrivetrainConstants {
38+ val TunerConstants : TunerConstants =
39+ when (Constants .Universal .whoami) {
40+ Constants .WHOAMI .COMPBOT -> CompBotTunerConstants
41+ Constants .WHOAMI .ALPHABOT -> AlphaBotTunerConstants
42+ Constants .WHOAMI .TESTBOT -> TestBotTunerConstants
43+ }
44+
2945 const val TELEOP_TURNING_SPEED_PERCENT = 0.6
3046
31- val WHEEL_DIAMETER = (2 * 2 ).inches
32- val DRIVETRAIN_LENGTH = 28.5 .inches
33- val DRIVETRAIN_WIDTH = 28.5 .inches
47+ val WHEEL_DIAMETER : Length
48+ get() {
49+ return when (Constants .Universal .whoami) {
50+ else -> (2 * 2 ).inches
51+ }
52+ }
53+
54+ val DRIVETRAIN_LENGTH : Length
55+ get() {
56+ return when (Constants .Universal .whoami) {
57+ else -> 28.5 .inches
58+ }
59+ }
60+
61+ val DRIVETRAIN_WIDTH : Length
62+ get() {
63+ return when (Constants .Universal .whoami) {
64+ else -> 28.5 .inches
65+ }
66+ }
3467
35- val BUMPER_WIDTH = 3.25 .inches
68+ val BUMPER_WIDTH : Length
69+ get() {
70+ return when (Constants .Universal .whoami) {
71+ else -> 3.25 .inches
72+ }
73+ }
3674
3775 var DRIVE_SETPOINT_MAX = 16 .feet.perSecond
3876 val TURN_SETPOINT_MAX =
@@ -49,10 +87,6 @@ object DrivetrainConstants {
4987
5088 val OBJECT_APPROACH_SPEED = 2 .meters.perSecond
5189
52- const val MK4_DRIVE_SENSOR_GEAR_RATIO = (16.0 / 50.0 ) * (27.0 / 17.0 ) * (15.0 / 45.0 )
53- const val MK4I_STEERING_SENSOR_GEAR_RATIO = 7.0 / 150.0
54- const val MK4N_STEERING_SENSOR_GEAR_RATIO = 1.0 / 18.75
55-
5690 val STEERING_SUPPLY_CURRENT_LIMIT = 20.0 .amps
5791 val DRIVE_SUPPLY_CURRENT_LIMIT = 50.0 .amps
5892
@@ -143,15 +177,28 @@ object DrivetrainConstants {
143177 val STEERING_KP = 10.0 .volts / 45 .degrees
144178 val STEERING_KI = 0.0 .volts.perDegreeSeconds
145179 val STEERING_KD = 0.0 .volts.perDegreePerSecond
146- val STEERING_KV = 0.0 .volts / 1.0 .radians.perSecond
180+ val STEERING_KV : VelocityFeedforward <Radian , Volt > =
181+ when (Constants .Universal .whoami) {
182+ else -> 0.0 .volts / 1.0 .radians.perSecond
183+ }
147184
148185 val DRIVE_KP = 1.52 .volts / 1 .meters.perSecond
149186 val DRIVE_KI = 0.0 .volts / (1 .meters.perSecond * 1 .seconds)
150187 val DRIVE_KD = 0.1 .volts / 1 .meters.perSecond.perSecond
151188
152- val DRIVE_KS = 0.236 .volts
153- val DRIVE_KV = 2.117 .volts / 1.0 .meters.perSecond
154- val DRIVE_KA = 0.0 .volts / 1.0 .meters.perSecond.perSecond
189+ val DRIVE_KS =
190+ when (Constants .Universal .whoami) {
191+ else -> 0.236 .volts
192+ }
193+ val DRIVE_KV : VelocityFeedforward <Meter , Volt > =
194+ when (Constants .Universal .whoami) {
195+ else -> 2.117 .volts / 1.0 .meters.perSecond
196+ }
197+
198+ val DRIVE_KA : AccelerationFeedforward <Meter , Volt > =
199+ when (Constants .Universal .whoami) {
200+ else -> 0.0 .volts / 1.0 .meters.perSecond.perSecond
201+ }
155202
156203 val SIM_DRIVE_KP = DRIVE_KP
157204 val SIM_DRIVE_KI = DRIVE_KI
0 commit comments