Skip to content

Commit 41f7883

Browse files
MGross21milopetersnwazusBraedeng0Braeden Gracy
authored
Merge pull request #43 from Pioneer-Robotics/RedGoalAuto
Summary: Large refactor and functionality merge across vision, turret, spindexer, autos, hardware abstraction, and supporting utilities. Includes AprilTag pipeline cleanup, major Spindexer overhaul, turret tracking updates, auto restructuring, and numerous fixes discovered during hardware testing. Details: Vision / AprilTag: - Added AprilTagMeta; increased camera resolution; fixed camera setup. - Moved AprilTag back to vision package; updated processing integration. - Refactored AprilTagMeta interfaces and classes. - Refactored AprilTag class to avoid conflicting distance/angle units. - Added Apriltag metadata and conversion utilities. - Fixed quaternionToEuler typo; simplified variable usage. - Refactored GoalTag classes: - Merged Processing and Metadata classes. - Removed decode from naming. - Removed obelisk tags from navigation (replaced by obelisk/motif). - Cleaned names, types, formatting. - Added simple helper methods and placeholder shooting offset. - Added neutral-alliance motif tag identifiers. - Enhanced GoalTagProcessor with detection and validation via AprilTagDetection. - Refactored GoalTagProcessor logic, neutral-alliance support, method names. - Removed companion object; replaced with standard static declarations. - Converted GoalTagProcessor to singleton and fixed test usage. - Cleaned camera and AprilTag methods after merge. - Calculated relative X/Y distances to tags in field space (WIP). - Updated camera calibration files; removed unused scripts. Spindexer / Artifact Handling: - Started implementing spindexer hardware. - Simplified MotorPosition enum and added functionality. - Refactored Artifact class to enum-based design. - Refactored motif handling; removed nullable artifacts. - Refactored Spindexer artifact detection and intake logic: - Simplified moveToNextOpenIntake via takeIf. - Renamed getArtifact → detectArtifact. - Added currentSensor, scanArtifact, and improved modular logic. - Removed indexer helper. - Refactored Spindexer class for improved sensor integration and readability. - Added RevColorSensor; consolidated logic; added utility methods. - Unified movement state transitions using moveToNext and runMotorToState. - Refactored SpindexerTest accordingly; simplified onLoop logic. - Updated artifact storage to use internal copy for safety. - Fixed switchMode behavior regression. - Added Color Sensor Gain Calibration; separated motif logic from Spindexer. - Additional refactors for readability, consistency, and consolidation under Constants. - Implemented physical encoder support. - Improved motor control with angle wrapping, corrected ticks/radian math, PID updates, and RUN_WITHOUT_ENCODER. - Cleaner init pattern via apply. - Many cleanup passes to Spindexer and artifact methods; added rescanAllArtifacts. - Merged Spindexer into RedGoalAuto. - Switched Spindexer back to motor-based design for testing. Turret: - Added turret hardware and auto-tracking. - Refactored angle calculation: - Defined wrapping. - Renamed constants class. - Reduced duplication using Kotlin mapping utilities. - Moved auto-track to turret-scoped state machine for richer context. - Small tracking fix after refactor. - Flipped turret direction; added field-centric behavior. Flywheel: - Added launch-servo functionality; defined servo positions in Constants. - Added flywheel velocity estimator based on distance. - Added current draw property. - Set PID coefficients. Autos: - Added basic red-side goal-side auto (needs hardware). - Refactored RedGoalSideAuto using Points class; separated start/complete steps. - Added AutoOptions for partial autos. - Filled in Teleop methods; fixed issues. - Merged Spindexer into RedGoalAuto. - Added intake to auto. - Added camera to AudienceSideAuto. - Renamed goal-side auto. - Streamlined GoalSideAuto; removed unused states; fixed Points initialization. - Optimized initialization flow in AudienceSideAuto and GoalSideAuto. - Improved Launcher and AudienceSideAuto encapsulation; dynamic alliance color in RedGoalSideAuto. - Disabled various calibration/testing opmodes. - Added more teleop/auto work before tournament. - Various cleanup and formatting. Hardware / Bot Infrastructure: - Removed redundant name properties across components; replaced with simpleName getter. - Refactored HardwareComponent with default update(). - Added Bot.updateAll(dt) and updated BaseOpMode accordingly. - Cleaned MecanumBase, Flywheel, Intake, Turret initialization patterns. - Updated constants consolidation across codebase. - Added intake hardware and competition-bot framework. - Small hardware fixes; updated robot constants; ongoing hardware bring-up. Follower / Movement: - Implemented heading interpolation (still buggy; FIXME). - Cleaned state_shoot imports. - Refactored Follower.kt for null-safety and clarity. - Fixed follower to use calculateVelocityConstraint. - Added new method for relative distance calculation; fixed method 2. - Translation to field coordinates WIP. General Maintenance: - Added Points class. - Added Phone placeholder class. - Cleaned various utilities. - Removed unused imports, redundant methods. - Fixed build issues (override annotations, motor visibility, missing gain access). - Style cleanup via ktlint. - Updated .gitattributes to ignore FTC SDK generated files. Co-authored-by: milopeters <[email protected]> Co-authored-by: nwazus <[email protected]> Co-authored-by: Braeden Gracy <[email protected]> Co-authored-by: Braeden Gracy <[email protected]> Co-authored-by: braedeng2008 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2 parents 46609fd + 4a54fb3 commit 41f7883

Some content is hidden

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

69 files changed

+2842
-1515
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.kt diff=kotlin
22
*.java diff=java
3+
FtcRobotController/* linguist-generated=true # Ignore files generated by the FTC SDK in the codebase stats

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
bin/
1818
gen/
1919
out/
20+
*.salive
2021
# Uncomment the following line in case you need and you don't have the release build type files in your app
2122
# release/
2223

FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorColor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
* Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
6969
* Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
7070
*/
71-
@TeleOp(name = "Sensor: Color", group = "Sensor")
7271
@Disabled
72+
@TeleOp(name = "Sensor: Color", group = "Sensor")
7373
public class SensorColor extends LinearOpMode {
7474

7575
/** The colorSensor field will contain a reference to our color sensor hardware object */
@@ -121,7 +121,7 @@ protected void runSample() {
121121
// colors will report at or near 1, and you won't be able to determine what color you are
122122
// actually looking at. For this reason, it's better to err on the side of a lower gain
123123
// (but always greater than or equal to 1).
124-
float gain = 2;
124+
float gain = 100;
125125

126126
// Once per loop, we will update this hsvValues array. The first element (0) will contain the
127127
// hue, the second element (1) will contain the saturation, and the third element (2) will
@@ -137,7 +137,7 @@ protected void runSample() {
137137
// Get a reference to our sensor object. It's recommended to use NormalizedColorSensor over
138138
// ColorSensor, because NormalizedColorSensor consistently gives values between 0 and 1, while
139139
// the values you get from ColorSensor are dependent on the specific sensor you're using.
140-
colorSensor = hardwareMap.get(NormalizedColorSensor.class, "sensor_color");
140+
colorSensor = hardwareMap.get(NormalizedColorSensor.class, "intakeSensor");
141141

142142
// If possible, turn the light on in the beginning (it might already be on anyway,
143143
// we just make sure it is if we can).
@@ -157,9 +157,9 @@ protected void runSample() {
157157
// Update the gain value if either of the A or B gamepad buttons is being held
158158
if (gamepad1.a) {
159159
// Only increase the gain by a small amount, since this loop will occur multiple times per second.
160-
gain += 0.005;
160+
gain += 0.5;
161161
} else if (gamepad1.b && gain > 1) { // A gain of less than 1 will make the values smaller, which is not helpful.
162-
gain -= 0.005;
162+
gain -= 0.5;
163163
}
164164

165165
// Show the gain value via telemetry
@@ -196,9 +196,9 @@ protected void runSample() {
196196
Color.colorToHSV(colors.toColor(), hsvValues);
197197

198198
telemetry.addLine()
199-
.addData("Red", "%.3f", colors.red)
200-
.addData("Green", "%.3f", colors.green)
201-
.addData("Blue", "%.3f", colors.blue);
199+
.addData("Red", "%.3f", colors.red * 255)
200+
.addData("Green", "%.3f", colors.green * 255)
201+
.addData("Blue", "%.3f", colors.blue * 255);
202202
telemetry.addLine()
203203
.addData("Hue", "%.3f", hsvValues[0])
204204
.addData("Saturation", "%.3f", hsvValues[1])

TeamCode/src/main/kotlin/pioneer/Bot.kt

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package pioneer
22

33
import com.qualcomm.robotcore.hardware.HardwareMap
4+
import pioneer.general.AllianceColor
45
import pioneer.hardware.BatteryMonitor
56
import pioneer.hardware.Camera
67
import pioneer.hardware.Flywheel
78
import pioneer.hardware.HardwareComponent
9+
import pioneer.hardware.Intake
810
import pioneer.hardware.LaunchServos
11+
import pioneer.hardware.Launcher
912
import pioneer.hardware.MecanumBase
13+
import pioneer.hardware.Spindexer
14+
import pioneer.hardware.Turret
1015
import pioneer.localization.localizers.Pinpoint
1116
import pioneer.pathing.follower.Follower
17+
import pioneer.vision.AprilTag
1218

1319
enum class BotType {
1420
MECANUM_BOT,
1521
GOBILDA_STARTER_BOT,
22+
COMP_BOT,
1623
CUSTOM,
1724
}
1825

@@ -30,23 +37,35 @@ class Bot private constructor(
3037
hardwareComponents.values.forEach { it.init() }
3138
}
3239

40+
var allianceColor = AllianceColor.RED
41+
3342
// Property-style access for known components
3443
val mecanumBase get() = get<MecanumBase>()
3544
val pinpoint get() = get<Pinpoint>()
3645
val launchServos get() = get<LaunchServos>()
3746
val flywheel get() = get<Flywheel>()
47+
val turret get() = get<Turret>()
48+
val intake get() = get<Intake>()
3849
val camera get() = get<Camera>()
3950
val batteryMonitor get() = get<BatteryMonitor>()
51+
val spindexer get() = get<Spindexer>()
52+
val launcher get() = get<Launcher>()
4053

4154
// Follower is lazily initialized (only if accessed)
4255
// and will error if localizer or mecanumBase is missing
4356
val follower: Follower by lazy {
4457
Follower(
45-
localizer = get<Pinpoint>()!!,
46-
mecanumBase = get<MecanumBase>()!!,
58+
localizer = pinpoint!!,
59+
mecanumBase = mecanumBase!!,
4760
)
4861
}
4962

63+
fun updateAll(dt: Double) {
64+
hardwareComponents.values.forEach { it.update() }
65+
pinpoint?.update(dt)
66+
// TODO: Add other update methods (ie. localizer, follower)
67+
}
68+
5069
// Companion for builder and fromType
5170
companion object {
5271
fun builder() = Builder()
@@ -68,7 +87,19 @@ class Bot private constructor(
6887
.add(Pinpoint(hardwareMap))
6988
.add(LaunchServos(hardwareMap))
7089
.add(Flywheel(hardwareMap))
71-
.add(Camera(hardwareMap, processors = arrayOf(Camera.createAprilTagProcessor())))
90+
.add(Camera(hardwareMap, processors = arrayOf(AprilTag().processor)))
91+
.add(BatteryMonitor(hardwareMap))
92+
.build()
93+
BotType.COMP_BOT ->
94+
builder()
95+
.add(MecanumBase(hardwareMap))
96+
.add(Pinpoint(hardwareMap))
97+
.add(Flywheel(hardwareMap))
98+
.add(Intake(hardwareMap))
99+
.add(Turret(hardwareMap))
100+
.add(Spindexer(hardwareMap))
101+
.add(Launcher(hardwareMap))
102+
.add(Camera(hardwareMap, processors = arrayOf(AprilTag().processor)))
72103
.add(BatteryMonitor(hardwareMap))
73104
.build()
74105
BotType.CUSTOM -> throw IllegalArgumentException("Use Bot.builder() to create a custom bot")

0 commit comments

Comments
 (0)