|
51 | 51 | # If you add a new schema element with a bound spec, either migrate its |
52 | 52 | # reader to ReadAttrTable (it will be auto-included) or add it here. |
53 | 53 | NOT_TABLE_DRIVEN = { |
54 | | - # actuator shorthands: read shared rows + per-tag remappings |
55 | | - 'motor', 'position', 'velocity', 'intvelocity', 'orientation', |
56 | | - 'pid', 'damper', 'cylinder', 'muscle', 'adhesion', 'dcmotor', |
| 54 | + # plugin actuator: shared rows + plugin config |
57 | 55 | 'actuator_plugin', |
58 | 56 | # equality subtypes: read shared equality_base + per-type refs |
59 | 57 | 'connect', 'weld', 'equality_joint', 'equality_tendon', |
|
65 | 63 | 'frame', 'plugin', 'numeric', 'text', 'tuple', |
66 | 64 | } |
67 | 65 |
|
| 66 | +# actuator tags whose mechanical rows are collected into kActuatorDispatch, |
| 67 | +# keyed by the actuatortype enum; shortcut parameters are reading=custom |
| 68 | +ACTUATOR_DISPATCH_ENUM = 'actuatortype' |
| 69 | + |
68 | 70 | # sensors whose whole branch derives from the schema (identity constants + |
69 | 71 | # references); their arrays are also collected into kSensorDispatch |
70 | 72 | SENSOR_DISPATCH = [ |
@@ -403,6 +405,17 @@ def generate(): |
403 | 405 | out.append('inline constexpr int kSensorDispatchN = ' |
404 | 406 | 'sizeof(kSensorDispatch) / sizeof(kSensorDispatch[0]);') |
405 | 407 | out.append('') |
| 408 | + out.append('// actuator tags and their mechanical rows: dispatch by tag or type') |
| 409 | + out.append('struct mjXActuatorEntry { const char* tag; int type;' |
| 410 | + ' const mjXAttr* rows; int n; };') |
| 411 | + out.append('inline constexpr mjXActuatorEntry kActuatorDispatch[] = {') |
| 412 | + for tag, const in schema.enums[ACTUATOR_DISPATCH_ENUM].items: |
| 413 | + array = array_name(tag) |
| 414 | + out.append(f' {{"{tag}", {const}, {array}, {array}N}},') |
| 415 | + out.append('};') |
| 416 | + out.append('inline constexpr int kActuatorDispatchN = ' |
| 417 | + 'sizeof(kActuatorDispatch) / sizeof(kActuatorDispatch[0]);') |
| 418 | + out.append('') |
406 | 419 | for gname, (struct, array) in EMIT_GROUPS.items(): |
407 | 420 | rows = rows_for_group(schema, structs, gname, struct) |
408 | 421 | out.append(f'// group {gname} ({struct})') |
|
0 commit comments