|
import numpy as np |
|
from shapely.geometry import * |
|
from shapely.affinity import * |
|
from env_utils import denormalize_xy, parse_obj_name, get_obj_names, get_obj_pos |
|
|
|
|
|
middle_pos = denormalize_xy([0.5, 0.5]) |
|
start_pos = middle_pos + [-0.3/2, 0] |
|
end_pos = middle_pos + [0.3/2, 0] |
|
line = make_line(start=start_pos, end=end_pos) |
|
points = interpolate_pts_on_line(line=line, n=3) |
|
ret_val = points |
|
|
|
middle_pos = denormalize_xy([1, 0.5]) |
|
start_pos = middle_pos + [0, -0.2/2] |
|
end_pos = middle_pos + [0, 0.2/2] |
|
line = make_line(start=start_pos, end=end_pos) |
|
points = interpolate_pts_on_line(line=line, n=4) |
|
ret_val = points |
|
|
|
top_left_corner = denormalize_xy([0, 1]) |
|
bottom_right_corner = denormalize_xy([1, 0]) |
|
line = make_line(start=top_left_corner, end=bottom_right_corner) |
|
points = interpolate_pts_on_line(line=line, n=5) |
|
ret_val = points |
|
|
|
polygon = make_triangle(size=0.1, center=denormalize_xy([0.5, 0.5])) |
|
points = get_points_from_polygon(polygon) |
|
ret_val = points |
|
|
|
block_name = parse_obj_name('the sun colored block', f'objects = {get_obj_names()}') |
|
corner_positions = np.array([denormalize_xy(pos) for pos in [[0, 0], [0, 1], [1, 1], [1, 0]]]) |
|
closest_corner_pos = get_closest_point(points=corner_positions, point=get_obj_pos(block_name)) |
|
ret_val = closest_corner_pos |
|
|
|
bowl_name = parse_obj_name('the right most bowl', f'objects = {get_obj_names()}') |
|
side_positions = np.array([denormalize_xy(pos) for pos in [[0.5, 0], [0.5, 1], [1, 0.5], [0, 0.5]]]) |
|
farthest_side_pos = get_farthest_point(points=side_positions, point=get_obj_pos(bowl_name)) |
|
ret_val = farthest_side_pos |
|
|
|
block_name = parse_obj_name('the third block from the bottom', f'objects = {get_obj_names()}') |
|
ret_val = get_obj_pos(block_name) + [0.1, 0] |
|
|
|
bowl_names = parse_obj_name('the bowls', f'objects = {get_obj_names()}') |
|
bowl_positions = get_all_object_positions_np(obj_names=bowl_names) |
|
left_obj_pos = bowl_positions[np.argmin(bowl_positions[:, 0])] + [-0.1, 0] |
|
ret_val = left_obj_pos |
|
|
|
bottom_pos = denormalize_xy([0.5, 0]) |
|
ret_val = bottom_pos |
|
|
|
top_left_pos = denormalize_xy([0, 1]) |
|
top_right_pos = denormalize_xy([1, 1]) |
|
ret_val = [top_left_pos, top_right_pos] |