Skip to content

Commit ee42a7c

Browse files
Fixed motor-controller filtering
1 parent 1e7c7c4 commit ee42a7c

4 files changed

Lines changed: 23 additions & 31 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ This project is configured for easy deployment to GitHub Pages:
8787

8888
For more detailed information, see the documentation in the `/docs` directory:
8989

90-
- [Architecture Overview](docs/architecture.md)
91-
- [Code Generation Process](docs/code-generation.md)
92-
- [Simulation System](docs/simulation.md)
90+
- [Hardware Configuration Guide](docs/hardware-configuration.md)
9391
- [Simulation Development Guide](docs/simulation-development.md)
9492
- [User Guide](docs/user-guide.md)
9593
- [Deployment Guide](docs/deployment.md)

components/mechanism-form.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
MOTOR_CONTROLLERS,
1616
MOTORS,
1717
getCompatibleMotors,
18-
getCompatibleControllers,
1918
} from "@/lib/config/hardware-config"
2019

2120
export default function MechanismForm({ form }: { form: UseFormReturn<any> }) {
@@ -31,7 +30,6 @@ export default function MechanismForm({ form }: { form: UseFormReturn<any> }) {
3130
const allMotors = Object.values(MOTORS)
3231

3332
// Get compatible controllers and motors based on current selections
34-
const compatibleControllers = getCompatibleControllers(motorType)
3533
const compatibleMotors = getCompatibleMotors(motorControllerType)
3634

3735
// Handle motor controller change
@@ -44,16 +42,6 @@ export default function MechanismForm({ form }: { form: UseFormReturn<any> }) {
4442
}
4543
}
4644

47-
// Handle motor type change
48-
const handleMotorTypeChange = (value: string) => {
49-
form.setValue("motorType", value)
50-
51-
// If changing to a Kraken motor and not using TalonFX, switch to TalonFX
52-
if ((value === "Krakenx44" || value === "Krakenx60") && motorControllerType !== "TalonFX") {
53-
form.setValue("motorControllerType", "TalonFX")
54-
}
55-
}
56-
5745
// Safe number input handler
5846
const handleNumberChange = (e: React.ChangeEvent<HTMLInputElement>, onChange: (...event: any[]) => void) => {
5947
const value = e.target.value
@@ -132,7 +120,7 @@ export default function MechanismForm({ form }: { form: UseFormReturn<any> }) {
132120
</SelectTrigger>
133121
</FormControl>
134122
<SelectContent>
135-
{compatibleControllers.map((controller) => (
123+
{allControllers.map((controller) => (
136124
<SelectItem key={controller.name} value={controller.name}>
137125
{controller.displayName}
138126
</SelectItem>
@@ -150,7 +138,7 @@ export default function MechanismForm({ form }: { form: UseFormReturn<any> }) {
150138
render={({ field }) => (
151139
<FormItem>
152140
<FormLabel>Motor Type</FormLabel>
153-
<Select onValueChange={handleMotorTypeChange} value={field.value}>
141+
<Select value={field.value}>
154142
<FormControl>
155143
<SelectTrigger>
156144
<SelectValue placeholder="Select motor type" />

lib/config/hardware-config.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ export const MOTOR_CONTROLLERS: Record<string, MotorControllerDefinition> = {
136136
},
137137
TalonFXS: {
138138
name: "TalonFXS",
139-
displayName: "TalonFX (Phoenix 5)",
139+
displayName: "TalonFX (Phoenix 6)",
140140
supportsCurrentLimit: true,
141141
supportsSupplyCurrentLimit: true,
142142
supportsBrakeMode: true,
143143
supportsRampRate: true,
144144
supportsSoftLimits: true,
145145
importPath: "com.ctre.phoenix.motorcontrol.can.TalonFXS",
146-
description: "CTRE TalonFX Motor Controller (Phoenix 5)",
146+
description: "CTRE TalonFX Motor Controller (Phoenix 6)",
147147
maxCurrentLimit: 100,
148148
maxVoltage: 12,
149149
},
@@ -249,14 +249,6 @@ export function getCompatibleMotors(controllerName: string): MotorDefinition[] {
249249
return Object.values(MOTORS).filter((motor) => motor.compatibleControllers.includes(controllerName))
250250
}
251251

252-
/**
253-
* Get all controllers compatible with a specific motor
254-
*/
255-
export function getCompatibleControllers(motorName: string): MotorControllerDefinition[] {
256-
const motor = getMotor(motorName)
257-
return Object.values(MOTOR_CONTROLLERS).filter((controller) => motor.compatibleControllers.includes(controller.name))
258-
}
259-
260252
/**
261253
* Get the WPILib DCMotor type string for a given motor
262254
*/

tsconfig.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"compilerOptions": {
3-
"lib": ["dom", "dom.iterable", "esnext"],
3+
"lib": [
4+
"dom",
5+
"dom.iterable",
6+
"esnext"
7+
],
48
"allowJs": true,
59
"target": "ES6",
610
"skipLibCheck": true,
@@ -19,9 +23,19 @@
1923
}
2024
],
2125
"paths": {
22-
"@/*": ["./*"]
26+
"@/*": [
27+
"./*"
28+
]
2329
}
2430
},
25-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26-
"exclude": ["node_modules"]
31+
"include": [
32+
"**/*.ts",
33+
"**/*.tsx",
34+
".next/types/**/*.ts",
35+
"next-env.d.ts",
36+
"out/types/**/*.ts"
37+
],
38+
"exclude": [
39+
"node_modules"
40+
]
2741
}

0 commit comments

Comments
 (0)