Skip to content

Commit 1411bc4

Browse files
committed
added markers for object spawn region
1 parent 4471570 commit 1411bc4

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/direct/deformable_cube/deformable_cube_env.py

+56-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import omni.isaac.lab.sim as sim_utils
88
import omni.isaac.lab.utils.math as math_utils
99
from omni.isaac.lab.actuators.actuator_cfg import ImplicitActuatorCfg
10+
from omni.isaac.lab.markers import VisualizationMarkersCfg, VisualizationMarkers
1011
from omni.isaac.lab.assets import Articulation, DeformableObject, ArticulationCfg, DeformableObjectCfg, RigidObjectCfg, RigidObject
1112
from omni.isaac.lab.envs import DirectRLEnv, DirectRLEnvCfg
1213
from omni.isaac.lab.scene import InteractiveSceneCfg
@@ -18,11 +19,13 @@
1819
from omni.isaac.lab_assets.franka import FRANKA_PANDA_CFG
1920

2021
CUBE_SIZE = 0.1
21-
CUBE_X_MIN, CUBE_X_MAX = 0.1, 1.0
22-
CUBE_Y_MIN, CUBE_Y_MAX = -0.5, 0.5
22+
CUBE_X_MIN, CUBE_X_MAX = 0.0, 1.0
23+
CUBE_Y_MIN, CUBE_Y_MAX = -0.45, 0.45
2324

2425
# TODO: Edit GPU settings for softbody contact buffer size
2526
# TODO: mess with deformable object settings
27+
# TODO: Make sure cube spawns on table
28+
# TODO: Add some way to detect if cube is in container
2629

2730
def get_robot() -> ArticulationCfg:
2831
return ArticulationCfg(
@@ -165,6 +168,55 @@ class DeformableCubeEnvCfg(DirectRLEnvCfg):
165168
object_cfg: DeformableObjectCfg = get_object()
166169
container_cfg: RigidObjectCfg = get_container()
167170

171+
# markers
172+
table_markers_cfg: VisualizationMarkersCfg = VisualizationMarkersCfg(
173+
prim_path="/Visuals/TableMarkers",
174+
markers={
175+
"table_bottom_left": sim_utils.UsdFileCfg(
176+
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/frame_prim.usd",
177+
scale=(0.15, 0.15, 0.15),
178+
),
179+
"table_bottom_right": sim_utils.UsdFileCfg(
180+
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/frame_prim.usd",
181+
scale=(0.15, 0.15, 0.15),
182+
),
183+
"table_top_left": sim_utils.UsdFileCfg(
184+
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/frame_prim.usd",
185+
scale=(0.15, 0.15, 0.15),
186+
),
187+
"table_top_right": sim_utils.UsdFileCfg(
188+
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/frame_prim.usd",
189+
scale=(0.15, 0.15, 0.15),
190+
),
191+
}
192+
)
193+
194+
def draw_markers(markers: VisualizationMarkers, origins: torch.Tensor):
195+
N_envs = origins.shape[0]
196+
197+
# table corner markers
198+
bottom_left_T = torch.tensor([0.0, 0.45, 1.0], device=origins.device).reshape(1, -1)
199+
bottom_right_T = torch.tensor([0.0, -0.45, 1.0], device=origins.device).reshape(1, -1)
200+
top_left_T = torch.tensor([1.0, 0.45, 1.0], device=origins.device).reshape(1, -1)
201+
top_right_T = torch.tensor([1.0, -0.45, 1.0], device=origins.device).reshape(1, -1)
202+
203+
bottom_left, bottom_right, top_left, top_right = origins.clone().repeat(4, 1).reshape(4, -1, 3).unbind(0)
204+
bottom_left += bottom_left_T
205+
bottom_right += bottom_right_T
206+
top_left += top_left_T
207+
top_right += top_right_T
208+
209+
r2b2 = math.sqrt(2) / 2
210+
bottom_left_quat = torch.tensor([-r2b2, 0.0, 0.0, r2b2], device=origins.device).reshape(1, -1).repeat(N_envs, 1)
211+
bottom_right_quat = torch.tensor([1.0, 0.0, 0.0, 0.0], device=origins.device).reshape(1, -1).repeat(N_envs, 1)
212+
top_left_quat = torch.tensor([0.0, 0.0, 0.0, 1.0], device=origins.device).reshape(1, -1).repeat(N_envs, 1)
213+
top_right_quat = torch.tensor([r2b2, 0.0, 0.0, r2b2], device=origins.device).reshape(1, -1).repeat(N_envs, 1)
214+
215+
marker_quats = torch.cat([bottom_left_quat, bottom_right_quat, top_left_quat, top_right_quat], dim=0)
216+
marker_locs = torch.cat([bottom_left, bottom_right, top_left, top_right], dim=0)
217+
marker_idxs = torch.tensor([0, 1, 2, 3]).repeat_interleave(N_envs)
218+
markers.visualize(marker_locs, marker_quats, marker_indices=marker_idxs)
219+
168220

169221
class DeformableCubeEnv(DirectRLEnv):
170222
cfg: DeformableCubeEnvCfg
@@ -187,9 +239,11 @@ def _setup_scene(self):
187239
self.object = DeformableObject(self.cfg.object_cfg)
188240
self.container = RigidObject(self.cfg.container_cfg)
189241
self.table = RigidObject(self.cfg.table_cfg)
242+
self.table_markers = VisualizationMarkers(self.cfg.table_markers_cfg)
190243
self.scene.articulations["robot"] = self.robot
191244

192245
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
246+
draw_markers(self.table_markers, self.scene.env_origins)
193247

194248
# clone, filter, and replicate
195249
self.scene.clone_environments(copy_from_source=False)

0 commit comments

Comments
 (0)