-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotate Cube Task using Trifingerpro robot #249
Merged
Merged
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4c73346
update rotate_cube v1
Kami-code a7c45b2
update rotate_cube v1
Kami-code 73ef7ce
update rotate_cube v1
Kami-code 33185cb
update rotate_cube v1
Kami-code d65fb0c
update rotate_cube v1
Kami-code 6411306
update rotate_cube v1
Kami-code fcb393b
update rotate_cube v1
Kami-code 264a8d8
update rotate_cube v1
Kami-code dd06ef1
update rotate_cube v1
Kami-code 6f9b692
update rotate_cube v1
Kami-code 138133a
update rotate_cube v1
Kami-code 3bbd78e
update rotate_cube v1
Kami-code fff735e
update rotate_cube v1
Kami-code ca21844
update rotate_cube v1
Kami-code 72b54d0
update rotate_cube v1
Kami-code 9644dfb
update rotate_cube v1
Kami-code d21e644
update rotate_cube v1
Kami-code e4cf8a3
update rotate_cube v1
Kami-code 4c5f017
update rotate_cube v1
Kami-code e54ed66
update rotate_cube v1
Kami-code 2d4efd9
update rotate_cube v1
Kami-code 17340be
update rotate_cube v1
Kami-code bed591f
update rotate_cube v1
Kami-code c6bb136
update rotate_cube v1
Kami-code 38c85be
update rotate_cube v1
Kami-code 1065cb1
update rotate_cube v1
Kami-code 7e83882
update rotate_cube v1
Kami-code 696c4e3
update rotate_cube v1
Kami-code e0ba64e
update rotate_cube v1
Kami-code 7c6d1d6
update rotate_cube v1
Kami-code 25bdf7a
update rotate_cube v1
Kami-code caf1407
update rotate_cube v1
Kami-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .trifingerpro import TriFingerPro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
from copy import deepcopy | ||
from typing import List | ||
|
||
import sapien | ||
import torch | ||
|
||
from mani_skill import PACKAGE_ASSET_DIR | ||
from mani_skill.agents.base_agent import BaseAgent | ||
from mani_skill.agents.controllers import * | ||
from mani_skill.agents.registration import register_agent | ||
from mani_skill.agents.utils import ( | ||
get_active_joint_indices, | ||
) | ||
from mani_skill.utils.sapien_utils import ( | ||
get_objs_by_names, | ||
) | ||
from mani_skill.utils.structs.pose import vectorize_pose | ||
|
||
|
||
@register_agent() | ||
class TriFingerPro(BaseAgent): | ||
""" | ||
Modified from https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/main/isaacgymenvs/tasks/trifinger.py | ||
|
||
""" | ||
uid = "trifingerpro" | ||
urdf_path = f"{PACKAGE_ASSET_DIR}/robots/trifinger/trifingerpro.urdf" | ||
urdf_config = dict( | ||
_materials=dict( | ||
tip=dict(static_friction=2.0, dynamic_friction=1.0, restitution=0.0) | ||
), | ||
link=dict( | ||
finger_tip_link_0=dict(material="tip"), | ||
finger_tip_link_120=dict(material="tip"), | ||
finger_tip_link_240=dict(material="tip"), | ||
), | ||
) | ||
sensor_configs = {} | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.joint_names = [ | ||
# "base_to_upper_holder_joint", | ||
# "finger_upper_visuals_joint_0", | ||
# "finger_middle_visuals_joint_0", | ||
# "finger_lower_to_tip_joint_0", | ||
"finger_base_to_upper_joint_0", | ||
"finger_upper_to_middle_joint_0", | ||
"finger_middle_to_lower_joint_0", | ||
# "finger_upper_visuals_joint_120", | ||
# "finger_middle_visuals_joint_120", | ||
# "finger_lower_to_tip_joint_120", | ||
"finger_base_to_upper_joint_120", | ||
"finger_upper_to_middle_joint_120", | ||
"finger_middle_to_lower_joint_120", | ||
# "finger_upper_visuals_joint_240", | ||
# "finger_middle_visuals_joint_240", | ||
# "finger_lower_to_tip_joint_240", | ||
"finger_base_to_upper_joint_240", | ||
"finger_upper_to_middle_joint_240", | ||
"finger_middle_to_lower_joint_240", | ||
# "holder_to_finger_0", | ||
# "holder_to_finger_120", | ||
# "holder_to_finger_240", | ||
] | ||
|
||
self.joint_stiffness = 1e2 | ||
self.joint_damping = 1e1 | ||
self.joint_force_limit = 2e1 | ||
self.tip_link_names = ["finger_tip_link_0", "finger_tip_link_120", "finger_tip_link_240"] | ||
self.root_joint_names = ["finger_base_to_upper_joint_0", "finger_base_to_upper_joint_120", "finger_base_to_upper_joint_240"] | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
def _after_init(self): | ||
self.tip_links: List[sapien.Entity] = get_objs_by_names( | ||
self.robot.get_links(), self.tip_link_names | ||
) | ||
self.root_joints = [ | ||
self.robot.find_joint_by_name(n) for n in self.root_joint_names | ||
] | ||
self.root_joint_indices = get_active_joint_indices( | ||
self.robot, self.root_joint_names | ||
) | ||
|
||
@property | ||
def _controller_configs(self): | ||
# -------------------------------------------------------------------------- # | ||
# Arm | ||
# -------------------------------------------------------------------------- # | ||
joint_pos = PDJointPosControllerConfig( | ||
self.joint_names, | ||
None, | ||
None, | ||
self.joint_stiffness, | ||
self.joint_damping, | ||
self.joint_force_limit, | ||
normalize_action=False, | ||
) | ||
joint_delta_pos = PDJointPosControllerConfig( | ||
self.joint_names, | ||
-0.1, | ||
0.1, | ||
self.joint_stiffness, | ||
self.joint_damping, | ||
self.joint_force_limit, | ||
use_delta=True, | ||
) | ||
joint_target_delta_pos = deepcopy(joint_delta_pos) | ||
joint_target_delta_pos.use_target = True | ||
|
||
# PD joint velocity | ||
pd_joint_vel = PDJointVelControllerConfig( | ||
self.joint_names, | ||
-1.0, | ||
1.0, | ||
self.joint_damping, # this might need to be tuned separately | ||
self.joint_force_limit, | ||
) | ||
|
||
# PD joint position and velocity | ||
joint_pos_vel = PDJointPosVelControllerConfig( | ||
self.joint_names, | ||
None, | ||
None, | ||
self.joint_stiffness, | ||
self.joint_damping, | ||
self.joint_force_limit, | ||
normalize_action=False, | ||
) | ||
joint_delta_pos_vel = PDJointPosVelControllerConfig( | ||
self.joint_names, | ||
-0.1, | ||
0.1, | ||
self.joint_stiffness, | ||
self.joint_damping, | ||
self.joint_force_limit, | ||
use_delta=True, | ||
) | ||
|
||
controller_configs = dict( | ||
pd_joint_delta_pos=dict(joint=joint_delta_pos), | ||
pd_joint_pos=dict(joint=joint_pos), | ||
pd_joint_target_delta_pos=dict(joint=joint_target_delta_pos), | ||
# Caution to use the following controllers | ||
pd_joint_vel=dict(joint=pd_joint_vel), | ||
pd_joint_pos_vel=dict(joint=joint_pos_vel), | ||
pd_joint_delta_pos_vel=dict(joint=joint_delta_pos_vel), | ||
) | ||
|
||
# Make a deepcopy in case users modify any config | ||
return deepcopy_dict(controller_configs) | ||
|
||
def get_proprioception(self): | ||
""" | ||
Get the proprioceptive state of the agent. | ||
""" | ||
obs = super().get_proprioception() | ||
obs.update({"tip_poses": self.tip_poses().view(-1, 21)}) | ||
obs.update({"tip_velocities": self.tip_velocities().view(-1, 9)}) | ||
return obs | ||
|
||
# @property | ||
def tip_poses(self): | ||
Kami-code marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Get the tip pose for each of the finger, three fingers in total | ||
""" | ||
tip_poses = [vectorize_pose(link.pose) for link in self.tip_links] | ||
return torch.stack(tip_poses, dim=-1) | ||
|
||
# @property | ||
def tip_velocities(self): | ||
""" | ||
Get the tip velocity for each of the finger, three fingers in total | ||
""" | ||
tip_velocities = [link.linear_velocity for link in self.tip_links] | ||
return torch.stack(tip_velocities, dim=-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't seem like these assets are in the repo? can you add them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did add it. Isn't it the right place to put it? https://github.com/haosulab/ManiSkill2/blob/7c6d1d64ada6a4c06ce9a23c0a468f85350a74dd/mani_skill/assets/robots/trifinger/trifingerpro.urdf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must have missed the file.