def scene_objects_linear(scene): '''Return the PDDL objects for `scene'.''' obj = [] def type_names(thing): return [ f.name for f in tm.collect_frame_type(scene,thing) ] # Moveable objects are blocks moveable = type_names("moveable") moveable.insert(0, "BLOCK") # Draw grid on surfaces locations = ['LOCATION'] def add_loc(name,i,j): locations.append(tm.mangle(name,i,j)) for frame in tm.collect_frame_type(scene,"surface"): name = frame.name for geom in frame.geometry: shape = geom.shape if aa.shape_is_box(shape): d = shape.dimension x_max = d[0] / 2 y_max = d[1] / 2 x = 0 i = 0 while x <= x_max: y = 0 j = 0 while y <= y_max: add_loc(name,i,j) if i > 0: add_loc(name,-i,j) if j > 0: add_loc(name,i,-j) if i > 0 and j > 0: add_loc(name,-i,-j) y += RESOLUTION j+=1 x += RESOLUTION i+=1 return [moveable, locations]
def map_locations(function, scene): for frame in tm.collect_frame_type(scene,"surface"): name = frame['name'] for geom in frame['geometry']: shape = geom['shape'] if aa.shape_is_box(shape): d = shape['dimension'] x_max = d[0] / 2 y_max = d[1] / 2 x = 0 i = 0 while x <= x_max: y = 0 j = 0 while y <= y_max: function(name,i,j) if i > 0: function(name,-i,j) if j > 0: function(name,i,-j) if i > 0 and j > 0: function(name,-i,-j) y += RESOLUTION j+=1 x += RESOLUTION i+=1
def place_height(scene,name): g = scene[name].collision s = g[0].shape if aa.shape_is_box(s): return s.dimension[2] / 2