Skip to content

Commit

Permalink
🎮 Add hotu_humanoid_w_hand MJCF model
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylark0924 committed Nov 17, 2023
1 parent 3b6a596 commit ec95dbc
Show file tree
Hide file tree
Showing 22 changed files with 1,998 additions and 904 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def inference(custom_args):
gpu_id = 1

parser = argparse.ArgumentParser()
parser.add_argument("--config_name", type=str, default="HumanoidSpoonPanSimple")
parser.add_argument("--motion_file", type=str, default="../hotu/024_amp_3.npy")
parser.add_argument("--config_name", type=str, default="HOTU_Humanoid")
parser.add_argument("--motion_file", type=str, default="/home/ubuntu/Data/2023_11_15_HED/has_gloves/New Session-009_amp.npy")
custom_args = parser.parse_args()

inference(custom_args)
16 changes: 13 additions & 3 deletions examples/simulator/example_robot_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# CURIminisim.show()

# franka
args = rf.config.get_sim_config("Franka")
frankasim = rf.sim.FrankaSim(args)
frankasim.show()
# args = rf.config.get_sim_config("Franka")
# frankasim = rf.sim.FrankaSim(args)
# frankasim.show()

# baxter
# args = rf.config.get_sim_config("Baxter")
Expand All @@ -42,6 +42,16 @@
# Gluonsim = rf.sim.GluonSim(args)
# Gluonsim.show()

# # qbsofthand
# args = rf.config.get_sim_config("QbSoftHand")
# QbSoftHandsim = rf.sim.QbSoftHandSim(args)
# QbSoftHandsim.show()

# Humanoid
args = rf.config.get_sim_config("Humanoid")
Humanoidsim = rf.sim.HumanoidSim(args)
Humanoidsim.show()

# TODO: Multi Robots
# curi_args = rf.config.get_sim_config("CURI")
# CURIsim = rf.sim.CURISim(curi_args)
Expand Down
6 changes: 3 additions & 3 deletions rofunc/config/simulator/Humanoid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ env:
asset:
robot_name: "Humanoid"
assetRoot:
assetFile: "mjcf/amp_humanoid.xml"
init_pose: [0.0, 1.8, 0.0, 0.0, 0.0, 0.0, 1]
fix_base_link: False
assetFile: "mjcf/hotu_humanoid_w_hand.xml"
init_pose: [0.0, 0.0, 1.8, 0.0, 0.0, 0.0, 1]
fix_base_link: True
flip_visual_attachments: False
armature: 0.01

Expand Down
43 changes: 43 additions & 0 deletions rofunc/config/simulator/QbSoftHand.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: QbSoftHand

physics_engine: 'physx' # 'physx' or 'flex'
graphics_device_id: 0
sim_device: 'cuda:0'

env:
numEnvs: 1
envSpacing: 3.

asset:
robot_name: "QbSoftHand"
assetRoot:
assetFile: "urdf/curi/urdf/qbhand_right.xml"
# assetFile: "urdf/curi/urdf/qbhand_right.urdf"
init_pose: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]
fix_base_link: True
flip_visual_attachments: False
armature: 0.01

object_asset:

sim:
dt: 0.0166 # 1/60
substeps: 1
up_axis: "Z"
use_gpu_pipeline: False
gravity: ${if:${eq:${.up_axis}, "Y"}, [0, -9.81, 0], [0, 0, -9.81]}
physx:
num_threads: 4 # Number of worker threads per scene used by PhysX - for CPU PhysX only.
solver_type: 1 # 0: pgs, 1: tgs
use_gpu: False # set to False to run on CPU
num_position_iterations: 12
num_velocity_iterations: 1
contact_offset: 0.005
rest_offset: 0.0
bounce_threshold_velocity: 0.2
max_depenetration_velocity: 1000.0
num_subscenes: 4 # Splits the simulation into N physics scenes and runs each one in a separate thread
contact_collection: 0 # 0: CC_NEVER (don't collect contact info), 1: CC_LAST_SUBSTEP (collect only contacts on last substep), 2: CC_ALL_SUBSTEPS (default - all contacts)
friction_offset_threshold: 0.001
friction_correlation_distance: 0.0005

7 changes: 7 additions & 0 deletions rofunc/config/view_motion/HOTU_Humanoid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class_name: HumanoidViewMotion
asset_name: "mjcf/hotu_humanoid.xml"
asset_body_num: 15
asset_joint_num: 34

keyBodies: ["right_hand", "left_hand", "right_foot", "left_foot"]
contactBodies: ["right_foot", "left_foot"]
18 changes: 5 additions & 13 deletions rofunc/learning/RofuncRL/tasks/isaacgym/ase/humanoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from isaacgym import gymtorch
from isaacgym.torch_utils import *

import rofunc as rf
from rofunc.utils.oslab.path import get_rofunc_path
from rofunc.learning.RofuncRL.tasks.isaacgym.base.vec_task import VecTask
from rofunc.learning.RofuncRL.tasks.utils import torch_jit_utils as torch_utils
Expand Down Expand Up @@ -240,16 +241,12 @@ def _setup_character_props(self, key_bodies):
second part is the observations for all bodies. The body number is multiplied by (3 position values, 6
orientation values, 3 linear velocity, and 3 angular velocity); finally, -3 stands for
Args:
key_bodies:
Returns:
:param key_bodies:
"""
# asset_body_num = self.cfg["env"]["asset"]["assetBodyNum"]
# asset_joint_num = self.cfg["env"]["asset"]["assetJointNum"]
asset_file = self.cfg["env"]["asset"]["assetFileName"]
num_key_bodies = len(key_bodies)
# num_key_bodies = len(key_bodies)

# The following are: body_name (body_id/body's joint num to its parent/offset pair)
# if asset_body_num == 15:
Expand Down Expand Up @@ -329,25 +326,20 @@ def _setup_character_props(self, key_bodies):
self._dof_obs_size = 72
self._num_actions = 28
self._num_obs = 1 + 15 * (3 + 6 + 3 + 3) - 3

elif asset_file == "mjcf/amp_humanoid_sword_shield.xml":
self._dof_body_ids = [1, 2, 3, 4, 5, 7, 8, 11, 12, 13, 14, 15, 16]
self._dof_offsets = [0, 3, 6, 9, 10, 13, 16, 17, 20, 21, 24, 27, 28, 31]
self._dof_obs_size = 78
self._num_actions = 31
self._num_obs = 1 + 17 * (3 + 6 + 3 + 3) - 3

elif asset_file == "mjcf/amp_humanoid_spoon_pan_fixed.xml":
elif asset_file in ["mjcf/amp_humanoid_spoon_pan_fixed.xml", "mjcf/hotu_humanoid.xml"]:
self._dof_body_ids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] # len=14
self._dof_offsets = [0, 3, 6, 9, 10, 13, 16, 17, 20, 23, 24, 27, 30, 31, 34] # len=14+1
self._dof_obs_size = 84
self._num_actions = 34
self._num_obs = 1 + 15 * (3 + 6 + 3 + 3) - 3

else:
assert print(f"Unsupported character config file: {asset_file}")

return
raise rf.logger.beauty_print(f"Unsupported character config file: {asset_file}")

def _build_termination_heights(self):
head_term_height = 0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _setup_character_props(self, key_bodies):
self._num_amp_obs_per_step = 13 + self._dof_obs_size + 28 + 3 * num_key_bodies # [root_h, root_rot, root_vel, root_ang_vel, dof_pos, dof_vel, key_body_pos]
elif asset_file == "mjcf/amp_humanoid_sword_shield.xml":
self._num_amp_obs_per_step = 13 + self._dof_obs_size + 31 + 3 * num_key_bodies # [root_h, root_rot, root_vel, root_ang_vel, dof_pos, d
elif asset_file == "mjcf/amp_humanoid_spoon_pan_fixed.xml":
elif asset_file in ["mjcf/amp_humanoid_spoon_pan_fixed.xml", "mjcf/hotu_humanoid.xml"]:
self._num_amp_obs_per_step = 13 + self._dof_obs_size + 34 + 3 * num_key_bodies
else:
print(f"Unsupported humanoid body num: {asset_file}")
Expand Down
1 change: 1 addition & 0 deletions rofunc/learning/RofuncRL/trainers/ase_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def pre_interaction(self):
elif not self.hrl:
if self.collect_observation is not None: # Reset failed envs
obs_dict, done_env_ids = self.env.reset_done()
obs_dict, done_env_ids = self.agent.multi_gpu_transfer(obs_dict, done_env_ids)
self.agent._current_states = obs_dict["obs"]
if len(done_env_ids) > 0:
self._reset_latents(done_env_ids)
Expand Down
2 changes: 2 additions & 0 deletions rofunc/simulator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
from .gluon_sim import GluonSim
from .multirobot_sim import MultiRobotSim
from .human_sim import HumanSim
from .humanoid_sim import HumanoidSim
from .qbsofthand_sim import QbSoftHandSim
from .utils.xsens2urdf import xsens2urdf
Loading

0 comments on commit ec95dbc

Please sign in to comment.