Giter Club home page Giter Club logo

Comments (9)

axnedergaard avatar axnedergaard commented on May 18, 2024 2

@huiwenzhang @DanielTakeshi It is really easy, at least for a simple environment:

Create files suite/new_domain.xml and suite/new_domain.py. The .xml file should contain your MuJoCo model in the MJCF format. Have a look at rl/control.py to see what your domain class in suite/new_domain.py must implement, note that some functions are already implemented in suite/base.py. You can also look at some other simple environments (e.g. cartpoly.py and humanoid.py) to get a feeling. You can find a minimalistic example of a suite/robot.py file for a 'robot' domain with a 'test' task below.

"""Robot Domain."""

import collections

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

_DEFAULT_TIME_LIMIT = 30
_CONTROL_TIMESTEP = .04

SUITE = containers.TaggedTasks()

def get_model_and_assets():
  """Returns a tuple containing the model XML string and a dict of assets."""
  return common.read_model('robot.xml'), common.ASSETS

@SUITE.add('playing')
def test(time_limit=_DEFAULT_TIME_LIMIT, random=None, environment_kwargs=None):
  """Returns the Test task."""
  physics = Physics.from_xml_string(*get_model_and_assets())
  task = Robot()
  environment_kwargs = environment_kwargs or {}
  return control.Environment(
      physics, task, time_limit=time_limit, control_timestep=_CONTROL_TIMESTEP,
      **environment_kwargs)

class Physics(mujoco.Physics):
  """Physics class"""

class Robot(base.Task):
  def __init__(self, random=None):
    """Initializes an instance of `Robot`."""
    super(Robot, self).__init__(random=random)

  def initialize_episode(self, physics):
    """Sets the state of the environment at the start of each episode."""
    pass
  
  def get_observation(self, physics):
    """Returns either the pure state or a set of egocentric features."""
    obs = collections.OrderedDict()
    return obs

  def get_reward(self, physics):
    """Returns a reward to the agent."""
    return 0

Once you have implemented your .py file, you just need to import it near the top of suite/_init_.py, and you should be able to use your environment!

For composed environments (e.g. Soccer), it is a bit more complicated, but you should be able to understand it from studying the code.

from dm_control.

huiwenzhang avatar huiwenzhang commented on May 18, 2024

Totally agree. Add documents for the API and instructions or examples to create customized environment. Hope it will come soon.

from dm_control.

DanielTakeshi avatar DanielTakeshi commented on May 18, 2024

Just wondering, was there any progress made on this?

from dm_control.

aaronsnoswell avatar aaronsnoswell commented on May 18, 2024

(For future readers): also see some of the comments on #53.

from dm_control.

alimuldal avatar alimuldal commented on May 18, 2024

We have an example of defining a new task from scratch in the Composer section of the tutorial colab

from dm_control.

ajayflynavy avatar ajayflynavy commented on May 18, 2024

Dear All,
It is requested that kindly help or provide some link how to design states, Actions and Rewards to train the agent on offline data. Data available on CSV file.

from dm_control.

yuvaltassa avatar yuvaltassa commented on May 18, 2024

Please read the the tutorial (Section 6) of the tech report associated with this package and/or run the associated tutorial colab.

from dm_control.

ajayflynavy avatar ajayflynavy commented on May 18, 2024

Hi Yuv,

Thanks for writing. I am looking for some py file and notebook on how to design a custom environment to train the agent in RL. I am trying to put some offline data and my actions are in discreet in nature.

Regards,

from dm_control.

josyulakrishna avatar josyulakrishna commented on May 18, 2024

Please read the the tutorial (Section 6) of the tech report associated with this package and/or run the associated tutorial colab.

The tutorial file doesn't open in colab or on github the error displayed is "Invalid notebook, The Notebook Does Not Appear to Be Valid JSON"

from dm_control.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.