From 43c4a29c10043d34238e3c1caac754a0c73f59fd Mon Sep 17 00:00:00 2001 From: Chenzui Li Date: Thu, 21 Nov 2024 05:42:09 +0000 Subject: [PATCH] fix some bugs --- rofunc/config/simulator/Humanoid.yaml | 7 ++++++- .../config/view_motion/HOTUHumanoidWQbhandNew.yaml | 12 +++++++----- .../tasks/isaacgymenv/ase/humanoid_view_motion.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/rofunc/config/simulator/Humanoid.yaml b/rofunc/config/simulator/Humanoid.yaml index 3c5af1767..5b77ce682 100644 --- a/rofunc/config/simulator/Humanoid.yaml +++ b/rofunc/config/simulator/Humanoid.yaml @@ -5,7 +5,7 @@ graphics_device_id: 0 sim_device: 'cuda:0' env: - numEnvs: 16 + numEnvs: 1 envSpacing: 1 numEnvPerRow: 1 @@ -18,6 +18,11 @@ env: # to anything > 0 will disable all self collisions. collision_mode: -1 + mani: + enable: True + export_link: ... + vis: True + asset: robot_name: "Humanoid" assetRoot: diff --git a/rofunc/config/view_motion/HOTUHumanoidWQbhandNew.yaml b/rofunc/config/view_motion/HOTUHumanoidWQbhandNew.yaml index 3185135fe..b20e62df2 100644 --- a/rofunc/config/view_motion/HOTUHumanoidWQbhandNew.yaml +++ b/rofunc/config/view_motion/HOTUHumanoidWQbhandNew.yaml @@ -9,17 +9,19 @@ env: # animation files to learn from # motion_file: "examples/data/hotu2/20240509/all_hotu_motion.yaml" # motion_file: "examples/data/hotu2/20240509/Ramdom (good)_Take 2024-05-09 04.49.16 PM_optitrack2hotu.npy" - motion_file: "examples/data/hotu2/20240509/Jumping_Take 2024-05-09 04.15.38 PM_optitrack2hotu.npy" + motion_file: "examples/data/hotu2/demo_2_test_chenzui_only_optitrack2hotu.npy" use_extra_dof_states_motion: False - motion_file_asset: "mjcf/hotu/hotu_humanoid_w_qbhand_full_new.xml" +# motion_file_asset: "mjcf/hotu/hotu_humanoid_w_qbhand_full_new.xml" + motion_file_asset: "mjcf/hotu/hotu_humanoid.xml" object_motion_file: asset: # assetFileName: "mjcf/hotu/hotu_humanoid_w_qbhand_full_new.xml" - assetFileName: "mjcf/hotu/hotu_humanoid_w_qbhand_full_new.xml" +# assetFileName: "mjcf/hotu/hotu_humanoid_w_qbhand_full_new.xml" + assetFileName: "mjcf/hotu/hotu_humanoid.xml" use_object_motion: False object_asset: @@ -28,8 +30,8 @@ env: assetSize: # List of object size, used for scaling the object and creating the box objects task: - wb_decompose: True # if True, decompose the whole body into parts + wb_decompose: False # if True, decompose the whole body into parts wb_decompose_parameter: parts: ["body"] # parts: [ "hands", "upper_body", "lower_body" ] - use_synergy: True # if True, use the synergy for the hand \ No newline at end of file + use_synergy: False # if True, use the synergy for the hand \ No newline at end of file diff --git a/rofunc/learning/RofuncRL/tasks/isaacgymenv/ase/humanoid_view_motion.py b/rofunc/learning/RofuncRL/tasks/isaacgymenv/ase/humanoid_view_motion.py index 324d3b5c7..b495425e8 100644 --- a/rofunc/learning/RofuncRL/tasks/isaacgymenv/ase/humanoid_view_motion.py +++ b/rofunc/learning/RofuncRL/tasks/isaacgymenv/ase/humanoid_view_motion.py @@ -27,6 +27,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import torch +import csv from isaacgym import gymtorch @@ -43,6 +44,7 @@ def __init__( headless, virtual_screen_capture, force_render, + csv_path ): self.cfg = cfg control_freq_inv = cfg["env"]["controlFrequencyInv"] @@ -68,6 +70,10 @@ def __init__( ) self._motion_ids = torch.remainder(self._motion_ids, num_motions) + # Initialize CSV writing + self.csv_file = open(csv_path, 'w', newline='') + self.csv_writer = csv.writer(self.csv_file) + def pre_physics_step(self, actions): self.actions = actions.to(self.device).clone() @@ -101,6 +107,10 @@ def _motion_sync(self): key_pos, ) = self._motion_lib.get_motion_state(motion_ids, motion_times) + # Convert torch tensor to a list and write to CSV + dof_pos_list = dof_pos.tolist() + self.csv_writer.writerows(dof_pos_list) + root_vel = torch.zeros_like(root_vel) root_ang_vel = torch.zeros_like(root_ang_vel) dof_vel = torch.zeros_like(dof_vel)