Separate forbidden ground from body collision and retain capture phase
This commit is contained in:
@@ -9,7 +9,6 @@ physical simulation time. Acquisition timestamps and freshness stay on wall time
|
||||
|
||||
import math
|
||||
|
||||
|
||||
SCHEMA = "missioncore.simulation-scheduling/v1"
|
||||
|
||||
|
||||
@@ -67,3 +66,30 @@ def build_scheduling_policy(*, continuous, physics_dt, capture_hz, main_loop_hz,
|
||||
freshness_clock="monotonic-wall-time-with-original-capture-timestamps",
|
||||
step_obligations="retain-every-executed-pre-post-and-native-audit",
|
||||
)
|
||||
|
||||
|
||||
class CaptureCadence:
|
||||
"""Admit only the current rendered frame, retaining the requested phase.
|
||||
|
||||
Render jitter may skip deadlines but must not round the capture period up
|
||||
to an integer number of render frames. Missed slots are discarded; neither
|
||||
acquisition timestamps nor physics clocks are synthesized or advanced.
|
||||
"""
|
||||
|
||||
def __init__(self, hz, started_at):
|
||||
self.period = 1 / _positive(hz, "capture rate")
|
||||
self.next_at = float(started_at) + self.period
|
||||
if not math.isfinite(self.next_at):
|
||||
raise ValueError("Invalid capture start")
|
||||
|
||||
def due(self, captured_at):
|
||||
if not math.isfinite(captured_at):
|
||||
raise ValueError("Invalid capture timestamp")
|
||||
if captured_at < self.next_at:
|
||||
return False
|
||||
missed = math.floor((captured_at - self.next_at) / self.period)
|
||||
self.next_at += (missed + 1) * self.period
|
||||
# Retain a strict future deadline even at floating-point boundaries.
|
||||
if self.next_at <= captured_at:
|
||||
self.next_at += self.period
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user