From d6f5bc415c5204765606abab6e8b6222bf7eff14 Mon Sep 17 00:00:00 2001 From: elladyr Date: Mon, 26 Aug 2024 01:53:09 -0400 Subject: [PATCH 01/14] Added metrics, fixed osl leg sign to fit defaults --- .../envs/myo/myochallenge/run_track_v0.py | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/myosuite/envs/myo/myochallenge/run_track_v0.py b/myosuite/envs/myo/myochallenge/run_track_v0.py index 8d5c0108..bf880d7d 100644 --- a/myosuite/envs/myo/myochallenge/run_track_v0.py +++ b/myosuite/envs/myo/myochallenge/run_track_v0.py @@ -51,6 +51,12 @@ class RunTrack(WalkEnvV0): OSL_PARAM_LIST = [] OSL_PARAM_SELECT = 0 + # Joint dict + pain_jnt = ['hip_adduction_l', 'hip_adduction_r', 'hip_flexion_l', 'hip_flexion_r', 'hip_rotation_l', 'hip_rotation_r', + 'knee_angle_l', 'knee_angle_l_beta_rotation1', 'knee_angle_l_beta_translation1', 'knee_angle_l_beta_translation2', + 'knee_angle_l_rotation2', 'knee_angle_l_rotation3', 'knee_angle_l_translation1', 'knee_angle_l_translation2', + 'mtp_angle_l', 'ankle_angle_l', 'subtalar_angle_l'] + def __init__(self, model_path, obsd_model_path=None, seed=None, **kwargs): # This flag needs to be here to prevent the simulation from starting in a done state # Before setting the key_frames, the model and opponent will be in the cartesian position, @@ -173,7 +179,9 @@ def get_reward_dict(self, obs_dict): DEFAULT_RWD_KEYS_AND_WEIGHTS dict, or when registering the environment with gym.register in myochallenge/__init__.py """ - act_mag = np.linalg.norm(self.obs_dict['act'], axis=-1)/self.sim.model.na if self.sim.model.na !=0 else 0 + # act_mag = np.linalg.norm(self.obs_dict['act'], axis=-1)/self.sim.model.na if self.sim.model.na !=0 else 0 + act_mag = np.mean( np.square(self.obs_dict['act']) ) if self.sim.model.na !=0 else 0 + pain = self.get_pain() # The task is entirely defined by these 3 lines score = self.get_score() @@ -186,6 +194,7 @@ def get_reward_dict(self, obs_dict): # Optional Keys ('act_reg', act_mag.squeeze()), + ('pain', pain), # Must keys ('sparse', score), ('solved', win_cdt), @@ -200,9 +209,13 @@ def get_metrics(self, paths): """ # average sucess over entire env horizon score = np.mean([np.sum(p['env_infos']['rwd_dict']['sparse']) for p in paths]) + effort = np.mean([np.sum(p['env_infos']['rwd_dict']['act_reg']) for p in paths]) + pain = np.mean([np.sum(p['env_infos']['rwd_dict']['pain']) for p in paths]) metrics = { - 'score': score, + 'score': score, # Distance travelled + 'effort': effort, + 'pain': pain, } return metrics @@ -395,6 +408,15 @@ def get_score(self): score = (y_pos - 15) / (- 15 - 15) return score.squeeze() + def get_pain(self): + if not self.startFlag: + return -1 + + pain_score = 0 + for joint in self.pain_jnt: + pain_score += np.abs(self.get_limitfrc(joint).squeeze()) + return pain_score + def _get_muscle_lengthRange(self): return self.sim.model.actuator_lengthrange.copy() @@ -449,6 +471,14 @@ def _get_fallen_condition(self): else: return 0 + def get_limitfrc(self, joint_name): + non_joint_limit_efc_idxs = np.where(self.sim.data.efc_type != self.sim.lib.mjtConstraint.mjCNSTR_LIMIT_JOINT)[0] + only_jnt_lim_efc_force = self.sim.data.efc_force.copy() + only_jnt_lim_efc_force[non_joint_limit_efc_idxs] = 0.0 + joint_force = np.zeros((self.sim.model.nv,)) + self.sim.lib.mj_mulJacTVec(self.sim.model._model, self.sim.data._data, joint_force, only_jnt_lim_efc_force) + return joint_force[self.sim.model.joint(joint_name).dofadr] + def get_internal_qpos(self): temp_qpos = self.sim.data.qpos.copy() to_remove = [self.sim.model.joint('osl_knee_angle_r').qposadr[0].copy(), self.sim.model.joint('osl_ankle_angle_r').qposadr[0].copy()] @@ -659,6 +689,6 @@ def get_osl_sens(self): osl_sens_data['knee_vel'] = self.sim.data.joint('osl_knee_angle_r').qvel[0].copy() osl_sens_data['ankle_angle'] = self.sim.data.joint('osl_ankle_angle_r').qpos[0].copy() osl_sens_data['ankle_vel'] = self.sim.data.joint('osl_ankle_angle_r').qvel[0].copy() - osl_sens_data['load'] = self.sim.data.sensor('r_socket_load').data[1].copy() # Only vertical + osl_sens_data['load'] = -1*self.sim.data.sensor('r_osl_load').data[1].copy() # Only vertical return osl_sens_data From 8dd766844a9115fecb75869d0869b578808b686e Mon Sep 17 00:00:00 2001 From: elladyr Date: Tue, 27 Aug 2024 14:10:28 -0400 Subject: [PATCH 02/14] Removed translation joints from pain metric --- myosuite/envs/myo/myochallenge/run_track_v0.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/myosuite/envs/myo/myochallenge/run_track_v0.py b/myosuite/envs/myo/myochallenge/run_track_v0.py index bf880d7d..2e84ee82 100644 --- a/myosuite/envs/myo/myochallenge/run_track_v0.py +++ b/myosuite/envs/myo/myochallenge/run_track_v0.py @@ -53,8 +53,7 @@ class RunTrack(WalkEnvV0): # Joint dict pain_jnt = ['hip_adduction_l', 'hip_adduction_r', 'hip_flexion_l', 'hip_flexion_r', 'hip_rotation_l', 'hip_rotation_r', - 'knee_angle_l', 'knee_angle_l_beta_rotation1', 'knee_angle_l_beta_translation1', 'knee_angle_l_beta_translation2', - 'knee_angle_l_rotation2', 'knee_angle_l_rotation3', 'knee_angle_l_translation1', 'knee_angle_l_translation2', + 'knee_angle_l', 'knee_angle_l_rotation2', 'knee_angle_l_rotation3', 'mtp_angle_l', 'ankle_angle_l', 'subtalar_angle_l'] def __init__(self, model_path, obsd_model_path=None, seed=None, **kwargs): @@ -414,8 +413,8 @@ def get_pain(self): pain_score = 0 for joint in self.pain_jnt: - pain_score += np.abs(self.get_limitfrc(joint).squeeze()) - return pain_score + pain_score += np.clip(np.abs(self.get_limitfrc(joint).squeeze()), -1000, 1000) + return pain_score / len(self.pain_jnt) def _get_muscle_lengthRange(self): return self.sim.model.actuator_lengthrange.copy() From 0f50ca529e6f0bee5b8b0b50dfe28328abf56971 Mon Sep 17 00:00:00 2001 From: elladyr Date: Fri, 30 Aug 2024 03:09:54 -0400 Subject: [PATCH 03/14] Added a patch for remapping muscle actions --- myosuite/envs/myo/myochallenge/run_track_v0.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/myosuite/envs/myo/myochallenge/run_track_v0.py b/myosuite/envs/myo/myochallenge/run_track_v0.py index 2e84ee82..0479883f 100644 --- a/myosuite/envs/myo/myochallenge/run_track_v0.py +++ b/myosuite/envs/myo/myochallenge/run_track_v0.py @@ -87,6 +87,7 @@ def _setup(self, real_width=1, distance_thr = 10, init_pose_path=None, + remap_required=False, **kwargs, ): @@ -94,6 +95,7 @@ def _setup(self, # Terrain type self.terrain_type = TrackTypes.FLAT.value + self.remap_required = remap_required # Env initialization with data if init_pose_path is not None: file_path = os.path.join(init_pose_path) @@ -666,6 +668,11 @@ def _prepareActions(self, mus_actions): Only considers the 54 muscles of the OSLMyoleg model """ + if self.remap_required: + if np.any( (mus_actions < -1) | (mus_actions > 1) ): + raise ValueError("Input value should be between -1 and 1") + mus_actions = (mus_actions + 1) / 2 + full_actions = np.zeros(self.sim.model.nu,) full_actions[0:self.sim.model.na] = mus_actions[0:self.sim.model.na].copy() From deebe43b3c6472d884761e1aa30a5c68dc4f87d7 Mon Sep 17 00:00:00 2001 From: Vikash Kumar Date: Fri, 30 Aug 2024 14:45:17 -0400 Subject: [PATCH 04/14] FEATURE: adding support for MyoSkeleton --- myosuite_init.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 6 ++++ 2 files changed, 90 insertions(+) create mode 100644 myosuite_init.py diff --git a/myosuite_init.py b/myosuite_init.py new file mode 100644 index 00000000..5d8ed4ec --- /dev/null +++ b/myosuite_init.py @@ -0,0 +1,84 @@ +import os +import shutil +from os.path import expanduser + +import git + +curr_dir = os.path.dirname(os.path.abspath(__file__)) +simhive_path = os.path.join(curr_dir, 'myosuite', 'simhive') + + +# from myosuite.utils.import_utils import fetch_git + +def fetch_git(repo_url, commit_hash, clone_directory, clone_path=None): + """ + fetch git repo using provided details + """ + if clone_path is None: + clone_path = os.path.join(expanduser("~"), ".myosuite") + clone_directory = os.path.join(clone_path, clone_directory) + + try: + # Create the clone directory if it doesn't exist + os.makedirs(clone_directory, exist_ok=True) + + # Clone the repository to the specified path + if not os.path.exists(os.path.join(clone_directory,'.git')): + repo = git.Repo.clone_from(repo_url, clone_directory) + print(f"{repo_url} cloned at {clone_directory}") + else: + repo = git.Repo(clone_directory) + origin = repo.remote('origin') + origin.fetch() + + # Check out the specific commit if not already + current_commit_hash = repo.head.commit.hexsha + if current_commit_hash != commit_hash: + repo.git.checkout(commit_hash) + print(f"{repo_url}@{commit_hash} fetched at {clone_directory}") + except git.GitCommandError as e: + print(f"Error: {e}") + + return clone_directory + + +def clean_simhive(): + """ + Remove cached simhive if it exists + """ + print("MyoSuite:> Clearing SimHive ...") + api_path = os.path.join(simhive_path, 'myo_model') + if os.path.exists(api_path): + shutil.rmtree(api_path) + else: + print("MyoSuite:> SimHive/myo_model directory does not exist.") + print("MyoSuite:> SimHive cleared") + + +def fetch_simhive(): + """ + fetch a copy of simhive + """ + print("MyoSuite:> Initializing...") + + # Mark the SimHive version (ToDo: Remove this when commits hashes are auto fetched from submodules) + __version__ = "2.5.0" + + # Fetch SimHive + print("MyoSuite:> Downloading simulation assets (upto ~300MBs)") + fetch_git(repo_url="https://github.com/myolab/myo_model.git", + commit_hash="619b1a876113e91a302b9baeaad6c2341e12ac81", + clone_directory="myo_model", + clone_path=simhive_path) + + + # mark successful creation of simhive + filename = os.path.join(simhive_path, "simhive-version") + with open(filename, 'w') as file: + file.write(__version__) + + print("MyoSuite:> Successfully Initialized.") + + +if __name__ == "__main__": + fetch_simhive() \ No newline at end of file diff --git a/setup.py b/setup.py index b6bc4ab4..baa0af91 100644 --- a/setup.py +++ b/setup.py @@ -56,4 +56,10 @@ def package_files(directory): packages=find_packages(exclude=("myosuite.agents")), python_requires=">=3.8", install_requires=fetch_requirements(), + entry_points={ + 'console_scripts': [ + 'myoapi_init = myosuite_init:fetch_simhive', + 'myoapi_clean = myosuite_init:clean_simhive', + ], + }, ) From 76a33c7d0a1ca9085c0e8ab9d25e5c64c568a80a Mon Sep 17 00:00:00 2001 From: Vikash Kumar Date: Fri, 30 Aug 2024 14:54:53 -0400 Subject: [PATCH 05/14] FEATURE: Acknoledge license --- myosuite_init.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/myosuite_init.py b/myosuite_init.py index 5d8ed4ec..829b03bd 100644 --- a/myosuite_init.py +++ b/myosuite_init.py @@ -55,6 +55,26 @@ def clean_simhive(): print("MyoSuite:> SimHive cleared") +def accept_license(): + prompt = """ +A permissive license for non-commercial scientific research is available. +You can review the license at: https://github.com/myolab/myo_model/blob/main/LICENSE + +Do you accept the terms of the license? (yes/no): +""" + response = input(prompt).strip().lower() + + if response == 'yes': + print("Thank you for accepting the license. You may proceed.") + return True + elif response == 'no': + print("You have rejected the license terms. Exiting...") + return False + else: + print("Invalid input. Please enter 'yes' or 'no'.") + return accept_license() # Recursively prompt again for valid input + + def fetch_simhive(): """ fetch a copy of simhive @@ -64,8 +84,17 @@ def fetch_simhive(): # Mark the SimHive version (ToDo: Remove this when commits hashes are auto fetched from submodules) __version__ = "2.5.0" + # Inform user about API + if accept_license(): + # Proceed with the rest of the code + print("MyoSuite:> License accepted. Proceeding initialization ...") + else: + # Exit or handle the rejection case + print("MyoSuite:> License rejected. Exiting") + return + # Fetch SimHive - print("MyoSuite:> Downloading simulation assets (upto ~300MBs)") + print("MyoSuite:> Downloading simulation assets (upto ~100MBs)") fetch_git(repo_url="https://github.com/myolab/myo_model.git", commit_hash="619b1a876113e91a302b9baeaad6c2341e12ac81", clone_directory="myo_model", From efe63faad99f6eb870e4cd679dd55d6f187ae160 Mon Sep 17 00:00:00 2001 From: Vittorio-Caggiano Date: Fri, 30 Aug 2024 16:56:31 -0400 Subject: [PATCH 06/14] add ci test --- .github/workflows/python-app.yml | 8 ++++++-- myosuite/tests/test_myoapi.py | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 myosuite/tests/test_myoapi.py diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 7f12a607..44694567 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -82,7 +82,7 @@ jobs: # if: ${{ runner.os == 'macOS' }} # run: | # brew install --cask xquartz -# brew install hdf5 +# brew install hdf5 # export CPATH="/opt/homebrew/include/" # export HDF5_DIR=/opt/homebrew/ # pip3 install h5py --only-binary h5py @@ -97,9 +97,13 @@ jobs: if: ${{ runner.os == 'Linux' }} run: python3 -m mujoco.render_test - - name: Run Test environment + - name: Test myoapi run: | conda activate $CONDA_DEFAULT_ENV + python3-m myosuite.tests.test_myo + + - name: Run Test environment + run: | python3 -m myosuite.tests.test_myo - name: Install ffmpeg diff --git a/myosuite/tests/test_myoapi.py b/myosuite/tests/test_myoapi.py new file mode 100644 index 00000000..4e7281d9 --- /dev/null +++ b/myosuite/tests/test_myoapi.py @@ -0,0 +1,25 @@ + +from pathlib import Path +from unittest.mock import patch + +from myosuite_init import fetch_simhive + +my_file = Path("/path/to/file") + +@patch('builtins.input', side_effect=['no']) +def test_no_myoapi(mock_input): + print("mock_input", mock_input.side_effect) + fetch_simhive() + assert not Path("myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml").exists() + +@patch('builtins.input', side_effect=['yes']) +def test_yes_myoapi(mock_input): + print("mock_input", mock_input.side_effect) + fetch_simhive() + assert Path("myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml").exists() + +test_no_myoapi() +test_yes_myoapi() + + + From a15c51f6166743cdba23e75c570da0b8be7b36b4 Mon Sep 17 00:00:00 2001 From: Vittorio Caggiano Date: Wed, 13 Dec 2023 07:29:53 -0600 Subject: [PATCH 07/14] update doc with gym/gymnasium aspecific import --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 44694567..c8c3a6fc 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -100,7 +100,7 @@ jobs: - name: Test myoapi run: | conda activate $CONDA_DEFAULT_ENV - python3-m myosuite.tests.test_myo + python3 -m myosuite.tests.test_myo - name: Run Test environment run: | From e2408d11f0f0ec0c41146cb4e001134446ea3128 Mon Sep 17 00:00:00 2001 From: Vittorio-Caggiano Date: Fri, 30 Aug 2024 17:02:00 -0400 Subject: [PATCH 08/14] add --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index c8c3a6fc..0bf6df2f 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -100,7 +100,7 @@ jobs: - name: Test myoapi run: | conda activate $CONDA_DEFAULT_ENV - python3 -m myosuite.tests.test_myo + python3 -m myosuite.tests.test_myoapi - name: Run Test environment run: | From eb0d03f04de6aa35d6c33d633402a620d1a35143 Mon Sep 17 00:00:00 2001 From: Vittorio Caggiano Date: Wed, 13 Dec 2023 07:29:53 -0600 Subject: [PATCH 09/14] update doc with gym/gymnasium aspecific import --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4509693e..25b5af21 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Test your installation using the following command (this will return also a list ``` bash python -m myosuite.tests.test_myo ``` - + You can also visualize the environments with random controls using the command below: ``` bash @@ -57,7 +57,10 @@ python -m myosuite.utils.examine_env --env_name myoElbowPose1D6MRandom-v0 mjpython -m myosuite.utils.examine_env --env_name myoElbowPose1D6MRandom-v0 ``` - +It is possible to take advantage of the latest MyoSkeleton. Once added (follow the instructions prompted by `python myosuite_init.py`), run: +``` bash +python myosuite/utils/examine_sim.py -s myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml +``` ## Examples It is possible to create and interface with MyoSuite environments just like any other OpenAI gym environments. For example, to use the `myoElbowPose1D6MRandom-v0` environment, it is possible simply to run: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1zFuNLsrmx42vT4oV8RbnEWtkSJ1xajEo) @@ -74,7 +77,7 @@ for _ in range(1000): env.close() ``` -You can find our [tutorials](https://github.com/myohub/myosuite/tree/main/docs/source/tutorials#tutorials) on the general features and the **ICRA2023 Colab Tutorial** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1KGqZgSYgKXF-vaYC33GR9llDsIW9Rp-q) **ICRA2024 Colab Tutorial** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1JwxE7o6Z3bqCT4ewELacJ-Z1SV8xFhKK#scrollTo=QDppGIzHB9Zu) +You can find our [tutorials](https://github.com/myohub/myosuite/tree/main/docs/source/tutorials#tutorials) on the general features and the **ICRA2023 Colab Tutorial** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1KGqZgSYgKXF-vaYC33GR9llDsIW9Rp-q) **ICRA2024 Colab Tutorial** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1JwxE7o6Z3bqCT4ewELacJ-Z1SV8xFhKK#scrollTo=QDppGIzHB9Zu) on how to load MyoSuite models/tasks, train them, and visualize their outcome. Also, you can find [baselines](https://github.com/myohub/myosuite/tree/main/myosuite/agents) to test some pre-trained policies. From e2db072356e364ef7052e42f7440ef4440ea162f Mon Sep 17 00:00:00 2001 From: Vittorio Caggiano Date: Sun, 1 Sep 2024 08:54:51 -0400 Subject: [PATCH 10/14] 2.6.0 release --- myosuite/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myosuite/version.py b/myosuite/version.py index 0158a4eb..2d679ff6 100644 --- a/myosuite/version.py +++ b/myosuite/version.py @@ -1 +1 @@ -__version_tuple__ = (2, 5, 0) +__version_tuple__ = (2, 6, 0) From 2d2469db2fb7829cb9d2f8fd76b48294b950986b Mon Sep 17 00:00:00 2001 From: Vittorio Caggiano Date: Sun, 1 Sep 2024 13:20:34 -0400 Subject: [PATCH 11/14] 2.7.0 release --- myosuite/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myosuite/version.py b/myosuite/version.py index 2d679ff6..d32caa42 100644 --- a/myosuite/version.py +++ b/myosuite/version.py @@ -1 +1 @@ -__version_tuple__ = (2, 6, 0) +__version_tuple__ = (2, 7, 0) From dd8e21f2b3e7f6e0352ee3ea608fdeb964b999a5 Mon Sep 17 00:00:00 2001 From: Vittorio-Caggiano Date: Tue, 3 Sep 2024 13:33:12 -0400 Subject: [PATCH 12/14] fix setup and installation instruction for myoskeleton --- README.md | 2 +- setup.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 25b5af21..35efe866 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ python -m myosuite.utils.examine_env --env_name myoElbowPose1D6MRandom-v0 mjpython -m myosuite.utils.examine_env --env_name myoElbowPose1D6MRandom-v0 ``` -It is possible to take advantage of the latest MyoSkeleton. Once added (follow the instructions prompted by `python myosuite_init.py`), run: +It is possible to take advantage of the latest MyoSkeleton. Once added (follow the instructions prompted by `python -m myosuite_init`), run: ``` bash python myosuite/utils/examine_sim.py -s myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml ``` diff --git a/setup.py b/setup.py index baa0af91..00231870 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,8 @@ import os -import sys import re -from setuptools import setup, find_packages +import sys + +from setuptools import find_packages, setup if sys.version_info.major != 3: print("This Python is only compatible with Python 3, but you are running " @@ -52,7 +53,7 @@ def package_files(directory): "Topic :: Scientific/Engineering :: Artificial Intelligence ", "Operating System :: OS Independent", ], - package_data={'': mjc_models_files}, + package_data={'': mjc_models_files+['../myosuite_init.py']}, packages=find_packages(exclude=("myosuite.agents")), python_requires=">=3.8", install_requires=fetch_requirements(), From a6d2bea6380b5fe211780ac6d781f6e184518f39 Mon Sep 17 00:00:00 2001 From: Vittorio-Caggiano Date: Tue, 3 Sep 2024 13:42:29 -0400 Subject: [PATCH 13/14] fix python call --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35efe866..e5114f47 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ mjpython -m myosuite.utils.examine_env --env_name myoElbowPose1D6MRandom-v0 It is possible to take advantage of the latest MyoSkeleton. Once added (follow the instructions prompted by `python -m myosuite_init`), run: ``` bash -python myosuite/utils/examine_sim.py -s myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml +python -m myosuite.utils.examine_sim -s myosuite/simhive/myo_model/myoskeleton/myoskeleton.xml ``` ## Examples From 93d46671df211f18e9fa53e79d7733318908f790 Mon Sep 17 00:00:00 2001 From: elladyr Date: Wed, 4 Sep 2024 18:52:12 -0400 Subject: [PATCH 14/14] Apply time metric --- myosuite/envs/myo/myochallenge/run_track_v0.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/myosuite/envs/myo/myochallenge/run_track_v0.py b/myosuite/envs/myo/myochallenge/run_track_v0.py index 0479883f..968af163 100644 --- a/myosuite/envs/myo/myochallenge/run_track_v0.py +++ b/myosuite/envs/myo/myochallenge/run_track_v0.py @@ -209,12 +209,14 @@ def get_metrics(self, paths): Evaluate paths and report metrics """ # average sucess over entire env horizon + times = np.mean([np.round(p['env_infos']['obs_dict']['time'][-1], 5) for p in paths]) score = np.mean([np.sum(p['env_infos']['rwd_dict']['sparse']) for p in paths]) effort = np.mean([np.sum(p['env_infos']['rwd_dict']['act_reg']) for p in paths]) pain = np.mean([np.sum(p['env_infos']['rwd_dict']['pain']) for p in paths]) metrics = { 'score': score, # Distance travelled + 'Time': times, 'effort': effort, 'pain': pain, }