|
9 | 9 | Wire format uses msgpack arrays with integer type codes: |
10 | 10 | - OK: MsgType.OK (just the integer) |
11 | 11 | - ERROR: [MsgType.ERROR, message] |
12 | | -- STATUS: [MsgType.STATUS, pose, angles, speeds, io, action_current, action_state, joint_en, cart_en_wrf, cart_en_trf, executing_index, completed_index, last_checkpoint, error, queued_segments, queued_duration, action_params, tool_status, tcp_speed, simulator_active, collision_active, collision_pairs, scene_epoch, accepted_index, homed] |
| 12 | +- STATUS: [MsgType.STATUS, pose, angles, speeds, io, action_current, action_state, joint_en, cart_en_wrf, cart_en_trf, executing_index, completed_index, last_checkpoint, error, queued_segments, queued_duration, action_params, tool_status, tcp_speed, simulator_active, collision_active, collision_pairs, scene_epoch, accepted_index, homed, enabled, homing_step, joints_homed, loop_health] |
13 | 13 | - RESPONSE: [MsgType.RESPONSE, query_type, value] |
14 | 14 | - COMMAND: [CmdType.XXX, ...params] |
15 | 15 | """ |
@@ -1362,6 +1362,8 @@ def pack_status( |
1362 | 1362 | enabled: bool = True, |
1363 | 1363 | homing_step: int = 0, |
1364 | 1364 | joints_homed: Sequence[int] = _NO_JOINTS_HOMED, |
| 1365 | + p99_period_s: float = 0.0, |
| 1366 | + overruns: int = 0, |
1365 | 1367 | ) -> bytes: |
1366 | 1368 | """Pack a status broadcast message. |
1367 | 1369 |
|
@@ -1409,6 +1411,7 @@ def pack_status( |
1409 | 1411 | enabled, |
1410 | 1412 | homing_step, |
1411 | 1413 | joints_homed, |
| 1414 | + (p99_period_s, overruns), |
1412 | 1415 | ), |
1413 | 1416 | option=ormsgpack.OPT_SERIALIZE_NUMPY, |
1414 | 1417 | ) |
@@ -1467,6 +1470,15 @@ class StatusBuffer: |
1467 | 1470 | ) |
1468 | 1471 | warnings: list[tuple] = field(default_factory=list) |
1469 | 1472 | link_health: dict = field(default_factory=dict) |
| 1473 | + # The drives report per-joint error FLAGS over the serial link, not |
| 1474 | + # analog temperature or current registers, so there is nothing to put |
| 1475 | + # here: empty is what tells a consumer "no such sensor" rather than |
| 1476 | + # "all zero". Flags surface as faults, not as a trend. |
| 1477 | + drive_health: dict = field(default_factory=dict) |
| 1478 | + # The control loop's own health: p99_period_s and overruns. Empty from |
| 1479 | + # producers that predate the field, which is how a consumer tells |
| 1480 | + # "loop healthy" from "loop not reported". |
| 1481 | + loop_health: dict = field(default_factory=dict) |
1470 | 1482 | # Firmware referencing progress in waldoctl's shape: active, sequence_step, |
1471 | 1483 | # and one (HomingJointState, HomingPhase) pair per joint; empty while idle. |
1472 | 1484 | homing: dict = field(default_factory=dict) |
@@ -1535,6 +1547,8 @@ def copy(self) -> "StatusBuffer": |
1535 | 1547 | torques_ext=self.torques_ext.copy(), |
1536 | 1548 | warnings=list(self.warnings), |
1537 | 1549 | link_health=dict(self.link_health), |
| 1550 | + drive_health=dict(self.drive_health), |
| 1551 | + loop_health=dict(self.loop_health), |
1538 | 1552 | homing=dict(self.homing), |
1539 | 1553 | ) |
1540 | 1554 |
|
@@ -1581,7 +1595,8 @@ def decode_status_bin_into(data: bytes, buf: StatusBuffer) -> bool: |
1581 | 1595 | error, queued_segments, queued_duration, action_params, |
1582 | 1596 | tool_status_tuple, tcp_speed, simulator_active, |
1583 | 1597 | collision_active, collision_pairs, scene_epoch, |
1584 | | - accepted_index, homed, enabled, homing_step, joints_homed] |
| 1598 | + accepted_index, homed, enabled, homing_step, joints_homed, |
| 1599 | + loop_health] |
1585 | 1600 |
|
1586 | 1601 | Args: |
1587 | 1602 | data: Raw msgpack bytes |
@@ -1656,6 +1671,12 @@ def decode_status_bin_into(data: bytes, buf: StatusBuffer) -> bool: |
1656 | 1671 | buf.enabled = bool(msg[25]) if len(msg) > 25 else True |
1657 | 1672 | if len(msg) > 27: |
1658 | 1673 | _apply_homing_progress(buf, int(msg[26]), msg[27]) |
| 1674 | + if len(msg) > 28: |
| 1675 | + lh = msg[28] |
| 1676 | + buf.loop_health = { |
| 1677 | + "p99_period_s": float(lh[0]), |
| 1678 | + "overruns": int(lh[1]), |
| 1679 | + } |
1659 | 1680 |
|
1660 | 1681 | return True |
1661 | 1682 | except Exception as e: |
|
0 commit comments