File tree Expand file tree Collapse file tree 6 files changed +38
-4
lines changed
robot_descriptions/loaders Expand file tree Collapse file tree 6 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 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.
1920Load a robot description in iDynTree.
2021"""
2122
23+ import os
2224from importlib import import_module # type: ignore
2325from typing import List , Optional
2426
3032def 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" )
Original file line number Diff line number Diff line change 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.
1920Load a robot description in MuJoCo.
2021"""
2122
23+ import os
2224from importlib import import_module # type: ignore
25+ from typing import Optional
2326
2427import 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" )
Original file line number Diff line number Diff line change 1919Load a robot description in Pinocchio.
2020"""
2121
22+ import os
2223from importlib import import_module # type: ignore
2324from typing import Optional , Union
2425
4445def 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 ,
Original file line number Diff line number Diff line change 1919Load a robot description in PyBullet.
2020"""
2121
22+ import os
2223from importlib import import_module # type: ignore
24+ from typing import Optional
2325
2426import 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" )
Original file line number Diff line number Diff line change 2020<https://github.com/petrikvladimir/RoboMeshCat>`_.
2121"""
2222
23+ import os
2324from importlib import import_module # type: ignore
25+ from typing import Optional
2426
2527import robomeshcat
2628
2729from .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 ,
Original file line number Diff line number Diff line change 1919Load a robot description in yourdfpy.
2020"""
2121
22+ import os
2223from importlib import import_module # type: ignore
24+ from typing import Optional
2325
2426try :
2527 import yourdfpy
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" )
You can’t perform that action at this time.
0 commit comments