Skip to content

Commit 6423013

Browse files
authored
feat(step-generation): python commands for disengage and engage magnet (#17642)
closes AUTH-1103
1 parent 9fee69e commit 6423013

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

step-generation/src/__tests__/disengageMagnet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('disengageMagnet', () => {
1717
id: moduleId,
1818
type: MAGNETIC_MODULE_TYPE,
1919
model: MAGNETIC_MODULE_V1,
20-
pythonName: 'mockPythonName',
20+
pythonName: 'mock_magnetic_module_1',
2121
}
2222
robotState = getInitialRobotStateStandard(invariantContext)
2323
robotState.modules[moduleId] = {
@@ -46,6 +46,7 @@ describe('disengageMagnet', () => {
4646
},
4747
},
4848
],
49+
python: 'mock_magnetic_module_1.disengage()',
4950
})
5051
})
5152
})

step-generation/src/__tests__/engageMagnet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('engageMagnet', () => {
1717
id: moduleId,
1818
type: MAGNETIC_MODULE_TYPE,
1919
model: MAGNETIC_MODULE_V1,
20-
pythonName: 'mockPythonName',
20+
pythonName: 'mock_magnetic_module_1',
2121
}
2222
robotState = getInitialRobotStateStandard(invariantContext)
2323
robotState.modules[moduleId] = {
@@ -49,6 +49,7 @@ describe('engageMagnet', () => {
4949
},
5050
},
5151
],
52+
python: `mock_magnetic_module_1.engage(height_from_base=${height})`,
5253
})
5354
})
5455
})

step-generation/src/commandCreators/atomic/disengageMagnet.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const disengageMagnet: CommandCreator<ModuleOnlyParams> = (
1212
prevRobotState
1313
) => {
1414
const { moduleId } = args
15+
const { moduleEntities } = invariantContext
1516
const commandType = 'magneticModule/disengage'
1617

1718
if (moduleId === null) {
@@ -21,9 +22,12 @@ export const disengageMagnet: CommandCreator<ModuleOnlyParams> = (
2122
}
2223

2324
assert(
24-
invariantContext.moduleEntities[moduleId]?.type === MAGNETIC_MODULE_TYPE,
25-
`expected module ${moduleId} to be magdeck, got ${invariantContext.moduleEntities[moduleId]?.type}`
25+
moduleEntities[moduleId]?.type === MAGNETIC_MODULE_TYPE,
26+
`expected module ${moduleId} to be magdeck, got ${moduleEntities[moduleId]?.type}`
2627
)
28+
29+
const pythonName = moduleEntities[moduleId].pythonName
30+
2731
return {
2832
commands: [
2933
{
@@ -34,5 +38,6 @@ export const disengageMagnet: CommandCreator<ModuleOnlyParams> = (
3438
},
3539
},
3640
],
41+
python: `${pythonName}.disengage()`,
3742
}
3843
}

step-generation/src/commandCreators/atomic/engageMagnet.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const engageMagnet: CommandCreator<EngageMagnetParams> = (
1212
prevRobotState
1313
) => {
1414
const { moduleId, height } = args
15+
const { moduleEntities } = invariantContext
1516
const commandType = 'magneticModule/engage'
1617

1718
if (moduleId === null) {
@@ -21,9 +22,12 @@ export const engageMagnet: CommandCreator<EngageMagnetParams> = (
2122
}
2223

2324
assert(
24-
invariantContext.moduleEntities[moduleId]?.type === MAGNETIC_MODULE_TYPE,
25-
`expected module ${moduleId} to be magdeck, got ${invariantContext.moduleEntities[moduleId]?.type}`
25+
moduleEntities[moduleId]?.type === MAGNETIC_MODULE_TYPE,
26+
`expected module ${moduleId} to be magdeck, got ${moduleEntities[moduleId]?.type}`
2627
)
28+
29+
const pythonName = moduleEntities[moduleId].pythonName
30+
2731
return {
2832
commands: [
2933
{
@@ -35,5 +39,6 @@ export const engageMagnet: CommandCreator<EngageMagnetParams> = (
3539
},
3640
},
3741
],
42+
python: `${pythonName}.engage(height_from_base=${height})`,
3843
}
3944
}

0 commit comments

Comments
 (0)