Skip to content

Commit beee110

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dependabot/github_actions/actions/checkout-6
2 parents e013bb4 + 41f7883 commit beee110

66 files changed

Lines changed: 2789 additions & 1474 deletions

Some content is hidden

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

.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)