Skip to content

Commit

Permalink
fixing some bugs from merge master into fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
qujohn314 committed Nov 16, 2023
1 parent 2db5344 commit 07c854d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ tests/_fake_trajs
tests/_fake_results
saved_dataset_behavior
dataset_backup
video_frames
# Jetbrains IDEs
.idea/
2 changes: 1 addition & 1 deletion predicators/behavior_utils/behavior_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def get_relevant_scene_body_ids(
return ids


def detect_collision(bodyA: int, object_in_hand: Optional[int] = None) -> bool:
def detect_collision(bodyA: int, ignore_objects: Optional[int] = None) -> bool:
"""Detects collisions between bodyA in the scene (except for the object in
the robot's hand)"""
if not isinstance(ignore_objects, list):
Expand Down
18 changes: 10 additions & 8 deletions predicators/behavior_utils/motion_planner_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,10 @@ def make_grasp_plan(
points = p.getClosestPoints(env.robots[0].get_body_id(), obj.get_body_id(), distance=10)#, linkIndexA=env.robots[0].grasp_point_joint_id)
closest_point = min(points, key=lambda x:x[8])
obj_pos = closest_point[6]

x = obj_pos[0] + grasp_offset[0]
y = obj_pos[1] + grasp_offset[1]
z = obj_pos[2] + grasp_offset[2]
hand_x, hand_y, hand_z = env.robots[0].parts["right_hand"].get_position()
minx = min(x, hand_x) - 0.5
miny = min(y, hand_y) - 0.5
minz = min(z, hand_z) - 0.5
maxx = max(x, hand_x) + 0.5
maxy = max(y, hand_y) + 0.5
maxz = max(z, hand_z) + 0.5


if isinstance(env.robots[0], BehaviorRobot):
# compute the angle the hand must be in such that it can
Expand All @@ -267,6 +260,15 @@ def make_grasp_plan(
# https://math.stackexchange.com/questions/180418/
# calculate-rotation-matrix-to-align-vector-a-to-vector
# -b-in-3d

hand_x, hand_y, hand_z = env.robots[0].parts["right_hand"].get_position()
minx = min(x, hand_x) - 0.5
miny = min(y, hand_y) - 0.5
minz = min(z, hand_z) - 0.5
maxx = max(x, hand_x) + 0.5
maxy = max(y, hand_y) + 0.5
maxz = max(z, hand_z) + 0.5

hand_to_obj_vector = np.array(grasp_offset[:3])
hand_to_obj_unit_vector = hand_to_obj_vector / \
np.linalg.norm(
Expand Down
2 changes: 1 addition & 1 deletion predicators/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def run_low_level_search(
nsrt = skeleton[cur_idx]
# Ground the NSRT's ParameterizedOption into an _Option.
# This invokes the NSRT's sampler.
option = nsrt.sample_option(state, task.goal, rng_sampler)
option = nsrt.sample_option(state, task.goal, skeleton, rng_sampler)
plan[cur_idx] = option
# Increment num_samples metric by 1
metrics["num_samples"] += 1
Expand Down

0 comments on commit 07c854d

Please sign in to comment.