Skip to content

Commit 57fe28b

Browse files
alimuldalcopybara-github
authored andcommitted
Add a suite of manipulation tasks based on the Jaco arm
PiperOrigin-RevId: 317728882 Change-Id: Ia9b4103d70e0227ea2b4e6ba74058f2093901047
1 parent 1bbc2d0 commit 57fe28b

17 files changed

Lines changed: 2285 additions & 1 deletion
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright 2018 The dm_control Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ============================================================================
15+
16+
"""A structured set of manipulation tasks with a single entry point."""
17+
18+
from __future__ import absolute_import
19+
from __future__ import division
20+
from __future__ import print_function
21+
22+
from absl import flags
23+
from dm_control import composer as _composer
24+
from dm_control.manipulation import bricks as _bricks
25+
from dm_control.manipulation import lift as _lift
26+
from dm_control.manipulation import place as _place
27+
from dm_control.manipulation import reach as _reach
28+
from dm_control.manipulation.shared import registry as _registry
29+
30+
_registry.done_importing_tasks()
31+
32+
_TIME_LIMIT = 10.
33+
_TIMEOUT = None
34+
35+
ALL = tuple(_registry.get_all_names())
36+
TAGS = tuple(_registry.get_tags())
37+
38+
flags.DEFINE_bool('timeout', True, 'Whether episodes should have a time limit.')
39+
FLAGS = flags.FLAGS
40+
41+
42+
def _get_timeout():
43+
global _TIMEOUT
44+
if _TIMEOUT is None:
45+
if FLAGS.is_parsed():
46+
_TIMEOUT = FLAGS.timeout
47+
else:
48+
_TIMEOUT = FLAGS['timeout'].default
49+
return _TIMEOUT
50+
51+
52+
def get_environments_by_tag(tag):
53+
"""Returns the names of all environments matching a given tag.
54+
55+
Args:
56+
tag: A string from `TAGS`.
57+
58+
Returns:
59+
A tuple of environment names.
60+
"""
61+
return tuple(_registry.get_names_by_tag(tag))
62+
63+
64+
def load(environment_name, seed=None):
65+
"""Loads a manipulation environment.
66+
67+
Args:
68+
environment_name: String, the name of the environment to load. Must be in
69+
`ALL`.
70+
seed: An optional integer used to seed the task's random number generator.
71+
If None (default), the random number generator will self-seed from a
72+
platform-dependent source of entropy.
73+
74+
Returns:
75+
An instance of `composer.Environment`.
76+
"""
77+
task = _registry.get_constructor(environment_name)()
78+
time_limit = _TIME_LIMIT if _get_timeout() else float('inf')
79+
return _composer.Environment(task, time_limit=time_limit, random_state=seed)

0 commit comments

Comments
 (0)