Spaces:
Sleeping
Sleeping
Commit
·
955085e
1
Parent(s):
a323252
Adicionar validacao de bounds em add_goal para garantir que todas as poses alvo estejam dentro do workspace
Browse files- cliport/tasks/task.py +32 -1
cliport/tasks/task.py
CHANGED
|
@@ -505,8 +505,39 @@ class Task():
|
|
| 505 |
- params ([(zone_target, zone_size)])): has to be [(zone_target, zone_size)] if the metric is `zone` where obj_pts is a dictionary that maps object ID to points.
|
| 506 |
- step_max_reward (float): the maximum reward of matching all the objects with all the target poses.
|
| 507 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
objs = self.zip_obj_ids(objs, symmetries)
|
| 509 |
-
self.goals.append((objs, matches,
|
| 510 |
metric, params, step_max_reward))
|
| 511 |
if language_goal is not None:
|
| 512 |
if type(language_goal) is str:
|
|
|
|
| 505 |
- params ([(zone_target, zone_size)])): has to be [(zone_target, zone_size)] if the metric is `zone` where obj_pts is a dictionary that maps object ID to points.
|
| 506 |
- step_max_reward (float): the maximum reward of matching all the objects with all the target poses.
|
| 507 |
"""
|
| 508 |
+
# Validate that all target poses are within workspace bounds
|
| 509 |
+
validated_targ_poses = []
|
| 510 |
+
for i, targ_pose in enumerate(targ_poses):
|
| 511 |
+
if isinstance(targ_pose, tuple) and len(targ_pose) == 2:
|
| 512 |
+
pos, rot = targ_pose
|
| 513 |
+
if isinstance(pos, (list, tuple, np.ndarray)) and len(pos) >= 3:
|
| 514 |
+
x, y, z = float(pos[0]), float(pos[1]), float(pos[2])
|
| 515 |
+
|
| 516 |
+
# Check if position needs clamping
|
| 517 |
+
x_original, y_original, z_original = x, y, z
|
| 518 |
+
x = np.clip(x, self.bounds[0, 0], self.bounds[0, 1])
|
| 519 |
+
y = np.clip(y, self.bounds[1, 0], self.bounds[1, 1])
|
| 520 |
+
z = np.clip(z, self.bounds[2, 0], self.bounds[2, 1])
|
| 521 |
+
|
| 522 |
+
# Warn if position was adjusted
|
| 523 |
+
if (x != x_original or y != y_original or z != z_original):
|
| 524 |
+
print(f"Warning: Target pose {i} was clamped to workspace bounds: "
|
| 525 |
+
f"({x_original:.3f}, {y_original:.3f}, {z_original:.3f}) -> "
|
| 526 |
+
f"({x:.3f}, {y:.3f}, {z:.3f})")
|
| 527 |
+
|
| 528 |
+
# Create validated pose (preserve original format if possible)
|
| 529 |
+
if isinstance(pos, np.ndarray):
|
| 530 |
+
validated_pos = np.array([x, y, z], dtype=pos.dtype)
|
| 531 |
+
else:
|
| 532 |
+
validated_pos = np.array([x, y, z])
|
| 533 |
+
validated_targ_poses.append((validated_pos, rot))
|
| 534 |
+
else:
|
| 535 |
+
validated_targ_poses.append(targ_pose)
|
| 536 |
+
else:
|
| 537 |
+
validated_targ_poses.append(targ_pose)
|
| 538 |
+
|
| 539 |
objs = self.zip_obj_ids(objs, symmetries)
|
| 540 |
+
self.goals.append((objs, matches, validated_targ_poses, replace, rotations,
|
| 541 |
metric, params, step_max_reward))
|
| 542 |
if language_goal is not None:
|
| 543 |
if type(language_goal) is str:
|