Skip to content

Commit f799e23

Browse files
alik-gitWT-MM
andauthored
get actuators receives full metadata (#26)
* handle full metadata * pass full metadata to actuator creation * lint --------- Co-authored-by: Wesley Maa <57124298+WT-MM@users.noreply.github.com>
1 parent 93838cc commit f799e23

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

train.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import optax
1818
import xax
1919
from jaxtyping import Array, PRNGKeyArray
20-
from kscale.web.gen.api import JointMetadataOutput
20+
from kscale.web.gen.api import RobotURDFMetadataOutput
2121

2222
NUM_JOINTS = 20
2323
NUM_ACTOR_INPUTS = 49
@@ -368,21 +368,23 @@ def get_mujoco_model(self) -> mujoco.MjModel:
368368
mjcf_path = asyncio.run(ksim.get_mujoco_model_path("kbot", name="robot"))
369369
return mujoco_scenes.mjcf.load_mjmodel(mjcf_path, scene="smooth")
370370

371-
def get_mujoco_model_metadata(self, mj_model: mujoco.MjModel) -> dict[str, JointMetadataOutput]:
371+
def get_mujoco_model_metadata(self, mj_model: mujoco.MjModel) -> RobotURDFMetadataOutput:
372372
metadata = asyncio.run(ksim.get_mujoco_model_metadata("kbot"))
373373
if metadata.joint_name_to_metadata is None:
374374
raise ValueError("Joint metadata is not available")
375-
return metadata.joint_name_to_metadata
375+
if metadata.actuator_type_to_metadata is None:
376+
raise ValueError("Actuator metadata is not available")
377+
return metadata
376378

377379
def get_actuators(
378380
self,
379381
physics_model: ksim.PhysicsModel,
380-
metadata: dict[str, JointMetadataOutput] | None = None,
382+
metadata: RobotURDFMetadataOutput | None = None,
381383
) -> ksim.Actuators:
382384
assert metadata is not None, "Metadata is required"
383385
return ksim.MITPositionActuators(
384386
physics_model=physics_model,
385-
joint_name_to_metadata=metadata,
387+
metadata=metadata,
386388
)
387389

388390
def get_physics_randomizers(self, physics_model: ksim.PhysicsModel) -> list[ksim.PhysicsRandomizer]:

0 commit comments

Comments
 (0)