Delete folder templates with huggingface_hub
Browse files- templates/problem_class_template.py +0 -211
- templates/scene_template.xml +0 -76
templates/problem_class_template.py
DELETED
|
@@ -1,211 +0,0 @@
|
|
| 1 |
-
from robosuite.utils.mjcf_utils import new_site
|
| 2 |
-
|
| 3 |
-
from libero.libero.envs.bddl_base_domain import BDDLBaseDomain, register_problem
|
| 4 |
-
from libero.libero.envs.robots import *
|
| 5 |
-
from libero.libero.envs.objects import *
|
| 6 |
-
from libero.libero.envs.predicates import *
|
| 7 |
-
from libero.libero.envs.regions import *
|
| 8 |
-
from libero.libero.envs.utils import rectangle2xyrange
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
@register_problem
|
| 12 |
-
class YOUR_CLASS_NAME(BDDLBaseDomain):
|
| 13 |
-
def __init__(self, bddl_file_name, *args, **kwargs):
|
| 14 |
-
|
| 15 |
-
# Configure the workspace
|
| 16 |
-
self.workspace_name = "kitchen_table"
|
| 17 |
-
self.visualization_sites_list = []
|
| 18 |
-
|
| 19 |
-
self.kitchen_table_full_size = (1.0, 1.2, 0.05)
|
| 20 |
-
self.kitchen_table_offset = (0.0, 0, 0.90)
|
| 21 |
-
# For z offset of environment fixtures
|
| 22 |
-
self.z_offset = 0.01 - self.kitchen_table_full_size[2]
|
| 23 |
-
kwargs.update(
|
| 24 |
-
{"robots": [f"Mounted{robot_name}" for robot_name in kwargs["robots"]]}
|
| 25 |
-
)
|
| 26 |
-
kwargs.update({"workspace_offset": self.kitchen_table_offset})
|
| 27 |
-
kwargs.update({"arena_type": "kitchen"})
|
| 28 |
-
|
| 29 |
-
# Specify the scene xml and scene properties. Specify the default here since not many people would need to change this actively.
|
| 30 |
-
if "scene_xml" not in kwargs or kwargs["scene_xml"] is None:
|
| 31 |
-
kwargs.update(
|
| 32 |
-
{"scene_xml": "scenes/libero_kitchen_tabletop_base_style.xml"}
|
| 33 |
-
)
|
| 34 |
-
if "scene_properties" not in kwargs or kwargs["scene_properties"] is None:
|
| 35 |
-
# The scene properties need to be specified in libero/envs/arenas/style.py.
|
| 36 |
-
kwargs.update(
|
| 37 |
-
{
|
| 38 |
-
"scene_properties": {
|
| 39 |
-
"floor_style": "gray-ceramic",
|
| 40 |
-
"wall_style": "yellow-linen",
|
| 41 |
-
}
|
| 42 |
-
}
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
-
super().__init__(bddl_file_name, *args, **kwargs)
|
| 46 |
-
|
| 47 |
-
def _load_fixtures_in_arena(self, mujoco_arena):
|
| 48 |
-
"""Load the figures in this scene. If some extra process is required for the initial configurations, do it here."""
|
| 49 |
-
for fixture_category in list(self.parsed_problem["fixtures"].keys()):
|
| 50 |
-
if fixture_category == "kitchen_table":
|
| 51 |
-
continue
|
| 52 |
-
for fixture_instance in self.parsed_problem["fixtures"][fixture_category]:
|
| 53 |
-
self.fixtures_dict[fixture_instance] = get_object_fn(fixture_category)(
|
| 54 |
-
name=fixture_instance,
|
| 55 |
-
joints=None,
|
| 56 |
-
)
|
| 57 |
-
|
| 58 |
-
def _load_objects_in_arena(self, mujoco_arena):
|
| 59 |
-
"""Load the movable objects in this scene."""
|
| 60 |
-
objects_dict = self.parsed_problem["objects"]
|
| 61 |
-
for category_name in objects_dict.keys():
|
| 62 |
-
for object_name in objects_dict[category_name]:
|
| 63 |
-
self.objects_dict[object_name] = get_object_fn(category_name)(
|
| 64 |
-
name=object_name
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
def _load_sites_in_arena(self, mujoco_arena):
|
| 68 |
-
"""Load the sites in this part. Sites are used for either visualization purpose, or specifying the target region / containing region."""
|
| 69 |
-
object_sites_dict = {}
|
| 70 |
-
region_dict = self.parsed_problem["regions"]
|
| 71 |
-
for object_region_name in list(region_dict.keys()):
|
| 72 |
-
|
| 73 |
-
if "kitchen_table" in object_region_name:
|
| 74 |
-
ranges = region_dict[object_region_name]["ranges"][0]
|
| 75 |
-
assert ranges[2] >= ranges[0] and ranges[3] >= ranges[1]
|
| 76 |
-
zone_size = ((ranges[2] - ranges[0]) / 2, (ranges[3] - ranges[1]) / 2)
|
| 77 |
-
zone_centroid_xy = (
|
| 78 |
-
(ranges[2] + ranges[0]) / 2 + self.workspace_offset[0],
|
| 79 |
-
(ranges[3] + ranges[1]) / 2 + self.workspace_offset[1],
|
| 80 |
-
)
|
| 81 |
-
target_zone = TargetZone(
|
| 82 |
-
name=object_region_name,
|
| 83 |
-
rgba=region_dict[object_region_name]["rgba"],
|
| 84 |
-
zone_size=zone_size,
|
| 85 |
-
z_offset=self.workspace_offset[2],
|
| 86 |
-
zone_centroid_xy=zone_centroid_xy,
|
| 87 |
-
)
|
| 88 |
-
object_sites_dict[object_region_name] = target_zone
|
| 89 |
-
mujoco_arena.table_body.append(
|
| 90 |
-
new_site(
|
| 91 |
-
name=target_zone.name,
|
| 92 |
-
pos=target_zone.pos + np.array([0.0, 0.0, -0.90]),
|
| 93 |
-
quat=target_zone.quat,
|
| 94 |
-
rgba=target_zone.rgba,
|
| 95 |
-
size=target_zone.size,
|
| 96 |
-
type="box",
|
| 97 |
-
)
|
| 98 |
-
)
|
| 99 |
-
continue
|
| 100 |
-
# Otherwise the processing is consistent
|
| 101 |
-
for query_dict in [self.objects_dict, self.fixtures_dict]:
|
| 102 |
-
for (name, body) in query_dict.items():
|
| 103 |
-
try:
|
| 104 |
-
if "worldbody" not in list(body.__dict__.keys()):
|
| 105 |
-
# This is a special case for CompositeObject, we skip this as this is very rare in our benchmark
|
| 106 |
-
continue
|
| 107 |
-
except:
|
| 108 |
-
continue
|
| 109 |
-
for part in body.worldbody.find("body").findall(".//body"):
|
| 110 |
-
sites = part.findall(".//site")
|
| 111 |
-
joints = part.findall("./joint")
|
| 112 |
-
if sites == []:
|
| 113 |
-
break
|
| 114 |
-
for site in sites:
|
| 115 |
-
site_name = site.get("name")
|
| 116 |
-
if site_name == object_region_name:
|
| 117 |
-
object_sites_dict[object_region_name] = SiteObject(
|
| 118 |
-
name=site_name,
|
| 119 |
-
parent_name=body.name,
|
| 120 |
-
joints=[joint.get("name") for joint in joints],
|
| 121 |
-
size=site.get("size"),
|
| 122 |
-
rgba=site.get("rgba"),
|
| 123 |
-
site_type=site.get("type"),
|
| 124 |
-
site_pos=site.get("pos"),
|
| 125 |
-
site_quat=site.get("quat"),
|
| 126 |
-
object_properties=body.object_properties,
|
| 127 |
-
)
|
| 128 |
-
self.object_sites_dict = object_sites_dict
|
| 129 |
-
|
| 130 |
-
# Keep track of visualization objects
|
| 131 |
-
for query_dict in [self.fixtures_dict, self.objects_dict]:
|
| 132 |
-
for name, body in query_dict.items():
|
| 133 |
-
if body.object_properties["vis_site_names"] != {}:
|
| 134 |
-
self.visualization_sites_list.append(name)
|
| 135 |
-
|
| 136 |
-
def _add_placement_initializer(self):
|
| 137 |
-
"""Very simple implementation at the moment. Will need to upgrade for other relations later. Take a look at BDDLBaseDomain class, and modify the implementation logic accordingly based on your own need."""
|
| 138 |
-
super()._add_placement_initializer()
|
| 139 |
-
|
| 140 |
-
def _check_success(self):
|
| 141 |
-
"""
|
| 142 |
-
Check if the goal is achieved. Consider conjunction goals at the moment
|
| 143 |
-
"""
|
| 144 |
-
goal_state = self.parsed_problem["goal_state"]
|
| 145 |
-
result = True
|
| 146 |
-
for state in goal_state:
|
| 147 |
-
result = self._eval_predicate(state) and result
|
| 148 |
-
return result
|
| 149 |
-
|
| 150 |
-
def _eval_predicate(self, state):
|
| 151 |
-
"""Evaluate each predicate. For the moment, we only consider unary and binary predicates."""
|
| 152 |
-
if len(state) == 3:
|
| 153 |
-
# Checking binary logical predicates
|
| 154 |
-
predicate_fn_name = state[0]
|
| 155 |
-
object_1_name = state[1]
|
| 156 |
-
object_2_name = state[2]
|
| 157 |
-
return eval_predicate_fn(
|
| 158 |
-
predicate_fn_name,
|
| 159 |
-
self.object_states_dict[object_1_name],
|
| 160 |
-
self.object_states_dict[object_2_name],
|
| 161 |
-
)
|
| 162 |
-
elif len(state) == 2:
|
| 163 |
-
# Checking unary logical predicates
|
| 164 |
-
predicate_fn_name = state[0]
|
| 165 |
-
object_name = state[1]
|
| 166 |
-
return eval_predicate_fn(
|
| 167 |
-
predicate_fn_name, self.object_states_dict[object_name]
|
| 168 |
-
)
|
| 169 |
-
|
| 170 |
-
def _setup_references(self):
|
| 171 |
-
"""Set up references for the objects. Add extra implementation here if the method in the parent class is not sufficient."""
|
| 172 |
-
super()._setup_references()
|
| 173 |
-
|
| 174 |
-
def _post_process(self):
|
| 175 |
-
"""Post process the simulation step. Mainly for handling site visualization."""
|
| 176 |
-
super()._post_process()
|
| 177 |
-
|
| 178 |
-
self.set_visualization()
|
| 179 |
-
|
| 180 |
-
def set_visualization(self):
|
| 181 |
-
"""Set the visualization of the objects in the scene."""
|
| 182 |
-
for object_name in self.visualization_sites_list:
|
| 183 |
-
for _, (site_name, site_visible) in (
|
| 184 |
-
self.get_object(object_name).object_properties["vis_site_names"].items()
|
| 185 |
-
):
|
| 186 |
-
vis_g_id = self.sim.model.site_name2id(site_name)
|
| 187 |
-
if ((self.sim.model.site_rgba[vis_g_id][3] <= 0) and site_visible) or (
|
| 188 |
-
(self.sim.model.site_rgba[vis_g_id][3] > 0) and not site_visible
|
| 189 |
-
):
|
| 190 |
-
# We toggle the alpha value
|
| 191 |
-
self.sim.model.site_rgba[vis_g_id][3] = (
|
| 192 |
-
1 - self.sim.model.site_rgba[vis_g_id][3]
|
| 193 |
-
)
|
| 194 |
-
|
| 195 |
-
def _setup_camera(self, mujoco_arena):
|
| 196 |
-
"""Configure the camera as the workspace observation."""
|
| 197 |
-
mujoco_arena.set_camera(
|
| 198 |
-
camera_name="agentview",
|
| 199 |
-
pos=[0.6586131746834771, 0.0, 1.6103500240372423],
|
| 200 |
-
quat=[
|
| 201 |
-
0.6380177736282349,
|
| 202 |
-
0.3048497438430786,
|
| 203 |
-
0.30484986305236816,
|
| 204 |
-
0.6380177736282349,
|
| 205 |
-
],
|
| 206 |
-
)
|
| 207 |
-
|
| 208 |
-
# For visualization purpose
|
| 209 |
-
mujoco_arena.set_camera(
|
| 210 |
-
camera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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/scene_template.xml
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
<mujoco model="table_arena">
|
| 2 |
-
<asset>
|
| 3 |
-
<texture builtin="gradient" height="256" rgb1=".9 .9 1." rgb2=".2 .3 .4" type="skybox" width="256"/>
|
| 4 |
-
|
| 5 |
-
<!-- floor texture and material-->
|
| 6 |
-
|
| 7 |
-
<texture file="../textures/tile_grigia_caldera_porcelain_floor.png" type="2d" name="texplane"/>
|
| 8 |
-
|
| 9 |
-
<material name="floorplane" reflectance="0.0" shininess="0.0"
|
| 10 |
-
specular="0.0" texrepeat="3 3" texture="texplane" texuniform="true"/>
|
| 11 |
-
|
| 12 |
-
<!-- table texture and material -->
|
| 13 |
-
<texture file="../textures/martin_novak_wood_table.png" type="cube" name="tex-table"/>
|
| 14 |
-
<material name="table_texture" reflectance="0.0" shininess="0.0" specular="0.2" texrepeat="1 1" texture="tex-table" />
|
| 15 |
-
<!-- table legs texture and material -->
|
| 16 |
-
<texture file="../textures/martin_novak_wood_table.png" type="cube" name="tex-table-legs"/>
|
| 17 |
-
<material name="table_legs" reflectance="0.8" shininess="0.8" texrepeat="1 1" texture="tex-table-legs" />
|
| 18 |
-
|
| 19 |
-
<!-- wall texture and material -->
|
| 20 |
-
<texture file="../textures/smooth_light_gray_plaster.png" type="2d" name="tex-wall"/>
|
| 21 |
-
<material name="walls_mat" reflectance="0.0" shininess="0.3" specular="0.8" texrepeat="3 3" texture="tex-wall" texuniform="true" />
|
| 22 |
-
|
| 23 |
-
<!-- added table texture and material for domain randomization -->
|
| 24 |
-
<texture name="textable" builtin="flat" height="512" width="512" rgb1="0.8 0.8 0.8" rgb2="0.8 0.8 0.8"/>
|
| 25 |
-
<material name="table_mat" texture="textable" />
|
| 26 |
-
|
| 27 |
-
<!-- Specify your own scene texture, change it on your own. -->
|
| 28 |
-
<texture file="kitchen_background/kitchen_background.png" name="tex-custom" type="2d"/>
|
| 29 |
-
<material name="custom" reflectance="0.5" texrepeat="1 1" texture="tex-custom" texuniform="false"/>
|
| 30 |
-
<mesh file="kitchen_background/visual/kitchen_background_vis.msh" name="custom_vis" scale="0.01 0.01 0.01"/>
|
| 31 |
-
|
| 32 |
-
</asset>
|
| 33 |
-
<worldbody>
|
| 34 |
-
<!-- Floor -->
|
| 35 |
-
<geom condim="3" group="1" material="floorplane" name="floor" pos="0 0 0" size="3 3 .125" type="plane"/>
|
| 36 |
-
|
| 37 |
-
<geom pos="-1.65 0.0 0.0" quat="0 0 0 1" type="mesh" mesh="custom_vis" conaffinity="0" contype="0" group="1" material="custom"/>
|
| 38 |
-
|
| 39 |
-
<light name="light_kitchen" diffuse=".8 .8 .8" dir="0 0 -1" directional="true" pos="-1.75 0 1.6" specular="0.8 0.8 0.8" castshadow="false"/>
|
| 40 |
-
|
| 41 |
-
<geom pos="0.5 3 1.5" quat="0.7071 0.7071 0 0" size="2.5 1.5 0.01" type="box" conaffinity="0" contype="0" group="1" name="wall_left_visual" material="walls_mat"/>
|
| 42 |
-
<geom pos="0.5 -3 1.5" quat="0.7071 -0.7071 0 0" size="2.5 1.5 0.01" type="box" conaffinity="0" contype="0" group="1" name="wall_right_visual" material="walls_mat"/>
|
| 43 |
-
<geom pos="-2 0 1.5" quat="0.5 0.5 0.5 0.5" size="3 1.5 0.01" type="box" conaffinity="0" contype="0" group="1" name="wall_rear_visual" material="walls_mat"/>
|
| 44 |
-
<geom pos="3 0 1.5" quat="0.5 0.5 -0.5 -0.5" size="3 1.5 0.01" type="box" conaffinity="0" contype="0" group="1" name="wall_front_visual" material="walls_mat"/>
|
| 45 |
-
<!-- Table body -->
|
| 46 |
-
<body name="table" pos="0 0 0.4">
|
| 47 |
-
<geom pos="0 0 0" size="0.4 0.4 0.4" type="box" group="0" name="table_collision" friction="1 0.005 0.0001"/>
|
| 48 |
-
<geom pos="0 0 0" size="0.4 0.4 0.4" type="box" conaffinity="0" contype="0" group="1" name="table_visual" material="table_texture"/>
|
| 49 |
-
<site pos="0 0 0.4" name="table_top" size="0.001 0.001 0.001" rgba="0 0 0 0"/>
|
| 50 |
-
<!-- Legs (visual only) -->
|
| 51 |
-
<geom pos="0 0 0" size="0.05 0.1" type="cylinder" conaffinity="0" contype="0" group="1" name="table_leg1_visual" material="table_legs"/>
|
| 52 |
-
<geom pos="0 0 0" size="0.05 0.1" type="cylinder" conaffinity="0" contype="0" group="1" name="table_leg2_visual" material="table_legs"/>
|
| 53 |
-
<geom pos="0 0 0" size="0.05 0.1" type="cylinder" conaffinity="0" contype="0" group="1" name="table_leg3_visual" material="table_legs"/>
|
| 54 |
-
<geom pos="0 0 0" size="0.05 0.1" type="cylinder" conaffinity="0" contype="0" group="1" name="table_leg4_visual" material="table_legs"/>
|
| 55 |
-
</body>
|
| 56 |
-
|
| 57 |
-
<!-- 固定障碍球,不会掉落 -->
|
| 58 |
-
<body name="obstacle_ball" pos="0.0 0.0 1.1">
|
| 59 |
-
<geom name="obstacle_collision" type="sphere" size="0.025"
|
| 60 |
-
rgba="1 0 0 1" group="4" contype="1" conaffinity="1" friction="1 0.1 0.01"/>
|
| 61 |
-
</body>
|
| 62 |
-
|
| 63 |
-
<light name="light1" diffuse=".8 .8 .8" dir="0 -.15 -1" directional="false" pos="1 1 4.0" specular="0.3 0.3 0.3" castshadow="false"/>
|
| 64 |
-
<light name="light2" diffuse=".8 .8 .8" dir="0 -.15 -1" directional="false" pos="-3. -3. 4.0" specular="0.3 0.3 0.3" castshadow="false"/>
|
| 65 |
-
|
| 66 |
-
<!-- front view -->
|
| 67 |
-
<camera mode="fixed" name="frontview" pos="1.0 0 1.45" quat="0.56 0.43 0.43 0.56"/>
|
| 68 |
-
<!-- bird view -->
|
| 69 |
-
<camera mode="fixed" name="birdview" pos="-0.2 0 3.0" quat="0.7071 0 0 0.7071"/>
|
| 70 |
-
<!-- agent view -->
|
| 71 |
-
<camera mode="fixed" name="agentview" pos="0.5 0 1.35" quat="0.653 0.271 0.271 0.653"/>
|
| 72 |
-
|
| 73 |
-
<!-- side view -->
|
| 74 |
-
<camera mode="fixed" name="sideview" pos="-0.05651774593317116 1.2761224129427358 1.4879572214102434" quat="0.009905065491771751 0.006877963156909582 0.5912228352893879 0.806418094001364" />
|
| 75 |
-
</worldbody>
|
| 76 |
-
</mujoco>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|