Skip to content

Commit c0786aa

Browse files
stephane-caronStéphane Caron
authored andcommitted
Add commit argument to all loaders
1 parent d37f9fe commit c0786aa

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

robot_descriptions/loaders/idyntree.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33
#
44
# Copyright 2022 Giulio Romualdi
5+
# Copyright 2023 Inria
56
#
67
# Licensed under the Apache License, Version 2.0 (the "License");
78
# you may not use this file except in compliance with the License.
@@ -19,6 +20,7 @@
1920
Load a robot description in iDynTree.
2021
"""
2122

23+
import os
2224
from importlib import import_module # type: ignore
2325
from typing import List, Optional
2426

@@ -30,6 +32,7 @@
3032
def load_robot_description(
3133
description_name: str,
3234
joints_list: Optional[List[str]] = None,
35+
commit: Optional[str] = None,
3336
) -> idyn.Model:
3437
"""
3538
Load a robot description in iDynTree.
@@ -48,6 +51,8 @@ def load_robot_description(
4851
ValueError:
4952
If the description is not URDF, or iDynTree is unable to load it.
5053
"""
54+
if commit is not None:
55+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
5156
module = import_module(f"robot_descriptions.{description_name}")
5257
if not hasattr(module, "URDF_PATH"):
5358
raise ValueError(f"{description_name} is not a URDF description")

robot_descriptions/loaders/mujoco.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33
#
44
# Copyright 2022 Stéphane Caron
5+
# Copyright 2023 Inria
56
#
67
# Licensed under the Apache License, Version 2.0 (the "License");
78
# you may not use this file except in compliance with the License.
@@ -19,12 +20,16 @@
1920
Load a robot description in MuJoCo.
2021
"""
2122

23+
import os
2224
from importlib import import_module # type: ignore
25+
from typing import Optional
2326

2427
import mujoco
2528

2629

27-
def load_robot_description(description_name: str) -> mujoco.MjModel:
30+
def load_robot_description(
31+
description_name: str, commit: Optional[str] = None
32+
) -> mujoco.MjModel:
2833
"""
2934
Load a robot description in MuJoCo.
3035
@@ -34,6 +39,8 @@ def load_robot_description(description_name: str) -> mujoco.MjModel:
3439
Returns:
3540
Robot model for MuJoCo.
3641
"""
42+
if commit is not None:
43+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
3744
module = import_module(f"robot_descriptions.{description_name}")
3845
if not hasattr(module, "MJCF_PATH"):
3946
raise ValueError(f"{description_name} is not an MJCF description")

robot_descriptions/loaders/pinocchio.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Load a robot description in Pinocchio.
2020
"""
2121

22+
import os
2223
from importlib import import_module # type: ignore
2324
from typing import Optional, Union
2425

@@ -44,6 +45,7 @@
4445
def load_robot_description(
4546
description_name: str,
4647
root_joint: Optional[PinocchioJoint] = None,
48+
commit: Optional[str] = None,
4749
) -> pin.RobotWrapper:
4850
"""
4951
Load a robot description in Pinocchio.
@@ -57,6 +59,8 @@ def load_robot_description(
5759
Returns:
5860
Robot model for Pinocchio.
5961
"""
62+
if commit is not None:
63+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
6064
module = import_module(f"robot_descriptions.{description_name}")
6165
robot = pin.RobotWrapper.BuildFromURDF(
6266
filename=module.URDF_PATH,

robot_descriptions/loaders/pybullet.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
Load a robot description in PyBullet.
2020
"""
2121

22+
import os
2223
from importlib import import_module # type: ignore
24+
from typing import Optional
2325

2426
import pybullet
2527

2628

27-
def load_robot_description(description_name: str) -> int:
29+
def load_robot_description(
30+
description_name: str, commit: Optional[str] = None
31+
) -> int:
2832
"""
2933
Load a robot description in PyBullet.
3034
@@ -34,6 +38,8 @@ def load_robot_description(description_name: str) -> int:
3438
Returns:
3539
Identifier of the robot in PyBullet.
3640
"""
41+
if commit is not None:
42+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
3743
module = import_module(f"robot_descriptions.{description_name}")
3844
if not hasattr(module, "URDF_PATH"):
3945
raise ValueError(f"{description_name} is not a URDF description")

robot_descriptions/loaders/robomeshcat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
<https://github.com/petrikvladimir/RoboMeshCat>`_.
2121
"""
2222

23+
import os
2324
from importlib import import_module # type: ignore
25+
from typing import Optional
2426

2527
import robomeshcat
2628

2729
from .pinocchio import get_package_dirs
2830

2931

30-
def load_robot_description(description_name: str) -> robomeshcat.Robot:
32+
def load_robot_description(
33+
description_name: str, commit: Optional[str] = None
34+
) -> robomeshcat.Robot:
3135
"""
3236
Load a robot description in RoboMeshCat.
3337
@@ -37,6 +41,8 @@ def load_robot_description(description_name: str) -> robomeshcat.Robot:
3741
Returns:
3842
Robot model for RoboMeshCat.
3943
"""
44+
if commit is not None:
45+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
4046
module = import_module(f"robot_descriptions.{description_name}")
4147
robot = robomeshcat.Robot(
4248
urdf_path=module.URDF_PATH,

robot_descriptions/loaders/yourdfpy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
Load a robot description in yourdfpy.
2020
"""
2121

22+
import os
2223
from importlib import import_module # type: ignore
24+
from typing import Optional
2325

2426
try:
2527
import yourdfpy
@@ -30,7 +32,9 @@
3032
) from e
3133

3234

33-
def load_robot_description(description_name: str) -> yourdfpy.URDF:
35+
def load_robot_description(
36+
description_name: str, commit: Optional[str] = None
37+
) -> yourdfpy.URDF:
3438
"""
3539
Load a robot description in yourdfpy.
3640
@@ -40,6 +44,8 @@ def load_robot_description(description_name: str) -> yourdfpy.URDF:
4044
Returns:
4145
Robot model for yourdfpy.
4246
"""
47+
if commit is not None:
48+
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
4349
module = import_module(f"robot_descriptions.{description_name}")
4450
if not hasattr(module, "URDF_PATH"):
4551
raise ValueError(f"{description_name} is not a URDF description")

0 commit comments

Comments
 (0)