Datasets:
File size: 1,363 Bytes
870b85a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Conservative base candidates using the existing measured navigation geometry."""
import math
from shapely.geometry import Point, Polygon, shape
from shapely.ops import unary_union
def free_space(composition):
room=shape(composition['navigation_free_space']).buffer(-.3)
obstacles=[]
for entity in composition['entities']:
if entity.get('parent_entity_id') or entity.get('category') in {'rug','carpet'} or entity.get('base_z_m',0)>.4:
continue
points=entity.get('visual_footprint_polygon_xy_m') or entity.get('visual_footprint_xy_m')
if not points: raise ValueError('Missing measured obstacle footprint: '+entity['entity_id'])
obstacles.append(Polygon(points).buffer(.32))
return room.difference(unary_union(obstacles))
def candidates(composition, item):
free=free_space(composition)
center=item['position_xyz_m'][:2]
previous=item['approach_pose']
points=[]
for distance in (.42,.45,.48,.51,.54,.57,.60,.63):
for degree in range(0,360,5):
angle=math.radians(degree)
point=(round(center[0]+distance*math.cos(angle),6),round(center[1]+distance*math.sin(angle),6))
if free.contains(Point(point)): points.append(point)
points.sort(key=lambda p:(math.dist(p,center),math.dist(p,[previous['x_m'],previous['y_m']])))
return points
|