fix: enforce Local G2 total window length

This commit is contained in:
梁薄云
2026-07-31 15:47:33 +08:00
parent c623c9b529
commit 1ac3dbda8d
3 changed files with 236 additions and 33 deletions
@@ -93,4 +93,37 @@ Assert-True (-not [string]::IsNullOrWhiteSpace([string]$overflowArguments[4])) `
'Rejected overflow detection must provide a stable reason.'
Assert-Equal 0 $overflowArguments[3].Count 'Rejected overflow detection must not publish a curvature event.'
$plannerType = Get-RequiredType 'MultiWheelC.TrajectoryPlanning.PathSmoothing.LocalG2.LocalG2WindowPlanner'
$plannerHooksType = $plannerType.GetNestedType('TestHooks', [Reflection.BindingFlags]'Public,NonPublic')
Assert-True ($null -ne $plannerHooksType) 'LocalG2WindowPlanner must expose narrow deterministic TestHooks.'
$planScenario = $plannerHooksType.GetMethod('Execute', [Reflection.BindingFlags]'Public,Static')
$separated = $planScenario.Invoke($null, @('SeparatedByOneMeter'))
Assert-Equal 2 $separated.RegionCount 'Events 1.0 m apart cannot share a 0.80 m total window.'
Assert-Equal '1,1' $separated.TransitionCounts 'Separated events must remain one event per region.'
$mergeable = $planScenario.Invoke($null, @('Mergeable'))
Assert-Equal 1 $mergeable.RegionCount 'Events covered by one legal total window must merge.'
Assert-Equal '2' $mergeable.TransitionCounts 'The merged region must retain both events.'
$partition = $planScenario.Invoke($null, @('ThreeEventPartition'))
Assert-Equal 2 $partition.RegionCount 'Three events must split at the first infeasible joint window.'
Assert-Equal '2,1' $partition.TransitionCounts 'Only a feasible consecutive subgroup may merge.'
$boundary = $planScenario.Invoke($null, @('NearBoundary'))
Assert-True ($boundary.FirstRightLength -gt $boundary.FirstLeftLength) `
'A boundary-clamped total window must transfer missing length to the available side.'
Assert-True ($boundary.MaximumWindowLength -le 0.80 + 1e-9) `
'No candidate window may exceed 0.80 m total length.'
foreach ($snapshot in @($separated, $mergeable, $partition, $boundary)) {
Assert-True $snapshot.ExactEnvelope 'Region envelope must equal the extrema of actual legal variants.'
Assert-True ($snapshot.MaximumWindowLength -le 0.80 + 1e-9) `
'MaximumWindowLengthMeters is a total, not a per-side length.'
}
$repeat = $planScenario.Invoke($null, @('ThreeEventPartition'))
Assert-Equal $partition.Signature $repeat.Signature `
'Repeated planning must preserve grouping, candidate numbering and variant order.'
Write-Output 'Path smoothing Local G2 detection checks passed.'