@@ -192,10 +192,39 @@ def record_joint_names(output: torch.Tensor, descriptor: GenericIODescriptor, **
192
192
joint_ids = list (range (len (asset .joint_names )))
193
193
descriptor .joint_names = [asset .joint_names [i ] for i in joint_ids ]
194
194
195
-
196
195
def record_body_names (output : torch .Tensor , descriptor : GenericIODescriptor , ** kwargs ):
197
196
asset : Articulation = kwargs ["env" ].scene [kwargs ["asset_cfg" ].name ]
198
197
body_ids = kwargs ["asset_cfg" ].body_ids
199
198
if body_ids == slice (None , None , None ):
200
199
body_ids = list (range (len (asset .body_names )))
201
200
descriptor .body_names = [asset .body_names [i ] for i in body_ids ]
201
+
202
+ def record_joint_pos_offsets (output : torch .Tensor , descriptor : GenericIODescriptor , ** kwargs ):
203
+ asset : Articulation = kwargs ["env" ].scene [kwargs ["asset_cfg" ].name ]
204
+ ids = kwargs ["asset_cfg" ].joint_ids
205
+ # Get the offsets of the joints for the first robot in the scene.
206
+ # This assumes that all robots have the same joint offsets.
207
+ descriptor .joint_pos_offsets = asset .data .default_joint_pos [:, ids ][0 ]
208
+
209
+ def record_joint_vel_offsets (output : torch .Tensor , descriptor : GenericIODescriptor , ** kwargs ):
210
+ asset : Articulation = kwargs ["env" ].scene [kwargs ["asset_cfg" ].name ]
211
+ ids = kwargs ["asset_cfg" ].joint_ids
212
+ # Get the offsets of the joints for the first robot in the scene.
213
+ # This assumes that all robots have the same joint offsets.
214
+ descriptor .joint_vel_offsets = asset .data .default_joint_vel [:, ids ][0 ]
215
+
216
+
217
+ def export_articulations_data (env : ManagerBasedEnv ):
218
+ articulation_joint_data = {}
219
+ for articulation_name , articulation in env .scene .articulations .items ():
220
+ articulation_joint_data [articulation_name ] = {}
221
+ articulation_joint_data [articulation_name ]["joint_names" ] = articulation .joint_names
222
+ articulation_joint_data [articulation_name ]["default_joint_pos" ] = articulation .data .default_joint_pos [0 ].detach ().cpu ().numpy ().tolist ()
223
+ articulation_joint_data [articulation_name ]["default_joint_vel" ] = articulation .data .default_joint_vel [0 ].detach ().cpu ().numpy ().tolist ()
224
+ articulation_joint_data [articulation_name ]["default_joint_pos_limits" ] = articulation .data .default_joint_pos_limits [0 ].detach ().cpu ().numpy ().tolist ()
225
+ articulation_joint_data [articulation_name ]["default_joint_damping" ] = articulation .data .default_joint_damping [0 ].detach ().cpu ().numpy ().tolist ()
226
+ articulation_joint_data [articulation_name ]["default_joint_stiffness" ] = articulation .data .default_joint_stiffness [0 ].detach ().cpu ().numpy ().tolist ()
227
+ articulation_joint_data [articulation_name ]["default_joint_friction" ] = articulation .data .default_joint_friction [0 ].detach ().cpu ().numpy ().tolist ()
228
+ articulation_joint_data [articulation_name ]["default_joint_armature" ] = articulation .data .default_joint_armature [0 ].detach ().cpu ().numpy ().tolist ()
229
+ return articulation_joint_data
230
+
0 commit comments