Skip to content

Commit 607e648

Browse files
Pop environment variable after import in all loaders
1 parent 57dd40c commit 607e648

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

robot_descriptions/loaders/idyntree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ def load_robot_description(
3939
ValueError:
4040
If the description is not URDF, or iDynTree is unable to load it.
4141
"""
42-
if commit is not None:
42+
if commit is not None: # technical debt, see #31
4343
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
4444
module = import_module(f"robot_descriptions.{description_name}")
45+
if commit is not None:
46+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
4547
if not hasattr(module, "URDF_PATH"):
4648
raise ValueError(f"{description_name} is not a URDF description")
4749

robot_descriptions/loaders/mujoco.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def load_robot_description(
2828
Returns:
2929
Robot model for MuJoCo.
3030
"""
31-
if commit is not None:
31+
if commit is not None: # technical debt, see #31
3232
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
3333
module = import_module(f"robot_descriptions.{description_name}")
34+
if commit is not None:
35+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
3436
if not hasattr(module, "MJCF_PATH"):
3537
raise ValueError(f"{description_name} is not an MJCF description")
3638

robot_descriptions/loaders/pinocchio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ def load_robot_description(
4848
Returns:
4949
Robot model for Pinocchio.
5050
"""
51-
if commit is not None:
51+
if commit is not None: # technical debt, see #31
5252
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
5353
module = import_module(f"robot_descriptions.{description_name}")
54+
if commit is not None:
55+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
5456
robot = pin.RobotWrapper.BuildFromURDF(
5557
filename=module.URDF_PATH,
5658
package_dirs=get_package_dirs(module),

robot_descriptions/loaders/pybullet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ def load_robot_description(
3838
Returns:
3939
Integer identifier of the robot in PyBullet.
4040
"""
41-
if commit is not None:
41+
if commit is not None: # technical debt, see #31
4242
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
4343
module = import_module(f"robot_descriptions.{description_name}")
44+
if commit is not None:
45+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
4446
if not hasattr(module, "URDF_PATH"):
4547
raise ValueError(f"{description_name} is not a URDF description")
4648

robot_descriptions/loaders/robomeshcat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ def load_robot_description(
3333
Returns:
3434
Robot model for RoboMeshCat.
3535
"""
36-
if commit is not None:
36+
if commit is not None: # technical debt, see #31
3737
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
3838
module = import_module(f"robot_descriptions.{description_name}")
39+
if commit is not None:
40+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
3941
robot = robomeshcat.Robot(
4042
urdf_path=module.URDF_PATH,
4143
mesh_folder_path=get_package_dirs(module),

robot_descriptions/loaders/yourdfpy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ def load_robot_description(
3434
Returns:
3535
Robot model for yourdfpy.
3636
"""
37-
if commit is not None:
37+
if commit is not None: # technical debt, see #31
3838
os.environ["ROBOT_DESCRIPTION_COMMIT"] = commit
3939
module = import_module(f"robot_descriptions.{description_name}")
40+
if commit is not None:
41+
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
4042
if not hasattr(module, "URDF_PATH"):
4143
raise ValueError(f"{description_name} is not a URDF description")
4244

0 commit comments

Comments
 (0)