fix(ground-ai): escalate repeated contacts with vehicles and wrecks
A bot pressed against the same wreck or stopped vehicle backed off, planned the same path again and drove into it once more, every few seconds for minutes, because a contact reset the stuck watch and left no trace for path searches. A second contact within pathFollow.contactRepeatSec near the same place now marks the body for path searches and switches the passing side; after unstickMaxAttempts repeats the bot gives its order up and the place is avoided like any other unreachable spot. NAV_CONTACT logs the repeat count and the body position.
This commit is contained in:
1 parent
413bd55c54
commit
58fde2030c
11 files changed
+61
-13
No files matched your search
@@ -736,6 +736,7 @@
|
||||
"blockTtlSec": "Blocked passage cost duration",
|
||||
"contactGapM": "Gap to an obstacle that counts as contact",
|
||||
"contactReverseSec": "Time in contact before backing off",
|
||||
"contactRepeatSec": "Window in which a second contact counts as a repeat",
|
||||
"stuckWindowSec": "Stuck detection window",
|
||||
"stuckMinProgressM": "Min progress within the stuck window",
|
||||
"unstickReverseM": "Unstick reverse distance",
|
||||
|
||||
@@ -736,6 +736,7 @@
|
||||
"blockTtlSec": "被堵路段代价持续时间",
|
||||
"contactGapM": "离障碍多近算作顶上",
|
||||
"contactReverseSec": "顶上多久后倒车",
|
||||
"contactRepeatSec": "多久内在同一处再顶上算作反复顶上",
|
||||
"stuckWindowSec": "卡住检测窗口时长",
|
||||
"stuckMinProgressM": "检测窗口内的最小前进距离",
|
||||
"unstickReverseM": "脱困倒车距离",
|
||||
|
||||
@@ -318,6 +318,7 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
num('pathFollow', 'blockTtlSec', 3, 120, 's'),
|
||||
num('pathFollow', 'contactGapM', 0.2, 3, 'm'),
|
||||
num('pathFollow', 'contactReverseSec', 0.3, 5, 's'),
|
||||
num('pathFollow', 'contactRepeatSec', 3, 120, 's'),
|
||||
num('pathFollow', 'stuckWindowSec', 1, 15, 's'),
|
||||
num('pathFollow', 'stuckMinProgressM', 0.2, 10, 'm'),
|
||||
num('pathFollow', 'unstickReverseM', 2, 25, 'm'),
|
||||
|
||||
@@ -148,6 +148,7 @@ const GroundAiPathFollowSchema = z.object({
|
||||
blockTtlSec: z.number().min(3).max(120),
|
||||
contactGapM: z.number().min(0.2).max(3),
|
||||
contactReverseSec: z.number().min(0.3).max(5),
|
||||
contactRepeatSec: z.number().min(3).max(120),
|
||||
stuckWindowSec: z.number().min(1).max(15),
|
||||
stuckMinProgressM: z.number().min(0.2).max(10),
|
||||
unstickReverseM: z.number().min(2).max(25),
|
||||
|
||||
@@ -246,6 +246,7 @@ function readPathFollowSection(pf: TuningReader): GroundAiPathFollow {
|
||||
blockTtlSec: n('blockTtlSec', 3, 120),
|
||||
contactGapM: n('contactGapM', 0.2, 3),
|
||||
contactReverseSec: n('contactReverseSec', 0.3, 5),
|
||||
contactRepeatSec: n('contactRepeatSec', 3, 120),
|
||||
stuckWindowSec: n('stuckWindowSec', 1, 15),
|
||||
stuckMinProgressM: n('stuckMinProgressM', 0.2, 10),
|
||||
unstickReverseM: n('unstickReverseM', 2, 25),
|
||||
|
||||
@@ -226,10 +226,13 @@
|
||||
"passSpeedMps": 4.0,
|
||||
// No side free: stop short, and after blockWaitSec mark the obstacle for path searches for
|
||||
// blockTtlSec and plan again. A hull within contactGapM of it for contactReverseSec backs off.
|
||||
// Pressed again within contactRepeatSec near the same place: mark the obstacle, try the other
|
||||
// side, and after unstickMaxAttempts such repeats give the order up.
|
||||
"blockWaitSec": 2.0,
|
||||
"blockTtlSec": 15.0,
|
||||
"contactGapM": 0.8,
|
||||
"contactReverseSec": 1.0,
|
||||
"contactRepeatSec": 20.0,
|
||||
// Less progress than stuckMinProgressM within stuckWindowSec while wanting to move is stuck.
|
||||
"stuckWindowSec": 3.0,
|
||||
"stuckMinProgressM": 0.8,
|
||||
|
||||
@@ -157,7 +157,7 @@ def private wto_nav_follow(var world : WtoWorldSnap&; navState : int; now : floa
|
||||
let narrow = slot.nav.wallDistM < WTO_AI_PF_NARROW_WALL_M || slot.nav.chokepoint
|
||||
wto_traffic_update(world, navState, now, myPos, pathDir, speedNow, narrow, slot)
|
||||
if wto_traffic_in_contact(now, slot.nav)
|
||||
wto_unstick_contact(navState, now, myPos, hullFwd, slot)
|
||||
wto_unstick_contact(world, navState, now, myPos, hullFwd, slot)
|
||||
if !wto_unstick_reversing(now, myPos, slot)
|
||||
wto_nav_halt(myPos, hullFwd, slot)
|
||||
return
|
||||
|
||||
@@ -56,6 +56,11 @@ struct public WtoNavState
|
||||
avoidSpeedCap : float = 99.0
|
||||
blockedSince : float = -100.0
|
||||
contactSince : float = -100.0
|
||||
contactBodyPos : float3 = float3(0.0, 0.0, 0.0)
|
||||
contactBodyRadiusM : float = 0.0
|
||||
lastContactAt : float = -100.0
|
||||
lastContactPos : float3 = float3(0.0, 0.0, 0.0)
|
||||
contactRepeats : int = 0
|
||||
stuckOrigin : float3 = float3(0.0, 0.0, 0.0)
|
||||
stuckCheckAt : float = -100.0
|
||||
unstickAnchor : float3 = float3(0.0, 0.0, 0.0)
|
||||
|
||||
@@ -196,13 +196,18 @@ def private wto_traffic_yield(now : float; var nav : WtoNavState&)
|
||||
nav.yieldCooldownUntil = nav.yieldUntil + WTO_AI_PF_YIELD_WAIT_SEC
|
||||
nav.avoidSpeedCap = min(nav.avoidSpeedCap, now < nav.yieldUntil ? 0.0 : WTO_AI_PF_PASS_SPEED_MPS)
|
||||
|
||||
// Hull pressed against a standing body: when that started (cleared once there is room again).
|
||||
// Hull pressed against a standing body: when that started (cleared once there is room again),
|
||||
// and where the body is and how much room passing it takes, for marking it on repeats.
|
||||
[never_inline]
|
||||
def private wto_traffic_contact(now, gap, speedMps : float; var nav : WtoNavState&)
|
||||
if gap >= WTO_AI_PF_CONTACT_GAP_M || speedMps >= WTO_AI_PF_STATIONARY_MPS
|
||||
def private wto_traffic_contact(now, speedMps : float; body : WtoTrafficBody const&; var slot : WtoBotSlot&)
|
||||
assume nav = slot.nav
|
||||
if wto_traffic_gap(body, slot.spec) >= WTO_AI_PF_CONTACT_GAP_M || speedMps >= WTO_AI_PF_STATIONARY_MPS
|
||||
nav.contactSince = -100.0
|
||||
elif nav.contactSince < -50.0
|
||||
return
|
||||
if nav.contactSince < -50.0
|
||||
nav.contactSince = now
|
||||
nav.contactBodyPos = body.pos
|
||||
nav.contactBodyRadiusM = wto_traffic_need(body, slot.spec)
|
||||
|
||||
// True after contactReverseSec pressed against a vehicle or wreck: the caller backs off at once.
|
||||
[never_inline]
|
||||
@@ -222,7 +227,7 @@ def public wto_traffic_update(world : WtoWorldSnap const&; navState : int; now :
|
||||
var standing = WtoTrafficBody()
|
||||
let lookM = max(WTO_AI_PF_BUMPER_RAY_M, speedMps * WTO_AI_PF_TRAFFIC_TTC_SEC)
|
||||
if wto_traffic_find_standing(world, myPos, dir, lookM, slot, standing)
|
||||
wto_traffic_contact(now, wto_traffic_gap(standing, slot.spec), speedMps, nav)
|
||||
wto_traffic_contact(now, speedMps, standing, slot)
|
||||
if !wto_traffic_pass(navState, now, myPos, dir, standing, slot)
|
||||
wto_traffic_blocked(navState, now, standing, slot)
|
||||
return
|
||||
|
||||
@@ -66,15 +66,43 @@ def private wto_unstick_give_up(var world : WtoWorldSnap&; navState : int; now :
|
||||
slot.nav.unstickAttempts = 0
|
||||
slot.nav.unstickLevel = 0
|
||||
|
||||
// Pressed against a vehicle or wreck: back up at once instead of waiting for the stuck window,
|
||||
// and plan again so the next path or passing point accounts for it.
|
||||
// Pressed against the same body again: mark it for path searches and try its other side; after
|
||||
// unstickMaxAttempts repeats give the order up like a bot stuck for good.
|
||||
[never_inline]
|
||||
def public wto_unstick_contact(navState : int; now : float; myPos, hullFwd : float3; var slot : WtoBotSlot&)
|
||||
slot.nav.contactSince = -100.0
|
||||
slot.nav.contactEvents++
|
||||
slot.nav.stuckCheckAt = -100.0
|
||||
def private wto_unstick_contact_repeat(var world : WtoWorldSnap&; navState : int; now : float; myPos : float3;
|
||||
var slot : WtoBotSlot&)
|
||||
assume nav = slot.nav
|
||||
nav.contactRepeats++
|
||||
if nav.contactRepeats >= WTO_AI_PF_UNSTICK_MAX_ATTEMPTS
|
||||
nav.unstickAttempts = nav.contactRepeats
|
||||
nav.contactRepeats = 0
|
||||
wto_unstick_give_up(world, navState, now, myPos, nav.contactBodyPos, slot)
|
||||
return
|
||||
if navState == WTO_NAVMESH_LOADED
|
||||
wto_navq_add_dynamic(nav.contactBodyPos, nav.contactBodyRadiusM, WTO_AI_PF_RUBBLE_COST_MUL, now + WTO_AI_PF_BLOCK_TTL_SEC)
|
||||
if nav.avoidSide != 0.0
|
||||
nav.avoidSide = -nav.avoidSide
|
||||
nav.avoidSideUntil = now + WTO_AI_PF_UNSTICK_REV_SEC + WTO_AI_PF_BLOCK_WAIT_SEC
|
||||
|
||||
// Pressed against a vehicle or wreck: back up at once instead of waiting for the stuck window,
|
||||
// and plan again. Pressed again near the same place within contactRepeatSec escalates.
|
||||
[never_inline]
|
||||
def public wto_unstick_contact(var world : WtoWorldSnap&; navState : int; now : float; myPos, hullFwd : float3;
|
||||
var slot : WtoBotSlot&)
|
||||
assume nav = slot.nav
|
||||
let again = (now - nav.lastContactAt <= WTO_AI_PF_CONTACT_REPEAT_SEC &&
|
||||
wto_xz_dist_sq(myPos, nav.lastContactPos) <= WTO_AI_PF_JAM_RADIUS_M * WTO_AI_PF_JAM_RADIUS_M)
|
||||
nav.lastContactAt = now
|
||||
nav.lastContactPos = myPos
|
||||
nav.contactSince = -100.0
|
||||
nav.contactEvents++
|
||||
nav.stuckCheckAt = -100.0
|
||||
slot.route.replanRequested = true
|
||||
print("WTO_AI|NAV_CONTACT|eid={uint(slot.eid)}|pos={myPos}\n")
|
||||
if again
|
||||
wto_unstick_contact_repeat(world, navState, now, myPos, slot)
|
||||
else
|
||||
nav.contactRepeats = 0
|
||||
print("WTO_AI|NAV_CONTACT|eid={uint(slot.eid)}|repeat={nav.contactRepeats}|pos={myPos}|body={nav.contactBodyPos}\n")
|
||||
wto_unstick_start_reverse(navState, now, myPos, hullFwd, slot)
|
||||
|
||||
// Backing up after being stuck; true while the manoeuvre runs (the drive command is set).
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface GroundAiPathFollow {
|
||||
readonly blockTtlSec: number;
|
||||
readonly contactGapM: number;
|
||||
readonly contactReverseSec: number;
|
||||
readonly contactRepeatSec: number;
|
||||
readonly stuckWindowSec: number;
|
||||
readonly stuckMinProgressM: number;
|
||||
readonly unstickReverseM: number;
|
||||
@@ -483,6 +484,7 @@ function pathFollowEntries(p: GroundAiPathFollow): readonly DasEntry[] {
|
||||
['WTO_AI_PF_BLOCK_TTL_SEC', 'float', p.blockTtlSec],
|
||||
['WTO_AI_PF_CONTACT_GAP_M', 'float', p.contactGapM],
|
||||
['WTO_AI_PF_CONTACT_REVERSE_SEC', 'float', p.contactReverseSec],
|
||||
['WTO_AI_PF_CONTACT_REPEAT_SEC', 'float', p.contactRepeatSec],
|
||||
['WTO_AI_PF_STUCK_WINDOW_SEC', 'float', p.stuckWindowSec],
|
||||
['WTO_AI_PF_STUCK_MIN_PROGRESS_M', 'float', p.stuckMinProgressM],
|
||||
['WTO_AI_PF_UNSTICK_REV_M', 'float', p.unstickReverseM],
|
||||
|
||||
Reference in new issue
Block a user