Allow observed detours to join advisory route segments
This commit is contained in:
@@ -424,10 +424,13 @@ class RoutedMission(WaypointMission):
|
||||
return None
|
||||
adjacent = segments[self.segment_index : self.segment_index + 2]
|
||||
if adjacent[0].get("guidance_only"):
|
||||
along, lateral = projection(pose[:2], adjacent[0]["start_xy"], adjacent[0]["end_xy"])
|
||||
along, _ = projection(pose[:2], adjacent[0]["start_xy"], adjacent[0]["end_xy"])
|
||||
length = math.dist(adjacent[0]["start_xy"], adjacent[0]["end_xy"])
|
||||
# A soft line must not allow instant graph progress at a distance.
|
||||
if length - along > 1.5 or lateral > max(2., adjacent[0]["half_width_m"]):
|
||||
# Use the same local observation radius as the native support
|
||||
# query. An advisory line's width is not a travel boundary: a
|
||||
# positively observed detour may join the next segment off-centre.
|
||||
# Progress and proximity still prevent remote/skipped joints.
|
||||
if length - along > 1.5 or math.dist(pose[:2], adjacent[0]["end_xy"]) > 3.5:
|
||||
return None
|
||||
directions = [np.asarray(s["end_xy"]) - s["start_xy"] for s in adjacent]
|
||||
# A reversal is a visit and return, not a corner that can be cut.
|
||||
|
||||
@@ -37,7 +37,7 @@ def bridge(monkeypatch):
|
||||
navigation.collision = SimpleNamespace(publish=lambda *args, **kwargs: True)
|
||||
floor = np.array([[x, y, 0., 0.] for x in np.arange(-2, 2.01, .05)
|
||||
for y in np.arange(-2, 2.01, .05)])
|
||||
observed = dict(terrain=floor, permitted_terrain=floor, search_terrain=floor,
|
||||
observed = dict(terrain=floor, collision_terrain=floor, permitted_terrain=floor, search_terrain=floor,
|
||||
detected=np.empty((0, 3)))
|
||||
navigation.terrain = SimpleNamespace(observe=lambda _: observed)
|
||||
value = dict(pose=[0., 0., .37, 0., 0., 0., 1.], goal=[1., 0., 0.],
|
||||
|
||||
@@ -178,3 +178,49 @@ def test_native_abort_retires_soft_joint_goal_but_keeps_final_and_return_anchor(
|
||||
mission.goal = final
|
||||
mission.retire_local_goal(None, failed=True)
|
||||
assert mission.goal == final
|
||||
|
||||
|
||||
@pytest.mark.parametrize("condition", ["supported", "unknown", "stale", "remote",
|
||||
"early", "no-go", "hard", "return", "reverse"])
|
||||
def test_observed_detour_can_pass_advisory_joint_without_returning_to_line(condition):
|
||||
from k1link.simulation.ai_polygon.route_mission import RoutedMission
|
||||
*_, inputs, _ = fixture()
|
||||
inputs["routing"]["blocked_edges"] = ["0", "1", "2"]
|
||||
inputs.update(sensors={"schema_version": "missioncore.simulation-sensor-rig/v4"},
|
||||
behavior={"max_speed_mps": 1.})
|
||||
mission = RoutedMission(inputs)
|
||||
mission.route_observation([0., 0., 0., 0., 0., 0., 1.], 0.)
|
||||
# A wide observed passage, offset from the prior, near the next joint.
|
||||
# No scene coordinates or obstacle labels supply movement permission.
|
||||
pose = [2.8, 4.5, 0., 0., 0., 0., 1.]
|
||||
if condition == "remote":
|
||||
pose[0] = 4.
|
||||
if condition == "early":
|
||||
pose[1] = 3.
|
||||
mission.route_observation(pose, 10.)
|
||||
mission.last_time, mission.last_pose = 10., tuple(pose)
|
||||
body = dict(observation=dict(pose=pose, target_xy=mission.arrival_target(),
|
||||
simulation_time_seconds=10., execution_inputs_sha256=inputs["sha256"]),
|
||||
admitted=True, collision_free=True, support_known=True,
|
||||
positive_surface_required=True, support_samples=4, supported_samples=4)
|
||||
if condition == "unknown":
|
||||
body.update(admitted=False, support_known=False, supported_samples=0)
|
||||
if condition == "stale":
|
||||
body["observation"]["simulation_time_seconds"] = 9.
|
||||
if condition == "no-go":
|
||||
mission.global_route["no_go"] = [dict(lower_xy=[2., 4.], upper_xy=[3., 5.])]
|
||||
if condition == "hard":
|
||||
for segment in mission.leg["segments"]:
|
||||
segment.pop("guidance_only", None)
|
||||
if condition == "return":
|
||||
mission.leg["segments"][0]["return_to_anchor"] = True
|
||||
if condition == "reverse":
|
||||
mission.leg["segments"][1]["end_xy"] = [0., 0.]
|
||||
result = mission.confirm_corridor_transition(pose, 10., body)
|
||||
assert (result is not None) is (condition == "supported")
|
||||
assert mission.segment_index == (1 if condition == "supported" else 0)
|
||||
assert mission.index == 0 # a corridor transition never completes a task goal
|
||||
if result:
|
||||
assert result["authority"] == "adjacent-route-intent-only; not-mission-arrival"
|
||||
assert result["body"] == body
|
||||
assert mission.confirm_corridor_transition(pose, 10., body) is None
|
||||
|
||||
Reference in New Issue
Block a user