RoboParty Release
Unify robohome source, assets and scenes delivery
3f15e9f
Raw History Blame Contribute Delete
1.36 kB
"""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