Skip to content

Commit

Permalink
Merge pull request #39 from ARISE-Initiative/demo-fixes
Browse files Browse the repository at this point in the history
adding script changes for new mujoco bindings
  • Loading branch information
yukezhu authored Nov 29, 2022
2 parents 194c336 + bd5a90c commit b54b96c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
Binary file not shown.
12 changes: 8 additions & 4 deletions robosuite/scripts/browse_mjcf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
Loads MJCF XML models from file and renders it on screen.
Example:
$ python browse_arena_model.py --filepath ../models/assets/arenas/table_arena.xml
$ python browse_mjcf_model.py --filepath ../models/assets/arenas/table_arena.xml
"""

import argparse
import os

from mujoco_py import MjSim, MjViewer, load_model_from_path
import mujoco

import robosuite as suite
from robosuite.utils import OpenCVRenderer
from robosuite.utils.binding_utils import MjRenderContext, MjSim

if __name__ == "__main__":

Expand All @@ -21,9 +23,11 @@
parser.add_argument("--filepath", type=str, default=arena_file)
args = parser.parse_args()

model = load_model_from_path(args.filepath)
model = mujoco.MjModel.from_xml_path(args.filepath)
sim = MjSim(model)
viewer = MjViewer(sim)
render_context = MjRenderContext(sim)
sim.add_render_context(render_context)
viewer = OpenCVRenderer(sim)

print("Press ESC to exit...")
while True:
Expand Down
6 changes: 2 additions & 4 deletions robosuite/scripts/collect_human_demonstrations.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""
A script to collect a batch of human demonstrations that can be used
to generate a learning curriculum (see `demo_learning_curriculum.py`).
A script to collect a batch of human demonstrations.
The demonstrations can be played back using the `playback_demonstrations_from_pkl.py`
script.
The demonstrations can be played back using the `playback_demonstrations_from_hdf5.py` script.
"""

import argparse
Expand Down
4 changes: 2 additions & 2 deletions robosuite/scripts/compile_mjcf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
from shutil import copyfile

from mujoco_py import load_model_from_path
import mujoco


def print_usage():
Expand All @@ -31,7 +31,7 @@ def print_usage():
tempfile = os.path.join(input_folder, ".robosuite_temp_model.xml")
copyfile(input_file, tempfile)

model = load_model_from_path(tempfile)
model = mujoco.MjModel.from_xml_path(tempfile)
xml_string = model.get_xml()
with open(output_file, "w") as f:
f.write(xml_string)
Expand Down
4 changes: 2 additions & 2 deletions robosuite/scripts/playback_demonstrations_from_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
--visualize-gripper (optional): If set, will visualize the gripper site
Example:
$ python playback_demonstrations_from_hdf5.py --folder ../models/assets/demonstrations/SawyerPickPlace/
$ python playback_demonstrations_from_hdf5.py --folder ../models/assets/demonstrations/lift/
"""

import argparse
Expand Down Expand Up @@ -59,7 +59,7 @@
while True:
print("Playing back random episode... (press ESC to quit)")

# # select an episode randomly
# select an episode randomly
ep = random.choice(demos)

# read the model xml, using the metadata stored in the attribute for this episode
Expand Down
2 changes: 1 addition & 1 deletion robosuite/scripts/tune_joints.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _toggle_arm(self):
Toggle between arms in the environment to set as current active arm
"""
if isinstance(self.active_robot, SingleArm):
self.active_robot_num = (self.active_robot_num + 1) // self.num_robots
self.active_robot_num = (self.active_robot_num + 1) % self.num_robots
robot = self.active_robot_num
else: # Bimanual case
self.active_arm = "left" if self.active_arm == "right" else "right"
Expand Down

0 comments on commit b54b96c

Please sign in to comment.