@@ -304,41 +304,46 @@ J = kinDyn.jacobian('frame_name', w_H_b, joints)
304304
305305### OpenUSD
306306
307- adam supports both exporting a model to OpenUSD and loading it back for computations.
307+ adam supports loading robot models directly from OpenUSD files and exporting models to OpenUSD.
308+
309+ ** Loading directly from a USD file:**
308310
309311``` python
310312import numpy as np
311313from adam import Representations
312- from adam.model import Model, build_model_factory
313314from adam.numpy import KinDynComputations
314- from adam.numpy.numpy_like import SpatialMath
315-
316- # You can convert a URDF to a USD
317- model_path = " robot.urdf"
318- joints_name_list = [" joint_1" , " joint_2" ]
319315
320- factory = build_model_factory(description = model_path, math = SpatialMath())
321- model = Model.build(factory = factory, joints_name_list = joints_name_list)
322-
323- # Export robot articulation to USD (use .usda for text, .usdc for binary)
324- usd_path = " robot.usda"
325- model.to_usd(usd_path, robot_prim_path = " /Robot" )
326-
327- # If you have an existing USD file, start from this to create a KinDynComputations instance
316+ # Load directly from any existing USD file
328317kinDyn = KinDynComputations.from_usd(
329- usd_path ,
318+ " robot.usd " ,
330319 robot_prim_path = " /Robot" ,
331- joints_name_list = joints_name_list ,
320+ joints_name_list = [ " joint_1 " , " joint_2 " ] ,
332321)
333322kinDyn.set_frame_velocity_representation(Representations.MIXED_REPRESENTATION )
334323
335324# Compute quantities as usual
336325w_H_b = np.eye(4 )
337- q = np.zeros(len (joints_name_list) )
326+ q = np.zeros(kinDyn.NDoF )
338327M = kinDyn.mass_matrix(w_H_b, q)
339328com = kinDyn.CoM_position(w_H_b, q)
340329```
341330
331+ ** Exporting a model to USD** (e.g. to convert a URDF to USD):
332+
333+ ``` python
334+ from adam.model import Model, build_model_factory
335+ from adam.numpy.numpy_like import SpatialMath
336+
337+ model_path = " robot.urdf"
338+ joints_name_list = [" joint_1" , " joint_2" ]
339+
340+ factory = build_model_factory(description = model_path, math = SpatialMath())
341+ model = Model.build(factory = factory, joints_name_list = joints_name_list)
342+
343+ # Export to USD
344+ model.to_usd(" robot.usd" , robot_prim_path = " /Robot" )
345+ ```
346+
342347### Visualization
343348
344349adam also provides a lightweight visualization layer based on [ viser] ( https://viser.studio/ ) .
@@ -349,7 +354,7 @@ For quick inspection from the terminal, use the bundled viewer command:
349354``` bash
350355adam-model-view --urdf path/to/robot.urdf
351356adam-model-view --mujoco path/to/model.xml
352- adam-model-view --usd path/to/robot.usda --robot-prim-path /Robot
357+ adam-model-view --usd path/to/robot.usd --robot-prim-path /Robot
353358```
354359
355360``` python
@@ -385,7 +390,7 @@ With other model sources, only the loader changes:
385390kindyn = KinDynComputations.from_mujoco_model(mj_model)
386391
387392# USD
388- kindyn = KinDynComputations.from_usd(" robot.usda " , robot_prim_path = " /Robot" )
393+ kindyn = KinDynComputations.from_usd(" robot.usd " , robot_prim_path = " /Robot" )
389394```
390395
391396Batched visualization is available through the same ` ModelHandle ` API by passing
0 commit comments