Guide local goals around observed obstacles and finish native recovery
This commit is contained in:
@@ -44,7 +44,11 @@ def configuration(inputs, robot):
|
||||
static_layer=dict(plugin='nav2_costmap_2d::StaticLayer', map_topic='/observed_map',
|
||||
map_subscribe_transient_local=True, subscribe_to_updates=False),
|
||||
inflation_layer=dict(plugin='nav2_costmap_2d::InflationLayer',
|
||||
cost_scaling_factor=3.0, inflation_radius=math.hypot(x, y) + 0.15),
|
||||
# A gentle field over the local goal horizon makes observed
|
||||
# obstacles influence the path before the body is beside them.
|
||||
# Full footprint, lethal cells and support gates are unchanged.
|
||||
cost_scaling_factor=1.0 / geometry['width_m'],
|
||||
inflation_radius=max(3.5, math.hypot(x, y) + 0.15)),
|
||||
)
|
||||
# Bound the corner displacement from a full angular bin to half a map
|
||||
# cell. Humble floors the start heading; a coarse primitive lattice can
|
||||
|
||||
@@ -39,7 +39,8 @@ def observed_turn_support(angle, terrain, pose, monitor, contact_height):
|
||||
return bool(np.all(states=='observed-supported'))
|
||||
|
||||
|
||||
def alignment_angle(pose, goal, terrain, detected, monitor, contact_height):
|
||||
def alignment_angle(pose, goal, terrain, detected, monitor, contact_height, *,
|
||||
collision_terrain=None):
|
||||
delta = np.asarray(goal[:2]) - np.asarray(pose[:2])
|
||||
if np.linalg.norm(delta) <= .4:
|
||||
return None
|
||||
@@ -49,8 +50,13 @@ def alignment_angle(pose, goal, terrain, detected, monitor, contact_height):
|
||||
angle = math.atan2(math.sin(bearing), math.cos(bearing))
|
||||
if abs(angle) < math.pi/6:
|
||||
return None
|
||||
if not monitor.rotation_clear(angle, terrain, pose):
|
||||
collision = terrain if collision_terrain is None else collision_terrain
|
||||
if not monitor.rotation_clear(angle, collision, pose):
|
||||
return None
|
||||
if collision_terrain is not None:
|
||||
forbidden = terrain[terrain[:, 3] > collision[:, 3]]
|
||||
if not monitor.ground_envelope().rotation_clear(angle, forbidden, pose):
|
||||
return None
|
||||
objects = DetectionObstacles(monitor)
|
||||
hazards = np.column_stack((detected, np.full(len(detected), objects.cost)))
|
||||
if not objects.monitor.rotation_clear(angle, hazards, pose):
|
||||
|
||||
@@ -143,6 +143,15 @@ class Navigation:
|
||||
detected=observed['detected']):
|
||||
return self.reply('stale-range')
|
||||
route = route_observation(terrain, pose, value, self.monitor.max_step)
|
||||
# Return the same observed search obstacles used by Smac, as bounded
|
||||
# intent guidance only. Goal selection must see unlabelled solids too.
|
||||
hazards = observed['search_terrain']
|
||||
hazards = hazards[hazards[:, 3] > self.monitor.max_step + 1e-4, :2]
|
||||
if len(hazards):
|
||||
_, indices = np.unique(np.floor(hazards / .05), axis=0, return_index=True)
|
||||
hazards = hazards[np.sort(indices)]
|
||||
receipts['clearance_observation'] = dict(
|
||||
observation=route['observation'], obstacles_xy=hazards.tolist())
|
||||
support = route_support(self.monitor, observed, value, self.inputs)
|
||||
if support is not None:
|
||||
receipts["route_support"] = support
|
||||
@@ -183,7 +192,8 @@ class Navigation:
|
||||
if (not reverse and value['translation_allowed'] and not aligning
|
||||
and alignment_key != self.attempted_alignment):
|
||||
turn = alignment_angle(pose, goal, terrain, observed['detected'], self.monitor,
|
||||
value['body_contact_height_m'])
|
||||
value['body_contact_height_m'],
|
||||
collision_terrain=observed['collision_terrain'])
|
||||
orienting = aligning or turn is not None or (not reverse and orientation is not None
|
||||
and orientation_key != self.completed_orientation
|
||||
and not value['translation_allowed'])
|
||||
@@ -207,16 +217,16 @@ class Navigation:
|
||||
self.attempted_alignment = alignment_key
|
||||
local_path = [[0.,0.,0.],[0.,0.,0.]]
|
||||
elif reverse:
|
||||
key = ('backup', tuple(goal[:2]), limit)
|
||||
completed = self.completed_action(key, route)
|
||||
if completed is not None:
|
||||
return completed
|
||||
delta = goal[:2]-pose[:2]
|
||||
heading = yaw_of(pose)
|
||||
rear = -float(delta @ [math.cos(heading), math.sin(heading)])
|
||||
if rear <= 0:
|
||||
self.node.stop()
|
||||
return self.reply('reverse-goal-is-not-behind', status='blocked')
|
||||
key = ('backup', tuple(goal[:2]), limit)
|
||||
completed = self.completed_action(key, route)
|
||||
if completed is not None:
|
||||
return completed
|
||||
if key != self.action_key:
|
||||
with self.owner_lock:
|
||||
self.action_key = None
|
||||
|
||||
Reference in New Issue
Block a user