ftc-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +224 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +15 -0
- package/build/knowledge/dashboard.d.ts +8 -0
- package/build/knowledge/dashboard.js +843 -0
- package/build/knowledge/examples.d.ts +1 -0
- package/build/knowledge/examples.js +1800 -0
- package/build/knowledge/ftc-sdk.d.ts +8 -0
- package/build/knowledge/ftc-sdk.js +1088 -0
- package/build/knowledge/ftclib.d.ts +10 -0
- package/build/knowledge/ftclib.js +1403 -0
- package/build/knowledge/gradle.d.ts +8 -0
- package/build/knowledge/gradle.js +956 -0
- package/build/knowledge/hardware.d.ts +22 -0
- package/build/knowledge/hardware.js +1949 -0
- package/build/knowledge/panels.d.ts +10 -0
- package/build/knowledge/panels.js +572 -0
- package/build/knowledge/pedro.d.ts +8 -0
- package/build/knowledge/pedro.js +1548 -0
- package/build/knowledge/roadrunner.d.ts +3 -0
- package/build/knowledge/roadrunner.js +481 -0
- package/build/knowledge/vision.d.ts +12 -0
- package/build/knowledge/vision.js +1869 -0
- package/build/prompts/registry.d.ts +2 -0
- package/build/prompts/registry.js +634 -0
- package/build/resources/registry.d.ts +2 -0
- package/build/resources/registry.js +520 -0
- package/build/server.d.ts +2 -0
- package/build/server.js +17 -0
- package/build/tools/registry.d.ts +2 -0
- package/build/tools/registry.js +660 -0
- package/package.json +34 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPrompts = registerPrompts;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerPrompts(server) {
|
|
6
|
+
// ── 1. Setup FTC Project ──────────────────────────────────────────────
|
|
7
|
+
server.prompt("setup-ftc-project", "Guided FTC project setup: choose pathing library, dashboard, configure Gradle", {
|
|
8
|
+
pathingLibrary: zod_1.z.string().optional().describe("pedro, roadrunner, or custom"),
|
|
9
|
+
useDashboard: zod_1.z.string().optional().describe("yes or no"),
|
|
10
|
+
}, async (args) => {
|
|
11
|
+
const pathing = args.pathingLibrary ?? "not specified";
|
|
12
|
+
const dashboard = args.useDashboard ?? "not specified";
|
|
13
|
+
return {
|
|
14
|
+
messages: [
|
|
15
|
+
{
|
|
16
|
+
role: "user",
|
|
17
|
+
content: {
|
|
18
|
+
type: "text",
|
|
19
|
+
text: `Set up an FTC project with the following preferences:
|
|
20
|
+
- Pathing library: ${pathing}
|
|
21
|
+
- Use FTC Dashboard: ${dashboard}
|
|
22
|
+
|
|
23
|
+
Follow these steps IN ORDER:
|
|
24
|
+
|
|
25
|
+
1. Call the scan_ftc_project tool to understand the current project state (existing files, Gradle config, dependencies already present).
|
|
26
|
+
|
|
27
|
+
2. Read these resources for Gradle setup guidance:
|
|
28
|
+
- ftc://gradle/project-structure — understand the FTC Gradle layout
|
|
29
|
+
- ftc://gradle/adding-libraries — how to add repositories and dependencies
|
|
30
|
+
- ftc://gradle/all-library-coords — exact Maven/Jitpack repo URLs and dependency coordinates with versions
|
|
31
|
+
|
|
32
|
+
3. Edit build.dependencies.gradle (NOT build.gradle):
|
|
33
|
+
- Add required maven/jitpack repositories to the repositories { } block
|
|
34
|
+
- Add implementation lines for the chosen libraries to the dependencies { } block
|
|
35
|
+
- Use the EXACT coordinates and versions from ftc://gradle/all-library-coords
|
|
36
|
+
|
|
37
|
+
4. If adding Pedro Pathing: also edit build.common.gradle and change compileSdkVersion to 34 (Pedro requires API 34).
|
|
38
|
+
|
|
39
|
+
5. Set up bulk reading for performance:
|
|
40
|
+
- Read ftc://hardware/bulk-reads
|
|
41
|
+
- The base OpMode or hardware init should set all Lynx modules to BulkCachingMode.MANUAL and clear cache each loop iteration.
|
|
42
|
+
|
|
43
|
+
6. Create the TeamCode folder structure:
|
|
44
|
+
- TeamCode/src/main/java/org/firstinspires/ftc/teamcode/
|
|
45
|
+
- autonomous/
|
|
46
|
+
- teleop/
|
|
47
|
+
- subsystems/
|
|
48
|
+
- util/
|
|
49
|
+
|
|
50
|
+
7. If using Pedro Pathing, create an initial Constants.java file:
|
|
51
|
+
- Read ftc://pedro/constants-pattern for the correct pattern
|
|
52
|
+
- Place in the util/ folder
|
|
53
|
+
- Include starter poses and tuning values
|
|
54
|
+
|
|
55
|
+
8. Remind the user to perform a Gradle Sync in Android Studio after all file changes.
|
|
56
|
+
|
|
57
|
+
Important: Always use the exact library coordinates from the resources. Do not guess versions.`,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
// ── 2. Create Autonomous ──────────────────────────────────────────────
|
|
64
|
+
server.prompt("create-autonomous", "Create a complete FTC autonomous routine", {
|
|
65
|
+
pathingLibrary: zod_1.z.string().optional().describe("pedro or roadrunner"),
|
|
66
|
+
allianceColor: zod_1.z.string().optional().describe("red or blue"),
|
|
67
|
+
startPosition: zod_1.z.string().optional().describe("e.g., near-basket, near-observation"),
|
|
68
|
+
}, async (args) => {
|
|
69
|
+
const pathing = args.pathingLibrary ?? "pedro";
|
|
70
|
+
const color = args.allianceColor ?? "not specified";
|
|
71
|
+
const startPos = args.startPosition ?? "not specified";
|
|
72
|
+
return {
|
|
73
|
+
messages: [
|
|
74
|
+
{
|
|
75
|
+
role: "user",
|
|
76
|
+
content: {
|
|
77
|
+
type: "text",
|
|
78
|
+
text: `Create a complete FTC autonomous routine with:
|
|
79
|
+
- Pathing library: ${pathing}
|
|
80
|
+
- Alliance color: ${color}
|
|
81
|
+
- Start position: ${startPos}
|
|
82
|
+
|
|
83
|
+
Follow these steps:
|
|
84
|
+
|
|
85
|
+
1. Call scan_ftc_project to understand the current project — existing OpModes, subsystems, Constants file, hardware names.
|
|
86
|
+
|
|
87
|
+
2. Read the appropriate pathing resources:
|
|
88
|
+
${pathing === "roadrunner" ? ` - ftc://roadrunner/api-reference — Road Runner trajectory API` : ` - ftc://pedro/api-reference — Pedro Pathing follower and path building API
|
|
89
|
+
- ftc://pedro/auto-structure — correct autonomous OpMode structure for Pedro
|
|
90
|
+
- ftc://pedro/coordinate-system — Pedro's coordinate system (important for pose math)`}
|
|
91
|
+
|
|
92
|
+
3. Read dashboard resources for live tuning:
|
|
93
|
+
- ftc://dashboard/config-pattern — make ALL positions and tuning values @Config public static fields so they can be adjusted live from FTC Dashboard without redeploying
|
|
94
|
+
- ftc://dashboard/telemetry — use MultipleTelemetry to send telemetry to both Driver Station and Dashboard; add field overlay drawing of the robot path
|
|
95
|
+
|
|
96
|
+
4. Generate the autonomous OpMode:
|
|
97
|
+
- Use a finite state machine (FSM) pattern with an enum of states (e.g., DRIVE_TO_SPECIMEN, SCORE, PARK)
|
|
98
|
+
- All poses and positions must be @Config public static so they are dashboard-tunable
|
|
99
|
+
- Include path callbacks for triggering subsystem actions mid-path (read ftc://pedro/callbacks if using Pedro)
|
|
100
|
+
- Call follower.update() every loop iteration (Pedro) or update drive in loop (Road Runner)
|
|
101
|
+
- Add telemetry for current state, path progress, and loop time
|
|
102
|
+
- Add field overlay drawing of planned paths and robot position
|
|
103
|
+
|
|
104
|
+
5. Call validate_ftc_code on the generated code to check for common mistakes.
|
|
105
|
+
|
|
106
|
+
Important: The auto should be competition-ready with proper error handling, state timeouts, and clean structure.`,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
// ── 3. Create TeleOp ─────────────────────────────────────────────────
|
|
113
|
+
server.prompt("create-teleop", "Create a complete FTC TeleOp", {
|
|
114
|
+
driveType: zod_1.z.string().optional().describe("field-centric, robot-centric, or pedro"),
|
|
115
|
+
subsystems: zod_1.z.string().optional().describe("comma-separated list of subsystems, e.g., arm, claw, lift"),
|
|
116
|
+
}, async (args) => {
|
|
117
|
+
const drive = args.driveType ?? "field-centric";
|
|
118
|
+
const subsystems = args.subsystems ?? "not specified";
|
|
119
|
+
return {
|
|
120
|
+
messages: [
|
|
121
|
+
{
|
|
122
|
+
role: "user",
|
|
123
|
+
content: {
|
|
124
|
+
type: "text",
|
|
125
|
+
text: `Create a complete FTC TeleOp with:
|
|
126
|
+
- Drive type: ${drive}
|
|
127
|
+
- Subsystems: ${subsystems}
|
|
128
|
+
|
|
129
|
+
Follow these steps:
|
|
130
|
+
|
|
131
|
+
1. Call scan_ftc_project to find existing subsystems, hardware config names, and Constants files.
|
|
132
|
+
|
|
133
|
+
2. Read the relevant resources:
|
|
134
|
+
- ftc://sdk/gamepad-api — gamepad button/stick API and edge detection
|
|
135
|
+
- ftc://sdk/opmode-patterns — LinearOpMode vs OpMode patterns
|
|
136
|
+
- ftc://hardware/bulk-reads — set up bulk read caching (MANUAL mode, clear each loop)
|
|
137
|
+
- ftc://dashboard/telemetry — MultipleTelemetry for dual DS + Dashboard output
|
|
138
|
+
${drive === "pedro" ? ` - ftc://pedro/teleop-structure — Pedro TeleOp drive integration` : ` - ftc://hardware/motors/api — motor control for mecanum math`}
|
|
139
|
+
${drive === "field-centric" ? ` - ftc://hardware/sensors/imu — IMU heading for field-centric calculation` : ""}
|
|
140
|
+
|
|
141
|
+
3. Generate the TeleOp OpMode:
|
|
142
|
+
- Drive control:
|
|
143
|
+
- Mecanum drive with proper strafing math (left stick = translate, right stick X = rotate)
|
|
144
|
+
- ${drive === "field-centric" ? "Field-centric: rotate input vector by negative IMU heading" : drive === "pedro" ? "Use Pedro follower.setTeleOpMovementVectors()" : "Robot-centric: direct stick-to-motor mapping"}
|
|
145
|
+
- Slow mode toggle (e.g., left bumper held = 0.3x speed multiplier)
|
|
146
|
+
- Subsystem control:
|
|
147
|
+
- Map each subsystem to intuitive gamepad controls
|
|
148
|
+
- Use edge detection (gamepad1.a && !previousA) for toggles, continuous for held actions
|
|
149
|
+
- Document the full control mapping in a comment block at the top
|
|
150
|
+
- Performance:
|
|
151
|
+
- Bulk read caching in MANUAL mode with clearBulkCache() at the start of each loop
|
|
152
|
+
- Minimize object allocation in the loop
|
|
153
|
+
- Telemetry:
|
|
154
|
+
- Show drive power, heading, subsystem states, loop time
|
|
155
|
+
- Use MultipleTelemetry for Dashboard + Driver Station
|
|
156
|
+
|
|
157
|
+
4. Call validate_ftc_code on the generated code.`,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
// ── 4. Create Subsystem ───────────────────────────────────────────────
|
|
164
|
+
server.prompt("create-subsystem", "Create a hardware subsystem with dashboard tuning", {
|
|
165
|
+
subsystemType: zod_1.z.string().optional().describe("e.g., arm, claw, lift, intake"),
|
|
166
|
+
hardware: zod_1.z.string().optional().describe("e.g., motor + servo, two motors"),
|
|
167
|
+
}, async (args) => {
|
|
168
|
+
const type = args.subsystemType ?? "generic";
|
|
169
|
+
const hw = args.hardware ?? "not specified";
|
|
170
|
+
return {
|
|
171
|
+
messages: [
|
|
172
|
+
{
|
|
173
|
+
role: "user",
|
|
174
|
+
content: {
|
|
175
|
+
type: "text",
|
|
176
|
+
text: `Create an FTC subsystem class:
|
|
177
|
+
- Subsystem type: ${type}
|
|
178
|
+
- Hardware: ${hw}
|
|
179
|
+
|
|
180
|
+
Follow these steps:
|
|
181
|
+
|
|
182
|
+
1. Call scan_ftc_project to see existing subsystems and hardware configuration names.
|
|
183
|
+
|
|
184
|
+
2. Read the relevant resources:
|
|
185
|
+
- ftc://hardware/motors/api and ftc://hardware/servos/api — motor and servo control API
|
|
186
|
+
- ftc://hardware/motors/run-modes — RUN_TO_POSITION, RUN_USING_ENCODER, etc.
|
|
187
|
+
- ftc://dashboard/config-pattern — @Config annotation for live tuning
|
|
188
|
+
|
|
189
|
+
3. Generate the subsystem class:
|
|
190
|
+
- Hardware initialization:
|
|
191
|
+
- Accept HardwareMap in the constructor
|
|
192
|
+
- Get hardware devices by name from hardwareMap
|
|
193
|
+
- Set motor directions, zero power behaviors, and modes
|
|
194
|
+
- Dashboard-tunable constants:
|
|
195
|
+
- Use @Config on the class
|
|
196
|
+
- All position values, speeds, PID coefficients as public static fields
|
|
197
|
+
- Example: public static double ARM_UP_POSITION = 0.8;
|
|
198
|
+
- State methods:
|
|
199
|
+
- Named methods for each position/action (e.g., goToIntake(), goToScore(), open(), close())
|
|
200
|
+
- Return the subsystem instance for method chaining if appropriate
|
|
201
|
+
- Update method:
|
|
202
|
+
- An update() method called each loop that handles state transitions, PID control, etc.
|
|
203
|
+
- Telemetry:
|
|
204
|
+
- A method to add subsystem telemetry (current position, target, state, power)
|
|
205
|
+
- Accept Telemetry object and add data lines
|
|
206
|
+
|
|
207
|
+
4. Call validate_ftc_code on the generated code.
|
|
208
|
+
|
|
209
|
+
Important: The class should be self-contained, testable, and follow FTC best practices. Use @Config public static for ALL tunable values so they can be adjusted live via FTC Dashboard.`,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
// ── 5. Tune PID ───────────────────────────────────────────────────────
|
|
216
|
+
server.prompt("tune-pid", "Set up PID tuning with FTC Dashboard", {
|
|
217
|
+
controllerType: zod_1.z.string().optional().describe("e.g., drive, heading, arm, lift"),
|
|
218
|
+
}, async (args) => {
|
|
219
|
+
const controller = args.controllerType ?? "not specified";
|
|
220
|
+
return {
|
|
221
|
+
messages: [
|
|
222
|
+
{
|
|
223
|
+
role: "user",
|
|
224
|
+
content: {
|
|
225
|
+
type: "text",
|
|
226
|
+
text: `Set up PID tuning for: ${controller}
|
|
227
|
+
|
|
228
|
+
Follow these steps:
|
|
229
|
+
|
|
230
|
+
1. Call scan_ftc_project to find existing PID controllers and subsystem code.
|
|
231
|
+
|
|
232
|
+
2. Read the relevant resources:
|
|
233
|
+
- ftc://dashboard/config-pattern — expose PID coefficients as @Config public static
|
|
234
|
+
- ftc://dashboard/telemetry — graph target vs actual position in real time
|
|
235
|
+
- ftc://dashboard/api — FTC Dashboard API for sending graph packets
|
|
236
|
+
|
|
237
|
+
3. Set up PID tuning infrastructure:
|
|
238
|
+
- Expose coefficients as @Config public static fields:
|
|
239
|
+
- public static double kP = 0.0;
|
|
240
|
+
- public static double kD = 0.0;
|
|
241
|
+
- public static double kI = 0.0;
|
|
242
|
+
- public static double kF = 0.0; (feedforward for gravity compensation if arm/lift)
|
|
243
|
+
- IMPORTANT: Re-read the static fields every loop iteration since Dashboard modifies them live. If you copy them into a PIDFController object, you must call controller.setPIDF(kP, kI, kD, kF) each loop.
|
|
244
|
+
|
|
245
|
+
4. Add telemetry graphing:
|
|
246
|
+
- Send target position and actual position as separate telemetry keys every loop
|
|
247
|
+
- These will appear as overlaid graphs on FTC Dashboard
|
|
248
|
+
- Also send error (target - actual) and motor power
|
|
249
|
+
- Use TelemetryPacket for high-frequency graph data
|
|
250
|
+
|
|
251
|
+
5. Provide tuning methodology instructions:
|
|
252
|
+
- Step 1: Set kI = 0, kD = 0, kF = 0. Increase kP until the mechanism oscillates around the target.
|
|
253
|
+
- Step 2: Increase kD to dampen oscillation. The mechanism should reach the target without overshooting.
|
|
254
|
+
- Step 3: If there is steady-state error (mechanism stops just short of target), add a small kI. Keep kI as small as possible to avoid integral windup.
|
|
255
|
+
- Step 4: For arms and lifts that fight gravity, add kF as a constant feedforward term. For arms, kF should vary with cos(angle). For lifts, kF is constant.
|
|
256
|
+
- Remind: kI is rarely needed and often causes problems. Try increasing kP and kD first.
|
|
257
|
+
|
|
258
|
+
6. Call validate_ftc_code on the generated tuning code.`,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
// ── 6. Optimize Performance ───────────────────────────────────────────
|
|
265
|
+
server.prompt("optimize-performance", "Optimize FTC robot loop times", async () => {
|
|
266
|
+
return {
|
|
267
|
+
messages: [
|
|
268
|
+
{
|
|
269
|
+
role: "user",
|
|
270
|
+
content: {
|
|
271
|
+
type: "text",
|
|
272
|
+
text: `Optimize my FTC robot code for faster loop times.
|
|
273
|
+
|
|
274
|
+
Follow these steps:
|
|
275
|
+
|
|
276
|
+
1. Call scan_ftc_project to analyze the full project — all OpModes, subsystems, and hardware usage.
|
|
277
|
+
|
|
278
|
+
2. Read the performance resources:
|
|
279
|
+
- ftc://hardware/bulk-reads — understand REV Hub bulk read caching modes
|
|
280
|
+
- ftc://hardware/caching-hardware — CachingDcMotorEx, CachingServo to reduce redundant writes
|
|
281
|
+
- ftc://hardware/optimization-summary — overview of all optimization techniques
|
|
282
|
+
|
|
283
|
+
3. Apply optimizations (check each one):
|
|
284
|
+
a. Bulk reads:
|
|
285
|
+
- Switch ALL Lynx modules to BulkCachingMode.MANUAL
|
|
286
|
+
- Add clearBulkCache() at the very start of each loop iteration
|
|
287
|
+
- This batches all encoder/sensor reads into one USB transfer instead of individual calls
|
|
288
|
+
b. Caching hardware wrappers:
|
|
289
|
+
- Replace DcMotorEx with CachingDcMotorEx — only sends setPower() commands when the value actually changes
|
|
290
|
+
- Replace Servo with CachingServo — same write-deduplication for servos
|
|
291
|
+
- This eliminates redundant USB writes that waste loop time
|
|
292
|
+
c. Minimize I2C reads:
|
|
293
|
+
- I2C sensors (color, distance, IMU) are extremely slow (~7ms each per read)
|
|
294
|
+
- Only read I2C sensors when the value is actually needed
|
|
295
|
+
- Cache I2C values and only re-read every N loops if real-time data isn't critical
|
|
296
|
+
- Consider moving I2C reads to a separate thread if needed
|
|
297
|
+
d. Loop timer:
|
|
298
|
+
- Add a loop timer that measures and displays loop time via telemetry
|
|
299
|
+
- Target: < 20ms per loop (50Hz+), ideal: < 10ms (100Hz+)
|
|
300
|
+
- Track min/max/average loop times
|
|
301
|
+
|
|
302
|
+
4. Add before/after measurement:
|
|
303
|
+
- Add loop time telemetry BEFORE making changes so the user can see the improvement
|
|
304
|
+
- Typical unoptimized loop: 50-100ms
|
|
305
|
+
- Typical optimized loop: 5-15ms
|
|
306
|
+
|
|
307
|
+
5. Call validate_ftc_code on modified code.`,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
});
|
|
313
|
+
// ── 7. Add Dashboard Tuning ───────────────────────────────────────────
|
|
314
|
+
server.prompt("add-dashboard-tuning", "Add FTC Dashboard live-tunable variables to existing code", {
|
|
315
|
+
className: zod_1.z.string().optional().describe("class to add tuning to"),
|
|
316
|
+
variables: zod_1.z.string().optional().describe("comma-separated variable names to make tunable"),
|
|
317
|
+
}, async (args) => {
|
|
318
|
+
const cls = args.className ?? "not specified";
|
|
319
|
+
const vars = args.variables ?? "not specified";
|
|
320
|
+
return {
|
|
321
|
+
messages: [
|
|
322
|
+
{
|
|
323
|
+
role: "user",
|
|
324
|
+
content: {
|
|
325
|
+
type: "text",
|
|
326
|
+
text: `Add FTC Dashboard live-tunable variables to existing code:
|
|
327
|
+
- Class: ${cls}
|
|
328
|
+
- Variables to make tunable: ${vars}
|
|
329
|
+
|
|
330
|
+
Follow these steps:
|
|
331
|
+
|
|
332
|
+
1. Call scan_ftc_project to find the target class and understand the current code.
|
|
333
|
+
|
|
334
|
+
2. Read the dashboard resources:
|
|
335
|
+
- ftc://dashboard/config-pattern — the @Config annotation pattern and requirements
|
|
336
|
+
- ftc://dashboard/telemetry — MultipleTelemetry setup for dual output
|
|
337
|
+
- ftc://dashboard/api — Dashboard API details
|
|
338
|
+
|
|
339
|
+
3. Apply the @Config pattern:
|
|
340
|
+
- Add @Config annotation to the class declaration
|
|
341
|
+
- Convert the target variables to public static fields:
|
|
342
|
+
- They MUST be public and static for Dashboard to detect them
|
|
343
|
+
- Example: private double armSpeed = 0.5 → public static double armSpeed = 0.5
|
|
344
|
+
- For long and double types, consider marking them volatile if they may be read from multiple threads
|
|
345
|
+
- WARNING — Copy semantics: If you copy a @Config static into a local variable or object field, the local copy will NOT update when Dashboard changes the static. Always read from the static field directly each loop.
|
|
346
|
+
|
|
347
|
+
4. Set up MultipleTelemetry:
|
|
348
|
+
- Replace the standard telemetry object with MultipleTelemetry:
|
|
349
|
+
telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry());
|
|
350
|
+
- This sends telemetry to BOTH the Driver Station and the Dashboard simultaneously
|
|
351
|
+
- Must be done in init, not in the loop
|
|
352
|
+
|
|
353
|
+
5. Add telemetry output for the tunable variables:
|
|
354
|
+
- Display current values of all tunable variables each loop
|
|
355
|
+
- This helps verify that Dashboard changes are being applied correctly
|
|
356
|
+
|
|
357
|
+
6. Call validate_ftc_code on the modified code.
|
|
358
|
+
|
|
359
|
+
Important: Remind the user that Dashboard serves a web UI at http://192.168.43.1:8080/dash when connected to the robot WiFi. Variables appear under the Config tab organized by class name.`,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
// ── 8. Command-Based Project Setup ──────────────────────────────────
|
|
366
|
+
server.prompt("setup-command-based", "Set up a command-based FTC project using SolversLib with subsystems, commands, and gamepad bindings", {
|
|
367
|
+
pathingLibrary: zod_1.z.string().optional().describe("pedro or roadrunner"),
|
|
368
|
+
subsystems: zod_1.z.string().optional().describe("Comma-separated subsystem names, e.g., lift, claw, intake, arm"),
|
|
369
|
+
}, async (args) => {
|
|
370
|
+
const pathing = args.pathingLibrary ?? "pedro";
|
|
371
|
+
const subsystems = args.subsystems ?? "not specified";
|
|
372
|
+
return {
|
|
373
|
+
messages: [
|
|
374
|
+
{
|
|
375
|
+
role: "user",
|
|
376
|
+
content: {
|
|
377
|
+
type: "text",
|
|
378
|
+
text: `Set up a command-based FTC project using SolversLib:
|
|
379
|
+
- Pathing library: ${pathing}
|
|
380
|
+
- Subsystems: ${subsystems}
|
|
381
|
+
|
|
382
|
+
Follow these steps:
|
|
383
|
+
|
|
384
|
+
1. Call scan_ftc_project to analyze the current project state.
|
|
385
|
+
|
|
386
|
+
2. Read the command-base resources:
|
|
387
|
+
- ftc://command-base/setup — SolversLib vs FTCLib, Gradle installation, import mapping
|
|
388
|
+
- ftc://command-base/api — CommandOpMode, SubsystemBase, CommandBase, built-in command types, composition
|
|
389
|
+
- ftc://command-base/organization — recommended directory structure, Constants pattern, Robot container
|
|
390
|
+
- ftc://command-base/subsystems — PID-controlled subsystems, servo subsystems, voltage compensation, cross-subsystem dependencies
|
|
391
|
+
- ftc://command-base/commands — atomic, timed, instant, persistent, macro, conditional patterns
|
|
392
|
+
- ftc://command-base/triggers — GamepadEx, button bindings, trigger bindings, default commands
|
|
393
|
+
|
|
394
|
+
3. Set up Gradle for SolversLib:
|
|
395
|
+
- Read ftc://gradle/adding-libraries for the process
|
|
396
|
+
- Add \`maven { url = "https://repo.dairy.foundation/releases" }\` to repositories
|
|
397
|
+
- Add \`implementation "org.solverslib:core:0.3.4"\` to dependencies
|
|
398
|
+
- IMPORTANT: Do NOT also add FTCLib — they cannot coexist
|
|
399
|
+
${pathing === "pedro" ? ` - Also add Pedro Pathing dependencies and set compileSdk to 34
|
|
400
|
+
- Read ftc://command-base/pedro-integration for Pedro + command-base integration patterns` : ` - Also add Road Runner dependencies`}
|
|
401
|
+
|
|
402
|
+
4. Create the project structure:
|
|
403
|
+
- Constants/ — @Config classes for each subsystem's tunable values
|
|
404
|
+
- subsystems/ — SubsystemBase classes with PID in periodic()
|
|
405
|
+
- commands/custom/ — atomic commands (one per file)
|
|
406
|
+
- commands/group/ — composite SequentialCommandGroup/ParallelCommandGroup
|
|
407
|
+
- opmode/teleop/ — CommandOpMode TeleOp with button bindings
|
|
408
|
+
- opmode/auton/ — CommandOpMode autonomous with path following
|
|
409
|
+
- lib/ — Robot container class, utilities
|
|
410
|
+
|
|
411
|
+
5. Create the Robot container class:
|
|
412
|
+
- Constructs all subsystems
|
|
413
|
+
- Enables bulk reads (or use CommandScheduler.getInstance().setBulkCacheMode())
|
|
414
|
+
- Provides subsystem instances to OpModes
|
|
415
|
+
|
|
416
|
+
6. Create the subsystem classes:
|
|
417
|
+
- Each extends SubsystemBase
|
|
418
|
+
- PID control in periodic() — commands just set targets
|
|
419
|
+
- All tunable values as @Config public static
|
|
420
|
+
- register() in constructor
|
|
421
|
+
|
|
422
|
+
7. Create atomic commands:
|
|
423
|
+
- LiftToPositionCommand (set target, wait for convergence)
|
|
424
|
+
- DefaultDriveCommand (persistent, reads gamepad suppliers)
|
|
425
|
+
${pathing === "pedro" ? ` - FollowPathCommand (wraps Pedro follower.followPath)` : ` - RoadRunnerActionCommand (wraps Road Runner Action)`}
|
|
426
|
+
|
|
427
|
+
8. Create the TeleOp OpMode:
|
|
428
|
+
- Thin — just constructs Robot, binds buttons, sets default commands
|
|
429
|
+
- Use GamepadEx for enhanced gamepad with edge detection
|
|
430
|
+
- Bind operator buttons to commands using .whenPressed(), .whileHeld(), etc.
|
|
431
|
+
- Set drive default command
|
|
432
|
+
|
|
433
|
+
9. Create the Autonomous OpMode:
|
|
434
|
+
- Build paths in initialize()
|
|
435
|
+
- Schedule a single SequentialCommandGroup with all steps
|
|
436
|
+
- Use .alongWith() for parallel actions (drive while lifting)
|
|
437
|
+
- Use WaitCommand for servo settling times
|
|
438
|
+
|
|
439
|
+
10. Call validate_ftc_code on generated code.
|
|
440
|
+
|
|
441
|
+
Important: Use SolversLib imports (com.seattlesolvers.solverslib.*), NOT FTCLib imports. All @Config values read at point of use in periodic(), never cached.`,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
// ── 9. Build and Deploy ─────────────────────────────────────────────
|
|
448
|
+
server.prompt("build-and-deploy", "Set up build and deploy workflow for FTC — works with VS Code, Android Studio, IntelliJ, or command line", {
|
|
449
|
+
ide: zod_1.z.string().optional().describe("vscode, android-studio, intellij, or command-line"),
|
|
450
|
+
connection: zod_1.z.string().optional().describe("usb or wifi"),
|
|
451
|
+
}, async (args) => {
|
|
452
|
+
const ide = args.ide ?? "not specified";
|
|
453
|
+
const connection = args.connection ?? "not specified";
|
|
454
|
+
return {
|
|
455
|
+
messages: [
|
|
456
|
+
{
|
|
457
|
+
role: "user",
|
|
458
|
+
content: {
|
|
459
|
+
type: "text",
|
|
460
|
+
text: `Set up the build and deploy workflow for my FTC project:
|
|
461
|
+
- IDE: ${ide}
|
|
462
|
+
- Robot connection: ${connection}
|
|
463
|
+
|
|
464
|
+
Follow these steps:
|
|
465
|
+
|
|
466
|
+
1. Call scan_ftc_project to check the current project state and Gradle configuration.
|
|
467
|
+
|
|
468
|
+
2. Read the development environment resource:
|
|
469
|
+
- ftc://sdk/dev-environment — prerequisites (JDK 17, Android SDK, ANDROID_HOME), IDE-specific setup instructions for VS Code, Android Studio, and IntelliJ
|
|
470
|
+
|
|
471
|
+
3. Read the build and deploy resource:
|
|
472
|
+
- ftc://gradle/build-and-deploy — Gradle wrapper commands, ADB connection, wireless deploy, logcat debugging, troubleshooting
|
|
473
|
+
|
|
474
|
+
4. Set up the development environment:
|
|
475
|
+
${ide === "vscode" ? ` - Ensure VS Code extensions are installed: Extension Pack for Java (vscjava.vscode-java-pack), Gradle for Java (vscjava.vscode-gradle)
|
|
476
|
+
- Create .vscode/settings.json with JDK 17 path
|
|
477
|
+
- Create .vscode/tasks.json with FTC build/deploy tasks for Ctrl+Shift+B integration` : ide === "android-studio" ? ` - Verify Android Studio is using JDK 17 (NOT the bundled JDK 21 from Ladybug)
|
|
478
|
+
- Configure Gradle JDK: File → Settings → Build → Gradle → Gradle JDK → JDK 17
|
|
479
|
+
- Do NOT upgrade Gradle or AGP when prompted` : ide === "intellij" ? ` - Set Gradle JDK to JDK 17: File → Settings → Build → Gradle → Gradle JDK
|
|
480
|
+
- Import the project as a Gradle project` : ` - Verify JDK 17 is installed and JAVA_HOME is set
|
|
481
|
+
- Verify Android SDK is installed and ANDROID_HOME is set
|
|
482
|
+
- Verify adb is in PATH`}
|
|
483
|
+
|
|
484
|
+
5. Verify the build works:
|
|
485
|
+
- Run \`./gradlew assembleDebug\` and confirm it succeeds
|
|
486
|
+
- If it fails, check ftc://gradle/common-issues for troubleshooting
|
|
487
|
+
|
|
488
|
+
6. Set up robot connection:
|
|
489
|
+
${connection === "wifi" ? ` - Connect computer to Control Hub WiFi network
|
|
490
|
+
- Run \`adb connect 192.168.43.1:5555\`
|
|
491
|
+
- Verify with \`adb devices\`` : connection === "usb" ? ` - Connect USB cable from computer to Control Hub
|
|
492
|
+
- Verify with \`adb devices\`` : ` - Explain both USB and WiFi connection options
|
|
493
|
+
- USB: plug in and run \`adb devices\`
|
|
494
|
+
- WiFi: connect to robot WiFi, then \`adb connect 192.168.43.1:5555\``}
|
|
495
|
+
|
|
496
|
+
7. Deploy and test:
|
|
497
|
+
- Run \`./gradlew installDebug\` to build and deploy in one step
|
|
498
|
+
- Confirm the app restarts on the Control Hub
|
|
499
|
+
- Check the Driver Station for your OpModes
|
|
500
|
+
|
|
501
|
+
8. Set up debugging:
|
|
502
|
+
- Show how to use \`adb logcat\` to view runtime logs
|
|
503
|
+
- Explain how to add Log.d() statements in Java code
|
|
504
|
+
- Show filtered logcat: \`adb logcat -s MyTag:*\`
|
|
505
|
+
|
|
506
|
+
Important: The Gradle wrapper handles everything. Android Studio is optional — any editor works. JDK 17 is required (not 21).`,
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
],
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
// ── 10. Setup Vision ─────────────────────────────────────────────────
|
|
513
|
+
server.prompt("setup-vision", "Set up FTC vision — USB webcam with VisionPortal and/or Limelight 3A for AprilTag and color detection", {
|
|
514
|
+
visionSystem: zod_1.z.string().optional().describe("webcam, limelight, or both"),
|
|
515
|
+
detectionType: zod_1.z.string().optional().describe("apriltag, color, or both"),
|
|
516
|
+
}, async (args) => {
|
|
517
|
+
const system = args.visionSystem ?? "not specified";
|
|
518
|
+
const detection = args.detectionType ?? "not specified";
|
|
519
|
+
return {
|
|
520
|
+
messages: [
|
|
521
|
+
{
|
|
522
|
+
role: "user",
|
|
523
|
+
content: {
|
|
524
|
+
type: "text",
|
|
525
|
+
text: `Set up FTC vision for my robot:
|
|
526
|
+
- Vision system: ${system}
|
|
527
|
+
- Detection type: ${detection}
|
|
528
|
+
|
|
529
|
+
Follow these steps:
|
|
530
|
+
|
|
531
|
+
1. Call scan_ftc_project to check the current project state, existing vision code, and hardware names.
|
|
532
|
+
|
|
533
|
+
2. Read the vision overview to understand the options:
|
|
534
|
+
- ftc://vision/overview — USB webcam vs Limelight comparison, when to use each
|
|
535
|
+
|
|
536
|
+
3. Based on the chosen vision system, read the appropriate setup guides:
|
|
537
|
+
${system === "limelight" || system === "both" ? `
|
|
538
|
+
Limelight 3A:
|
|
539
|
+
- ftc://vision/limelight — complete Limelight 3A API, all pipeline types, result reading
|
|
540
|
+
- ftc://vision/megatag — MegaTag1/MegaTag2 robot localization from AprilTags
|
|
541
|
+
` : ""}${system === "webcam" || system === "both" || system === "not specified" ? `
|
|
542
|
+
USB Webcam + VisionPortal:
|
|
543
|
+
- ftc://vision/visionportal-setup — VisionPortal builder, lifecycle, streaming
|
|
544
|
+
- ftc://vision/camera-controls — exposure, gain, focus, white balance settings
|
|
545
|
+
` : ""}
|
|
546
|
+
4. Based on the detection type, read the detection guides:
|
|
547
|
+
${detection === "apriltag" || detection === "both" || detection === "not specified" ? `
|
|
548
|
+
AprilTag Detection:
|
|
549
|
+
- ftc://vision/apriltag-detection — AprilTagProcessor setup, decimation, pose reading, tag libraries
|
|
550
|
+
` : ""}${detection === "color" || detection === "both" ? `
|
|
551
|
+
Color Detection:
|
|
552
|
+
- ftc://vision/color-detection — custom VisionProcessor with OpenCV, HSV thresholding, contour analysis
|
|
553
|
+
` : ""}
|
|
554
|
+
5. Read the optimization guide:
|
|
555
|
+
- ftc://vision/optimization — resolution selection, decimation strategy, exposure for motion blur, processor toggling, stream format, ROI cropping, memory management
|
|
556
|
+
|
|
557
|
+
6. Read common vision patterns:
|
|
558
|
+
- ftc://vision/patterns — init-phase detection, drive-to-AprilTag alignment, field localization, vision + path following integration
|
|
559
|
+
|
|
560
|
+
7. Generate the vision code:
|
|
561
|
+
${system === "limelight" ? ` - Initialize Limelight3A from hardwareMap
|
|
562
|
+
- Set poll rate to 100Hz
|
|
563
|
+
- Select the appropriate pipeline
|
|
564
|
+
- Read results in the loop with staleness checking
|
|
565
|
+
- If using MegaTag2: integrate IMU heading via updateRobotOrientation()` : system === "webcam" || system === "not specified" ? ` - Build VisionPortal with appropriate processors
|
|
566
|
+
- Set camera resolution (640x480 recommended for balance of speed and range)
|
|
567
|
+
- Configure manual exposure (5-6ms) and gain (250) for AprilTag detection
|
|
568
|
+
- Set manual white balance for consistent color detection
|
|
569
|
+
- Implement dynamic decimation switching (1 for init, 3 for driving)
|
|
570
|
+
- Toggle processors when not needed to save CPU` : ` - Set up BOTH webcam VisionPortal AND Limelight
|
|
571
|
+
- Use Limelight for AprilTag localization (offloads CPU)
|
|
572
|
+
- Use webcam for custom color detection
|
|
573
|
+
- Both run simultaneously on separate USB ports`}
|
|
574
|
+
|
|
575
|
+
8. Add appropriate telemetry:
|
|
576
|
+
- Detection count, tag IDs, ranges, bearings
|
|
577
|
+
- FPS monitoring
|
|
578
|
+
- Pipeline latency (Limelight)
|
|
579
|
+
- Camera state
|
|
580
|
+
|
|
581
|
+
9. Call validate_ftc_code on the generated code.
|
|
582
|
+
|
|
583
|
+
Important: Set manual camera controls for competition consistency. Always have a fallback for when vision fails. Disable LiveView and unused processors in competition for maximum performance.`,
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
],
|
|
587
|
+
};
|
|
588
|
+
});
|
|
589
|
+
// ── 11. Setup Gradle ──────────────────────────────────────────────────
|
|
590
|
+
server.prompt("setup-gradle", "Configure Gradle dependencies for FTC libraries", {
|
|
591
|
+
libraries: zod_1.z.string().optional().describe("Comma-separated: pedro, dashboard, roadrunner, caching-hardware, ftclib"),
|
|
592
|
+
}, async (args) => {
|
|
593
|
+
const libs = args.libraries ?? "not specified";
|
|
594
|
+
return {
|
|
595
|
+
messages: [
|
|
596
|
+
{
|
|
597
|
+
role: "user",
|
|
598
|
+
content: {
|
|
599
|
+
type: "text",
|
|
600
|
+
text: `Configure Gradle dependencies for the following FTC libraries: ${libs}
|
|
601
|
+
|
|
602
|
+
Follow these steps:
|
|
603
|
+
|
|
604
|
+
1. Call scan_ftc_project to see the current Gradle configuration and what's already installed.
|
|
605
|
+
|
|
606
|
+
2. Read the Gradle resources:
|
|
607
|
+
- ftc://gradle/project-structure — understand which files to edit
|
|
608
|
+
- ftc://gradle/adding-libraries — step-by-step instructions for adding repos and deps
|
|
609
|
+
- ftc://gradle/all-library-coords — EXACT Maven/Jitpack repository URLs, group IDs, artifact IDs, and versions for ALL supported libraries
|
|
610
|
+
|
|
611
|
+
3. Edit build.dependencies.gradle:
|
|
612
|
+
- Add any required maven { url '...' } entries to the repositories { } block
|
|
613
|
+
- Add implementation 'group:artifact:version' lines to the dependencies { } block
|
|
614
|
+
- Use the EXACT coordinates from ftc://gradle/all-library-coords — do not guess or use outdated versions
|
|
615
|
+
- Do NOT duplicate repositories or dependencies that are already present
|
|
616
|
+
|
|
617
|
+
4. Handle special cases:
|
|
618
|
+
- Pedro Pathing requires compileSdkVersion 34: edit build.common.gradle and change compileSdkVersion to 34
|
|
619
|
+
- Pedro Pathing requires Java 8+: ensure sourceCompatibility and targetCompatibility are set (usually already correct in FTC projects)
|
|
620
|
+
|
|
621
|
+
5. Verify the configuration:
|
|
622
|
+
- Check that no conflicting versions exist
|
|
623
|
+
- Ensure repository URLs are correct (some libraries use jitpack.io, others use maven.google.com or custom Maven repos)
|
|
624
|
+
|
|
625
|
+
6. Remind the user to:
|
|
626
|
+
- Perform a Gradle Sync in Android Studio (File → Sync Project with Gradle Files or click the elephant icon)
|
|
627
|
+
- Check the Build output for any resolution errors
|
|
628
|
+
- If Gradle sync fails, read ftc://gradle/common-issues for troubleshooting`,
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
],
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
}
|