Skip to content

❤️ (VCS/VTC) Implement Threading Lock #17

@OppaAI

Description

@OppaAI

⚠️ Issue: Non-Deterministic Temporal Reference & Thread Contention

The system currently suffers from Temporal Alias where logic relies on the host's system clock (import time) rather than the ROS 2 abstraction layer. Additionally, as we scale to a MultiThreadedExecutor, the shared glob_bin is vulnerable to race conditions without explicit synchronization.

🎯 Location:

/robot/vtc/pump.py

🦠 Symptoms:

  • time.time() ignores ROS 2 SimTime, causing consistent "Pulse Brightness" even when simulation is paused or running at 0.5x speed.
  • Potential RuntimeError or data corruption when the Pump writes to a deque while the Display or Regulator is performing a max() calculation.
  • Inconsistent timestamps during rosbag playback.

🩺 Diagnosis:

  • Temporal Disconnect: The use of the System Wall Clock (import time) bypasses the ROS 2 clock middleware.
  • Race Conditions: Using a MultiThreadedExecutor means the display_tick and pump_cycle run on separate threads. Simultaneous access to the glob_bin dictionary is non-thread-safe in Python's high-frequency loops.

💡 Proposal:

  • Synchronized Critical Sections: Implement threading.Lock (a Mutex) to wrap all read/write operations on the glob_bin.
  • ROS 2 Clock Integration: Replace all time.time() calls with self.get_clock().now() to ensure logic adheres to the use_sim_time parameter.
  • Hardware Discovery Probe: Use the INIT state to validate all YAML conduit paths before starting the high-frequency harvest.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions