Skip to content

Commit

Permalink
[AbstractWorld]
Browse files Browse the repository at this point in the history
Added joint class to handle joint related things.
Object, Link, and Joint all have cached poses.
Cached poses update when World.simulate() is called.
Or when the poses are set manually.
  • Loading branch information
AbdelrhmanBassiouny committed Feb 3, 2024
1 parent 50adda9 commit 99c675f
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 130 deletions.
9 changes: 5 additions & 4 deletions src/pycram/bullet_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,15 @@ def get_number_of_joints(self, obj: Object) -> int:
def reset_joint_position(self, obj: Object, joint_name: str, joint_pose: float) -> None:
p.resetJointState(obj.id, obj.joint_name_to_id[joint_name], joint_pose, physicsClientId=self.client_id)

def reset_object_base_pose(self, obj: Object, position: List[float], orientation: List[float]):
p.resetBasePositionAndOrientation(obj.id, position, orientation, physicsClientId=self.client_id)
def reset_object_base_pose(self, obj: Object, pose: Pose) -> None:
p.resetBasePositionAndOrientation(obj.id, pose.position_as_list(), pose.orientation_as_list(),
physicsClientId=self.client_id)

def step(self):
p.stepSimulation(physicsClientId=self.client_id)

def update_obj_pose(self, obj: Object) -> None:
obj.set_pose(Pose(*p.getBasePositionAndOrientation(obj.id, physicsClientId=self.client_id)))
def get_object_pose(self, obj: Object) -> Pose:
return Pose(*p.getBasePositionAndOrientation(obj.id, physicsClientId=self.client_id))

def set_link_color(self, link: Link, rgba_color: Color):
p.changeVisualShape(link.get_object_id(), link.id, rgbaColor=rgba_color, physicsClientId=self.client_id)
Expand Down
4 changes: 3 additions & 1 deletion src/pycram/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TaskStatus(Enum):
SUCCEEDED = 2
FAILED = 3


class JointType(Enum):
"""
Enum for readable joint types.
Expand All @@ -29,6 +28,9 @@ class JointType(Enum):
SPHERICAL = 2
PLANAR = 3
FIXED = 4
UNKNOWN = 5
CONTINUOUS = 6
FLOATING = 7


class Grasp(Enum):
Expand Down
2 changes: 1 addition & 1 deletion src/pycram/pose_generator_and_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def reachability_validator(pose: Pose,
if robot in allowed_collision.keys():
allowed_robot_links = allowed_collision[robot]

joint_state_before_ik = robot._current_joints_positions
joint_state_before_ik = robot.get_positions_of_all_joints()
try:
# resp = request_ik(base_link, end_effector, target_diff, robot, left_joints)
resp = request_ik(target, robot, left_joints, left_gripper)
Expand Down
Loading

0 comments on commit 99c675f

Please sign in to comment.