Find return points at nearby terrain elevations
This commit is contained in:
1 parent
295f033411
commit
8fd81b6f2a
1 file changed
+33
-5
@@ -30,6 +30,12 @@ class WorkBoundaryReturnMixin:
|
|||||||
if self.work_policies and
|
if self.work_policies and
|
||||||
self.work_boundary_start_position is not None else 0.0)
|
self.work_boundary_start_position is not None else 0.0)
|
||||||
self.work_boundary_return_retry_at = 0.0
|
self.work_boundary_return_retry_at = 0.0
|
||||||
|
if (self.work_policies and
|
||||||
|
self.work_boundary_return_point is None and
|
||||||
|
self.work_boundary_start_position is not None):
|
||||||
|
print('[work boundary] start {} is outside the active policy; '
|
||||||
|
'will find an in-bound return point after this task'.format(
|
||||||
|
self.work_boundary_start_position))
|
||||||
|
|
||||||
def _inside_work_policies(self, position):
|
def _inside_work_policies(self, position):
|
||||||
return bool(self.work_policies) and all(
|
return bool(self.work_policies) and all(
|
||||||
@@ -90,10 +96,14 @@ class WorkBoundaryReturnMixin:
|
|||||||
base_x = anchor[0] + dx * scale
|
base_x = anchor[0] + dx * scale
|
||||||
base_z = anchor[2] + dz * scale
|
base_z = anchor[2] + dz * scale
|
||||||
base = (int(round(base_x)), anchor[1], int(round(base_z)))
|
base = (int(round(base_x)), anchor[1], int(round(base_z)))
|
||||||
for dy in (0, -1, 1):
|
# Signs are commonly placed several blocks above the floor.
|
||||||
|
# Search elevations around both the sign and the bot instead
|
||||||
|
# of assuming a standable return point is at sign_y +/- 1.
|
||||||
|
lower_y = min(int(from_position[1]), anchor[1]) - 8
|
||||||
|
upper_y = max(int(from_position[1]), anchor[1]) + 8
|
||||||
|
for y in range(lower_y, upper_y + 1):
|
||||||
for ox, oz in offsets:
|
for ox, oz in offsets:
|
||||||
point = (base[0] + ox, base[1] + dy,
|
point = (base[0] + ox, y, base[2] + oz)
|
||||||
base[2] + oz)
|
|
||||||
if (point not in candidates and
|
if (point not in candidates and
|
||||||
self._inside_work_policies(point) and
|
self._inside_work_policies(point) and
|
||||||
standable(point)):
|
standable(point)):
|
||||||
@@ -104,11 +114,29 @@ class WorkBoundaryReturnMixin:
|
|||||||
|
|
||||||
def _find_work_boundary_return_plan(self, world, from_position,
|
def _find_work_boundary_return_plan(self, world, from_position,
|
||||||
preferred_points=()):
|
preferred_points=()):
|
||||||
for point in self._work_boundary_return_candidates(
|
candidates = self._work_boundary_return_candidates(
|
||||||
world, from_position, preferred_points):
|
world, from_position, preferred_points)
|
||||||
|
verbose = getattr(self, 'work_boundary_return_retry_at', 0.0) == 0.0
|
||||||
|
if verbose:
|
||||||
|
print('[work boundary] planning return from {} with {} '
|
||||||
|
'in-bound candidate(s)'.format(from_position, len(candidates)))
|
||||||
|
failed = []
|
||||||
|
for point in candidates:
|
||||||
navpath = world.path_to_place(from_position, point)
|
navpath = world.path_to_place(from_position, point)
|
||||||
if navpath is not None:
|
if navpath is not None:
|
||||||
|
if verbose:
|
||||||
|
print('[work boundary] return route to {} has {} '
|
||||||
|
'waypoint(s)'.format(point, len(navpath)))
|
||||||
return point, navpath
|
return point, navpath
|
||||||
|
failed.append(point)
|
||||||
|
if verbose:
|
||||||
|
if failed:
|
||||||
|
print('[work boundary] no route to return candidates; tried {} '
|
||||||
|
'(first failures: {})'.format(
|
||||||
|
len(failed), failed[:8]))
|
||||||
|
else:
|
||||||
|
print('[work boundary] no standable in-bound return candidates '
|
||||||
|
'near the active boundary')
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def _maybe_return_to_work_boundary(self, resume_state):
|
def _maybe_return_to_work_boundary(self, resume_state):
|
||||||
|
|||||||
Reference in new issue
Block a user