7
7
import omni .isaac .lab .sim as sim_utils
8
8
import omni .isaac .lab .utils .math as math_utils
9
9
from omni .isaac .lab .actuators .actuator_cfg import ImplicitActuatorCfg
10
+ from omni .isaac .lab .markers import VisualizationMarkersCfg , VisualizationMarkers
10
11
from omni .isaac .lab .assets import Articulation , DeformableObject , ArticulationCfg , DeformableObjectCfg , RigidObjectCfg , RigidObject
11
12
from omni .isaac .lab .envs import DirectRLEnv , DirectRLEnvCfg
12
13
from omni .isaac .lab .scene import InteractiveSceneCfg
18
19
from omni .isaac .lab_assets .franka import FRANKA_PANDA_CFG
19
20
20
21
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
23
24
24
25
# TODO: Edit GPU settings for softbody contact buffer size
25
26
# 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
26
29
27
30
def get_robot () -> ArticulationCfg :
28
31
return ArticulationCfg (
@@ -165,6 +168,55 @@ class DeformableCubeEnvCfg(DirectRLEnvCfg):
165
168
object_cfg : DeformableObjectCfg = get_object ()
166
169
container_cfg : RigidObjectCfg = get_container ()
167
170
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
+
168
220
169
221
class DeformableCubeEnv (DirectRLEnv ):
170
222
cfg : DeformableCubeEnvCfg
@@ -187,9 +239,11 @@ def _setup_scene(self):
187
239
self .object = DeformableObject (self .cfg .object_cfg )
188
240
self .container = RigidObject (self .cfg .container_cfg )
189
241
self .table = RigidObject (self .cfg .table_cfg )
242
+ self .table_markers = VisualizationMarkers (self .cfg .table_markers_cfg )
190
243
self .scene .articulations ["robot" ] = self .robot
191
244
192
245
spawn_ground_plane (prim_path = "/World/ground" , cfg = GroundPlaneCfg ())
246
+ draw_markers (self .table_markers , self .scene .env_origins )
193
247
194
248
# clone, filter, and replicate
195
249
self .scene .clone_environments (copy_from_source = False )
0 commit comments