Skip to content

Commit a405675

Browse files
committed
only solve ik for left arm in ioai grasp env
1 parent 6c5fc48 commit a405675

File tree

1 file changed

+18
-48
lines changed

1 file changed

+18
-48
lines changed

examples/ioai_examples/ioai_grasp_env.py

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ def _is_joint_positions_reached(self, module, target_positions, atol=0.01):
389389
current_positions = module.get_joint_positions()
390390
return np.allclose(current_positions, target_positions, atol=atol)
391391

392-
def _is_arms_motion_complete(self, atol=0.01):
393-
"""Check if both arms have reached their target positions."""
392+
def _is_left_arm_motion_complete(self, atol=0.01):
393+
"""Check if left arm has reached its target position."""
394394
for module_name, target_positions in self.target_joint_positions.items():
395395
module = getattr(self.interface, module_name)
396396
if not self._is_joint_positions_reached(module, target_positions, atol):
@@ -436,27 +436,21 @@ def init_state():
436436
# Get current joint positions as start configuration
437437
current_joints = self.mink_config.q
438438

439-
# Solve IK for left arm
439+
# Solve IK for left arm only
440440
left_target_pose = np.array([0.5, 0.3, 0.7, 0, 0.7071, 0, 0.7071])
441441
left_arm_joints = self.compute_simple_ik(current_joints, left_target_pose, "left_arm")
442442

443-
# Solve IK for right arm
444-
right_target_pose = np.array([0.5, -0.3, 0.7, 0, 0.7071, 0, 0.7071])
445-
right_arm_joints = self.compute_simple_ik(current_joints, right_target_pose, "right_arm")
446-
447-
# Start motion for arms only
443+
# Start motion for left arm only
448444
self._move_joints_to_target(self.interface.left_arm, left_arm_joints)
449-
self._move_joints_to_target(self.interface.right_arm, right_arm_joints)
450445

451446
# Store target positions for completion check
452447
self.target_joint_positions = {
453-
"left_arm": left_arm_joints,
454-
"right_arm": right_arm_joints
448+
"left_arm": left_arm_joints
455449
}
456450
self.motion_in_progress = True
457451

458452
# Check if motion is complete
459-
if self._is_arms_motion_complete():
453+
if self._is_left_arm_motion_complete():
460454
self.motion_in_progress = False
461455
return True
462456
return False
@@ -471,24 +465,18 @@ def move_to_pre_pick_state():
471465

472466
current_joints = self.mink_config.q
473467

474-
# Solve IK for left arm
468+
# Solve IK for left arm only
475469
left_target_pose = np.concatenate([self.cube_position + np.array([0, 0, 0.15]), np.array([0, 0.7071, 0, 0.7071])])
476470
left_arm_joints = self.compute_simple_ik(current_joints, left_target_pose, "left_arm")
477471

478-
# Solve IK for right arm
479-
right_target_pose = np.array([0.5, -0.3, 0.7, 0, 0.7071, 0, 0.7071])
480-
right_arm_joints = self.compute_simple_ik(current_joints, right_target_pose, "right_arm")
481-
482472
self._move_joints_to_target(self.interface.left_arm, left_arm_joints)
483-
self._move_joints_to_target(self.interface.right_arm, right_arm_joints)
484473

485474
self.target_joint_positions = {
486-
"left_arm": left_arm_joints,
487-
"right_arm": right_arm_joints
475+
"left_arm": left_arm_joints
488476
}
489477
self.motion_in_progress = True
490478

491-
if self._is_arms_motion_complete():
479+
if self._is_left_arm_motion_complete():
492480
self.motion_in_progress = False
493481
return True
494482
return False
@@ -498,24 +486,18 @@ def move_to_pick_state():
498486
if not self.motion_in_progress:
499487
current_joints = self.mink_config.q
500488

501-
# Solve IK for left arm
489+
# Solve IK for left arm only
502490
left_target_pose = np.concatenate([self.cube_position + np.array([0, 0, 0.03]), np.array([0, 0.7071, 0, 0.7071])])
503491
left_arm_joints = self.compute_simple_ik(current_joints, left_target_pose, "left_arm")
504492

505-
# Solve IK for right arm
506-
right_target_pose = np.array([0.5, -0.3, 0.7, 0, 0.7071, 0, 0.7071])
507-
right_arm_joints = self.compute_simple_ik(current_joints, right_target_pose, "right_arm")
508-
509493
self._move_joints_to_target(self.interface.left_arm, left_arm_joints)
510-
self._move_joints_to_target(self.interface.right_arm, right_arm_joints)
511494

512495
self.target_joint_positions = {
513-
"left_arm": left_arm_joints,
514-
"right_arm": right_arm_joints
496+
"left_arm": left_arm_joints
515497
}
516498
self.motion_in_progress = True
517499

518-
if self._is_arms_motion_complete():
500+
if self._is_left_arm_motion_complete():
519501
self.motion_in_progress = False
520502
return True
521503
return False
@@ -537,24 +519,18 @@ def move_to_pre_place_state():
537519
if not self.motion_in_progress:
538520
current_joints = self.mink_config.q
539521

540-
# Solve IK for left arm
522+
# Solve IK for left arm only
541523
left_target_pose = np.concatenate([self.cube_position + np.array([-0.1, 0, 0.4]), np.array([0, 0.7071, 0, 0.7071])])
542524
left_arm_joints = self.compute_simple_ik(current_joints, left_target_pose, "left_arm")
543525

544-
# Solve IK for right arm
545-
right_target_pose = np.array([0.5, -0.3, 0.7, 0, 0.7071, 0, 0.7071])
546-
right_arm_joints = self.compute_simple_ik(current_joints, right_target_pose, "right_arm")
547-
548526
self._move_joints_to_target(self.interface.left_arm, left_arm_joints)
549-
self._move_joints_to_target(self.interface.right_arm, right_arm_joints)
550527

551528
self.target_joint_positions = {
552-
"left_arm": left_arm_joints,
553-
"right_arm": right_arm_joints
529+
"left_arm": left_arm_joints
554530
}
555531
self.motion_in_progress = True
556532

557-
if self._is_arms_motion_complete():
533+
if self._is_left_arm_motion_complete():
558534
self.motion_in_progress = False
559535
return True
560536
return False
@@ -569,24 +545,18 @@ def move_to_place_state():
569545

570546
current_joints = self.mink_config.q
571547

572-
# Solve IK for left arm
548+
# Solve IK for left arm only
573549
left_target_pose = np.concatenate([self.bucket_position + np.array([0, 0, 0.3]), np.array([0, 0.7071, 0, 0.7071])])
574550
left_arm_joints = self.compute_simple_ik(current_joints, left_target_pose, "left_arm")
575551

576-
# Solve IK for right arm
577-
right_target_pose = np.array([0.5, -0.3, 0.7, 0, 0.7071, 0, 0.7071])
578-
right_arm_joints = self.compute_simple_ik(current_joints, right_target_pose, "right_arm")
579-
580552
self._move_joints_to_target(self.interface.left_arm, left_arm_joints)
581-
self._move_joints_to_target(self.interface.right_arm, right_arm_joints)
582553

583554
self.target_joint_positions = {
584-
"left_arm": left_arm_joints,
585-
"right_arm": right_arm_joints
555+
"left_arm": left_arm_joints
586556
}
587557
self.motion_in_progress = True
588558

589-
if self._is_arms_motion_complete():
559+
if self._is_left_arm_motion_complete():
590560
self.motion_in_progress = False
591561
return True
592562
return False

0 commit comments

Comments
 (0)