Created
February 22, 2019 02:32
-
-
Save iandanforth/04521ba10decdedc6c46579b9804a833 to your computer and use it in GitHub Desktop.
XML viewer for DeepMind Control Suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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