Skip to content

Instantly share code, notes, and snippets.

@iandanforth
Created February 22, 2019 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandanforth/04521ba10decdedc6c46579b9804a833 to your computer and use it in GitHub Desktop.
Save iandanforth/04521ba10decdedc6c46579b9804a833 to your computer and use it in GitHub Desktop.
XML viewer for DeepMind Control Suite
from __future__ import absolute_import
from dm_control import mujoco
from dm_control.rl import control
from dm_control.suite import base
from dm_control.suite import common
from dm_control.utils import containers
SUITE = containers.TaggedTasks()
@SUITE.add()
def empty(xml):
xml_string = common.read_model(xml)
physics = mujoco.Physics.from_xml_string(xml_string, common.ASSETS)
task = EmptyTask()
env = control.Environment(physics, task)
return env
class EmptyTask(base.Task):
def initialize_episode(self, physics):
pass
def get_observation(self, physics):
return dict()
def get_reward(self, physics):
return 0.0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from absl import app
from dm_control import viewer
from dm_control.suite import empty
def main(argv):
if len(argv) < 2:
raise Exception("Required positional argument missing. Example Usage: python xml-explore.py cheetah.xml")
xml_file = argv[1]
task_kwargs = dict(
xml=xml_file
)
def loader():
env = empty.SUITE["empty"](**task_kwargs)
return env
viewer.launch(loader)
if __name__ == '__main__':
app.run(main)
@iandanforth
Copy link
Author

Please note this could be made into a single file quite easily. This tries to preserve a minimum of structure in case you want to build back up to an actual dm_control Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment