Keep through-travel heading at lateral local goals
This commit is contained in:
@@ -281,7 +281,18 @@ class Navigation:
|
||||
if (key != self.action_key or not continuing or self.path is None
|
||||
or self.node.native_command() is None
|
||||
or entered-self.path_planned_at >= 1.0):
|
||||
path, status = self.node.plan(pose, goal, math.atan2(goal[1]-pose[1],goal[0]-pose[0]))
|
||||
heading = math.atan2(goal[1]-pose[1], goal[0]-pose[0])
|
||||
if (value.get('continuous', False) and target is None
|
||||
and not value.get('recovery_orientation', False)
|
||||
and orientation is not None and 'direction_xy' in orientation):
|
||||
# The observed passage selects XY; the declared continuation
|
||||
# supplies its through-travel heading. Re-aiming the terminal
|
||||
# body toward a nearby lateral XY each replan makes the
|
||||
# approach progressively tighter instead of rejoining travel.
|
||||
# Smac still checks the complete path and footprint, and the
|
||||
# live support/collision gates retain all motion authority.
|
||||
heading = math.atan2(*reversed(orientation['direction_xy']))
|
||||
path, status = self.node.plan(pose, goal, heading)
|
||||
if path is None or len(path.poses) < 2:
|
||||
self.stop()
|
||||
# Humble has no typed planner error code. Preserve its
|
||||
|
||||
@@ -262,3 +262,51 @@ def test_view_spin_is_not_restarted_by_translated_direction_endpoint(moving_brid
|
||||
result = navigation.plan(value)
|
||||
assert len(calls) == int(changed)
|
||||
assert result['controller_generation'] == (8 if changed else 7)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('world_yaw', [0., .73, -2.1])
|
||||
def test_lateral_passage_goal_keeps_continuation_heading_while_body_approaches(moving_bridge, world_yaw):
|
||||
navigation, value, _, _ = moving_bridge
|
||||
axes = np.array([[math.cos(world_yaw), -math.sin(world_yaw)],
|
||||
[math.sin(world_yaw), math.cos(world_yaw)]])
|
||||
origin = np.array([42., -17.])
|
||||
goal = origin + axes @ [3., -1.2]
|
||||
direction = axes @ [1., 0.]
|
||||
value.update(goal=[*goal, 0.], route_transition_target=None,
|
||||
orientation_target=dict(key='route-0-1', xy=[*goal],
|
||||
direction_xy=direction.tolist()))
|
||||
native_plan = navigation.node.plan
|
||||
headings = []
|
||||
def capture(pose, selected, heading):
|
||||
headings.append(heading)
|
||||
np.testing.assert_allclose(selected[:2], goal)
|
||||
return native_plan(pose, selected, heading)
|
||||
navigation.node.plan = capture
|
||||
for along, lateral, body_yaw in [(0., 0., 0.), (1., -.1, -.2), (2., -.5, -.6)]:
|
||||
xy = origin + axes @ [along, lateral]
|
||||
a = world_yaw + body_yaw
|
||||
value['pose'] = [*xy, .37, 0., 0., math.sin(a/2), math.cos(a/2)]
|
||||
navigation.path_planned_at = float('-inf')
|
||||
assert navigation.plan(value)['status'] == 'path'
|
||||
# The observed endpoint still selects the lateral passage. Approaching it
|
||||
# must not turn its shrinking diagonal into a progressively sharper final
|
||||
# body heading: this is through travel along one continuation, not parking.
|
||||
np.testing.assert_allclose(headings, world_yaw, atol=1e-12)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mode', ['unrouted', 'recovery', 'arrival', 'discrete'])
|
||||
def test_continuation_heading_does_not_override_a_placement_or_recovery(moving_bridge, mode):
|
||||
navigation, value, _, _ = moving_bridge
|
||||
value['orientation_target']['direction_xy'] = [1., 0.]
|
||||
if mode == 'unrouted':value['orientation_target'].pop('direction_xy')
|
||||
elif mode == 'recovery':value['recovery_orientation'] = True
|
||||
elif mode == 'arrival':value.update(arrival_target=[20., 0.], visual_goal_available=True)
|
||||
else:value['continuous'] = False
|
||||
native_plan = navigation.node.plan
|
||||
headings = []
|
||||
def capture(pose, selected, heading):
|
||||
headings.append(heading)
|
||||
return native_plan(pose, selected, heading)
|
||||
navigation.node.plan = capture
|
||||
assert navigation.plan(value)['status'] == 'path'
|
||||
assert headings == [math.atan2(.2, 4.)]
|
||||
|
||||
Reference in New Issue
Block a user