Skip to content

❤️ (VCS/VTC) Safe max() Wrappers to ensure max not calling on None value of the deque #20

@OppaAI

Description

@OppaAI

⚠️ Issue: Unguarded Statistical Aggregation (Empty Sequence / Type Errors)

The VTC and Regulator modules rely on max() to find the "worst-case" values in the Pump's deques. Without proper filtering and defaults, these calls trigger fatal exceptions when encountering None values or empty deques during initialization or sensor dropouts.

🎯 Location:

robot/vtc -> display_tick()
Any logic performing peak-detection on glob_bin

🦠 Symptoms:

  • ValueError: max() arg is an empty sequence during the first few milliseconds of startup.
  • TypeError: '>' not supported between instances of 'NoneType' and 'float' when a sensor fails to return a value.
  • Total node failure (crash) instead of graceful degradation.

🩺 Diagnosis:

  • Python's built-in max() is not "null-aware." In a high-frequency telemetry system like the VCS, None represents a "missing sample," not a zero. Passing a sequence containing None or an empty list to max() results in an unhandled exception that halts the entire thread.

💡 Proposal:

The "Resilient Peak" Wrapper
Implement a standardized, generator-based filtering pattern for all peak-detection logic. This ensures that the system always returns a safe numerical default even if the "glob" is corrupted or empty.

  • None-Filtering: Use a generator expression to strip None values before aggregation.
  • Safe Defaults: Always utilize the default keyword argument in max() to provide a neutral fallback (e.g., 0.0).
  • Type Consistency: Ensure the output is cast to a float to maintain compatibility with the VitalPulse message definition.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions