Align native planning clearance and admit observed tracked pivots
This commit is contained in:
@@ -19,6 +19,7 @@ import rclpy
|
||||
import yaml
|
||||
from action_msgs.msg import GoalStatus
|
||||
from configuration import observed_configuration
|
||||
from differential_motion import alignment_angle
|
||||
from navigation.arrival_approach import validate_orientation
|
||||
from navigation.continuous_control import ContinuousControl
|
||||
from navigation.footprint import Footprint
|
||||
@@ -44,6 +45,7 @@ class Navigation:
|
||||
self.plan_lock, self.owner_lock = threading.Lock(), threading.Lock()
|
||||
self.action_key = None
|
||||
self.completed_orientation = None
|
||||
self.attempted_alignment = None
|
||||
self.path = None
|
||||
self.path_planned_at = float('-inf')
|
||||
self.active, self.failure = False, None
|
||||
@@ -124,7 +126,8 @@ class Navigation:
|
||||
terrain = observed['terrain']
|
||||
self.latest_terrain = observed
|
||||
observed['observation_id'] = value['observation_id']
|
||||
if not self.collision.publish(value, observed['search_terrain'], time.monotonic()-entered):
|
||||
if not self.collision.publish(value, observed['search_terrain'], time.monotonic()-entered,
|
||||
detected=observed['detected']):
|
||||
return self.reply('stale-range')
|
||||
route = route_observation(terrain, pose, value, self.monitor.max_step)
|
||||
orientation = validate_orientation(value.get('orientation_target'))
|
||||
@@ -150,22 +153,33 @@ class Navigation:
|
||||
and self.node.terminal is not None and self.node.terminal.done()
|
||||
and self.node.terminal.result().status == GoalStatus.STATUS_SUCCEEDED):
|
||||
self.completed_orientation = orientation_key
|
||||
# Smac/DWB owns the approach to a permitted translation destination,
|
||||
# including recovery goals. Forcing a bearing-alignment Spin first can
|
||||
# sweep the rear into an obstacle when a forward arc is available.
|
||||
# Spin belongs only to explicit orientation-only intent; its completion
|
||||
# cannot authorize translation. BackUp keeps the existing body heading.
|
||||
orienting = (not reverse and orientation is not None
|
||||
# The tracked rover can change heading without translating. Consider
|
||||
# a native Spin before a large direction change, only if the complete
|
||||
# rectangular body turn fits the obstacle/detector reserve and its
|
||||
# complete newly entered track sweep has measured support.
|
||||
# Unsafe turns leave Smac/DWB free to find an arc. Support and all live
|
||||
# command gates still apply during Spin; completion grants no motion.
|
||||
alignment_key = ('align', tuple(goal[:2]), limit)
|
||||
aligning = (not reverse and value['translation_allowed']
|
||||
and self.action_key == alignment_key and self.node.terminal is not None
|
||||
and not self.node.terminal.done())
|
||||
turn = None
|
||||
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'])
|
||||
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'])
|
||||
if not value['translation_allowed'] and not orienting:
|
||||
self.node.stop()
|
||||
return self.reply('no-permitted-goal', status='blocked', route_observation=route)
|
||||
if orienting:
|
||||
delta = np.asarray(orientation['xy'])-pose[:2]
|
||||
automatic = aligning or turn is not None
|
||||
delta = (goal[:2] if automatic else np.asarray(orientation['xy']))-pose[:2]
|
||||
heading = math.atan2(delta[1], delta[0])
|
||||
angle = math.atan2(math.sin(heading-yaw_of(pose)), math.cos(heading-yaw_of(pose)))
|
||||
key = orientation_key
|
||||
key = alignment_key if automatic else orientation_key
|
||||
if key != self.action_key:
|
||||
with self.owner_lock:
|
||||
self.action_key = None
|
||||
@@ -173,6 +187,8 @@ class Navigation:
|
||||
# a second wall-clock maneuver budget in a slower simulation.
|
||||
# The unchanged command/data leases still gate every output.
|
||||
self.node.spin(angle, 0.)
|
||||
if automatic:
|
||||
self.attempted_alignment = alignment_key
|
||||
local_path = [[0.,0.,0.],[0.,0.,0.]]
|
||||
elif reverse:
|
||||
delta = goal[:2]-pose[:2]
|
||||
|
||||
Reference in New Issue
Block a user