Exemple #1
0
    def __init__(self, title='Explorer', width=1024, height=768):
        """Instance initializer."""
        self._render_surface = None
        self._renderer = renderer.NullRenderer()
        self._viewport = renderer.Viewport(width, height)
        self._window = gui.RenderWindow(width, height, title)

        self._pause_subject = util.ObservableFlag(True)
        self._time_multiplier = util.TimeMultiplier(1.)
        self._frame_timer = util.Timer()
        self._viewer = viewer.Viewer(self._viewport, self._window.mouse,
                                     self._window.keyboard)
        self._viewer_layout = views.ViewportLayout()
        self._status = Status(self._time_multiplier, self._pause_subject,
                              self._frame_timer)

        self._runtime = None
        self._environment_loader = None
        self._environment = None
        self._policy = None
        self._deferred_reload_request = None

        status_view_toggle = self._build_view_toggle(
            views.ColumnTextView(self._status),
            views.PanelLocation.BOTTOM_LEFT)
        help_view_toggle = self._build_view_toggle(
            views.ColumnTextView(Help()), views.PanelLocation.TOP_RIGHT)
        status_view_toggle()

        self._input_map = user_input.InputMap(self._window.mouse,
                                              self._window.keyboard)
        self._input_map.bind(self._pause_subject.toggle, _PAUSE)
        self._input_map.bind(self._time_multiplier.increase, _SPEED_UP_TIME)
        self._input_map.bind(self._time_multiplier.decrease, _SLOW_DOWN_TIME)
        self._input_map.bind(self._advance_simulation, _ADVANCE_SIMULATION)
        self._input_map.bind(self._restart_runtime, _RESTART)
        self._input_map.bind(help_view_toggle, _HELP)
        self._input_map.bind(status_view_toggle, _STATUS)
Exemple #2
0
    def __init__(self, environment, policy=None):
        """Instance initializer.

    Args:
      environment: An instance of dm_control.rl.control.Environment.
      policy: Either a callable that accepts a `TimeStep` and returns a numpy
        array of actions conforming to `environment.action_spec()`, or None, in
        which case a default action will be generated for each environment step.
    """
        self.on_error = util.QuietSet()
        self.on_episode_begin = util.QuietSet()
        self.simulation_time_budget = _DEFAULT_MAX_SIM_STEP

        self._state = State.START
        self._simulation_timer = util.Timer()
        self._tracked_simulation_time = 0.0
        self._error_logger = util.ErrorLogger(self.on_error)

        self._env = environment
        self._policy = policy
        self._default_action = _get_default_action(environment.action_spec())
        self._time_step = None
        self._last_action = None
        self.on_physics_changed = util.QuietSet()
Exemple #3
0
 def setUp(self):
     self.timer = util.Timer()
Exemple #4
0
 def setUp(self):
     super(TimerTest, self).setUp()
     self.timer = util.Timer()
Exemple #5
0
 def setUp(self):
   super().setUp()
   self.timer = util.Timer()