Skip to content

Commit 5aab3eb

Browse files
authored
Merge branch 'master' into Hopper
2 parents c36d913 + c0b2fbc commit 5aab3eb

42 files changed

Lines changed: 2873 additions & 393 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,53 @@ task(eventDeploy) {
226226
}
227227
}
228228
createVersionFile.dependsOn(eventDeploy)
229+
230+
def argSpec = [
231+
robot: [
232+
allowed: ["compbot", "alphabot", "testbot"],
233+
required: true
234+
],
235+
tuning: [
236+
allowed: ["true", "t", "false", "f"],
237+
required: true,
238+
],
239+
]
240+
241+
tasks.register("validateArgs") {
242+
doFirst {
243+
argSpec.each { key, spec ->
244+
def value = project.findProperty(key) ?: spec.default
245+
246+
if (value == null && spec.required) {
247+
throw new GradleException("Missing required argument: -P$key. Allowed: ${spec.allowed}")
248+
}
249+
250+
if (spec.allowed && !spec.allowed.contains(value.toLowerCase())) {
251+
throw new GradleException(
252+
"Invalid -P$key=$value. Allowed: ${spec.allowed}"
253+
)
254+
}
255+
256+
if (spec.pattern && !(value ==~ spec.pattern)) {
257+
throw new GradleException(
258+
"Invalid -P$key=$value. Must match ${spec.pattern}"
259+
)
260+
}
261+
}
262+
}
263+
}
264+
265+
["simulateJava", "deploy"].each { taskName ->
266+
tasks.named(taskName).configure {
267+
dependsOn validateArgs
268+
}
269+
}
270+
271+
tasks.withType(JavaExec).configureEach {
272+
argSpec.keySet().each { key ->
273+
def value = project.findProperty(key) ?: argSpec[key].default
274+
if (value != null) {
275+
systemProperty key.toLowerCase(), value
276+
}
277+
}
278+
}

src/main/kotlin/com/team4099/lib/phoenix6/PhoenixUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@ object PhoenixUtil {
172172
}
173173
}
174174

175-
private typealias ConfiguredSwerveModuleConstants =
175+
typealias ConfiguredSwerveModuleConstants =
176176
SwerveModuleConstants<TalonFXConfiguration?, TalonFXConfiguration?, CANcoderConfiguration?>

src/main/kotlin/com/team4099/robot2026/RobotContainer.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.team4099.robot2026.util.driver.Jessika
2121
import edu.wpi.first.wpilibj.RobotBase
2222
import org.ironmaple.simulation.SimulatedArena
2323
import org.ironmaple.simulation.drivesims.SwerveDriveSimulation
24+
import org.ironmaple.simulation.seasonspecific.rebuilt2026.Arena2026Rebuilt
2425
import org.littletonrobotics.junction.Logger
2526
import org.team4099.lib.geometry.Pose2d
2627
import org.team4099.lib.geometry.Pose3d
@@ -37,6 +38,8 @@ object RobotContainer {
3738
var driveSimulation: SwerveDriveSimulation? = null
3839

3940
init {
41+
SimulatedArena.overrideInstance(Arena2026Rebuilt(false))
42+
4043
if (Constants.Universal.DISABLE_COLLISIONS)
4144
SimulatedArena.overrideInstance(FieldConstants.EMPTY_MAPLESIM_FIELD)
4245

@@ -47,7 +50,6 @@ object RobotContainer {
4750
ModuleIOTalonFXReal.generateModules(),
4851
{ edu.wpi.first.math.geometry.Pose2d.kZero },
4952
{ pose -> {} })
50-
5153
vision =
5254
Vision(
5355
CameraIOPhotonvision(

src/main/kotlin/com/team4099/robot2026/config/constants/Constants.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.team4099.robot2026.config.constants
22

3+
import com.team4099.robot2026.util.ArgParser.argToBool
4+
import com.team4099.robot2026.util.ArgParser.argToEnum
35
import org.team4099.lib.units.base.grams
46
import org.team4099.lib.units.base.meters
57
import org.team4099.lib.units.base.pounds
@@ -10,6 +12,7 @@ import org.team4099.lib.units.milli
1012
import org.team4099.lib.units.perSecond
1113

1214
object Constants {
15+
1316
object Universal {
1417
val gravity = 9.81.meters.perSecond.perSecond
1518
val SIM_MODE = Tuning.SimType.SIM
@@ -26,14 +29,22 @@ object Constants {
2629
val POWER_DISTRIBUTION_HUB_ID = 1
2730

2831
const val SIMULATE_VISION = false
29-
const val DISABLE_COLLISIONS = true
32+
const val DISABLE_COLLISIONS = false
3033

3134
val ROBOT_WEIGHT = 135.pounds
3235
val ROBOT_MOI = 6.76.kilo.grams.meterSquared
36+
37+
val whoami = argToEnum<WHOAMI>(System.getProperty("robot"))
38+
}
39+
40+
enum class WHOAMI {
41+
COMPBOT,
42+
ALPHABOT,
43+
TESTBOT
3344
}
3445

3546
object Tuning {
36-
const val TUNING_MODE = false
47+
val TUNING_MODE = argToBool(System.getProperty("tuning"))
3748
const val DEBUGING_MODE = false
3849

3950
enum class SimType {
@@ -57,5 +68,17 @@ object Constants {
5768

5869
object Hopper {
5970
const val HOPPER_MOTOR_ID = -1337
71+
object Feeder {
72+
const val FEEDER_MOTOR_ID = 61
73+
}
74+
75+
object Intake {
76+
const val INTAKE_ROLLERS_MOTOR_ID = -1337
77+
const val INTAKE_PIVOT_MOTOR_ID = -1337
78+
}
79+
80+
object Shooter {
81+
const val LEADER_MOTOR_ID = 42
82+
const val FOLLOWER_MOTOR_ID = 43
6083
}
6184
}

src/main/kotlin/com/team4099/robot2026/config/constants/DrivetrainConstants.kt

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
package 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
37
import edu.wpi.first.wpilibj.RobotBase
48
import kotlin.math.sqrt
59
import org.team4099.lib.geometry.Pose2d
610
import org.team4099.lib.units.Velocity
11+
import org.team4099.lib.units.base.Length
712
import org.team4099.lib.units.base.Meter
813
import org.team4099.lib.units.base.amps
914
import org.team4099.lib.units.base.feet
1015
import org.team4099.lib.units.base.inMeters
1116
import org.team4099.lib.units.base.inches
1217
import org.team4099.lib.units.base.meters
1318
import org.team4099.lib.units.base.seconds
19+
import org.team4099.lib.units.derived.AccelerationFeedforward
1420
import org.team4099.lib.units.derived.DerivativeGain
1521
import org.team4099.lib.units.derived.IntegralGain
1622
import 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
1726
import org.team4099.lib.units.derived.degrees
1827
import org.team4099.lib.units.derived.metersPerSecondPerMetersPerSecond
1928
import org.team4099.lib.units.derived.perDegreePerSecond
@@ -26,13 +35,42 @@ import org.team4099.lib.units.inMetersPerSecond
2635
import org.team4099.lib.units.perSecond
2736

2837
object 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
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.team4099.robot2026.config.constants
2+
3+
import org.team4099.lib.units.base.amps
4+
import org.team4099.lib.units.base.grams
5+
import org.team4099.lib.units.derived.meterSquared
6+
import org.team4099.lib.units.derived.volts
7+
8+
object FeederConstants {
9+
val STATOR_CURRENT_LIMIT = 40.0.amps
10+
val SUPPLY_CURRENT_LIMIT = 40.0.amps
11+
val GEAR_RATIO = 12.0 / 24.0
12+
val VOLTAGE_COMPENSATION = 12.0.volts
13+
val IDLE_VOLTAGE = 0.0.volts
14+
// TODO: Change this value later
15+
val MOMENT_OF_INERTIA = 0.35.grams.meterSquared
16+
}

src/main/kotlin/com/team4099/robot2026/config/constants/GyroConstants.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ package com.team4099.robot2026.config.constants
33
import org.team4099.lib.units.derived.degrees
44

55
object GyroConstants {
6-
val mountPitch = 180.0.degrees
7-
val mountRoll = 0.0.degrees
8-
val mountYaw = -90.0.degrees
6+
val mountPitch =
7+
when (Constants.Universal.whoami) {
8+
else -> 180.0.degrees
9+
}
10+
val mountRoll =
11+
when (Constants.Universal.whoami) {
12+
else -> 0.0.degrees
13+
}
14+
val mountYaw =
15+
when (Constants.Universal.whoami) {
16+
else -> -90.0.degrees
17+
}
918
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.team4099.robot2025.config.constants
2+
3+
import org.team4099.lib.units.base.amps
4+
import org.team4099.lib.units.base.grams
5+
import org.team4099.lib.units.base.inches
6+
import org.team4099.lib.units.base.seconds
7+
import org.team4099.lib.units.derived.DerivativeGain
8+
import org.team4099.lib.units.derived.IntegralGain
9+
import org.team4099.lib.units.derived.ProportionalGain
10+
import org.team4099.lib.units.derived.Radian
11+
import org.team4099.lib.units.derived.Volt
12+
import org.team4099.lib.units.derived.degrees
13+
import org.team4099.lib.units.derived.meterSquared
14+
import org.team4099.lib.units.derived.radians
15+
import org.team4099.lib.units.derived.volts
16+
import org.team4099.lib.units.perSecond
17+
18+
object IntakeConstants {
19+
val ZERO_OFFSET = ANGLES.STOW_ANGLE
20+
val GEAR_RATIO = 0.0 / 1.0
21+
22+
val INTAKE_TOLERANCE = 1.0.degrees
23+
24+
val PIVOT_INERTIA = 0.0.grams.meterSquared
25+
val PIVOT_LENGTH = 0.0.inches
26+
val PIVOT_MAX_ANGLE = 120.0.degrees
27+
val PIVOT_MIN_ANGLE = 0.0.degrees
28+
29+
val STATOR_CURRENT_LIMIT = 30.amps
30+
val SUPPLY_CURRENT_LIMIT = 30.amps
31+
32+
val VOLTAGE_COMPENSATION = 12.0.volts
33+
34+
val MAX_VELOCITY = 125.degrees.perSecond
35+
val MAX_ACCELERATION = 125.degrees.perSecond.perSecond
36+
37+
val SIM_VELOCITY = 400.degrees.perSecond
38+
val SIM_ACCELERATION = 400.degrees.perSecond.perSecond
39+
40+
val LENGTH_EXTENDED = 0.0.inches
41+
42+
object ANGLES {
43+
val INTAKE_ANGLE = 0.0.degrees
44+
val STOW_ANGLE = 0.0.degrees
45+
}
46+
47+
object PID {
48+
// PID Constants
49+
val SIM_PIVOT_KP: ProportionalGain<Radian, Volt> = 0.0.volts / 1.0.degrees
50+
val SIM_PIVOT_KI: IntegralGain<Radian, Volt> = 0.0.volts / (1.0.degrees * 1.0.seconds)
51+
val SIM_PIVOT_KD: DerivativeGain<Radian, Volt> = 0.0.volts / 1.0.degrees.perSecond
52+
53+
val REAL_PIVOT_KP: ProportionalGain<Radian, Volt> = 0.0.volts / 1.0.degrees
54+
val REAL_PIVOT_KI: IntegralGain<Radian, Volt> = 0.0.volts / (1.0.degrees * 1.0.seconds)
55+
val REAL_PIVOT_KD: DerivativeGain<Radian, Volt> = 0.0.volts / 1.0.degrees.perSecond
56+
57+
val PIVOT_KA = 0.0.volts / 1.0.radians.perSecond.perSecond
58+
val PIVOT_KV = 0.0.volts / 1.0.radians.perSecond
59+
val PIVOT_KG = 0.0.volts
60+
val PIVOT_KS = 0.0.volts
61+
62+
val SIM_PIVOT_KA = 0.0.volts / 1.0.radians.perSecond.perSecond
63+
val SIM_PIVOT_KV = 0.0.volts / 1.0.radians.perSecond
64+
val SIM_PIVOT_KG = 0.0.volts
65+
val SIM_PIVOT_KS = 0.0.volts
66+
}
67+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.team4099.robot2025.config.constants
2+
3+
import org.team4099.lib.units.base.amps
4+
import org.team4099.lib.units.base.grams
5+
import org.team4099.lib.units.derived.meterSquared
6+
import org.team4099.lib.units.derived.volts
7+
import org.team4099.lib.units.kilo
8+
9+
object RollersConstants {
10+
val GEAR_RATIO = 1.0 / 1.0
11+
val VOLTAGE_COMPENSATION = 12.volts
12+
13+
val IDLE_VOLTAGE = 0.0.volts
14+
val EJECT_VOLTAGE = (-3.0).volts
15+
val INTAKE_VOLTAGE = 6.0.volts
16+
17+
val MOMENT_OF_INERTIA = 0.0.kilo.grams.meterSquared // TODO: Change
18+
19+
val SUPPLY_CURRENT_LIMIT = 40.0.amps
20+
val STATOR_CURRENT_LIMIT = 40.0.amps
21+
}

0 commit comments

Comments
 (0)