2121
2222from importlib import import_module # type: ignore
2323from typing import List , Optional
24- from .._package_dirs import get_package_dirs
2524
2625import idyntree .swig as idyn
2726
27+ from .._package_dirs import get_package_dirs
28+
2829
29- def load_robot_description (description_name : str ,
30- joints_list : Optional [List [str ]] = None ,
30+ def load_robot_description (
31+ description_name : str ,
32+ joints_list : Optional [List [str ]] = None ,
3133) -> idyn .Model :
3234 """
3335 Load a robot description in iDynTree.
3436
3537 Args:
3638 description_name: Name of the robot description.
37- joints_list: Optional parameter containing the list of the joints considered
38- in the model. If empty, the model will contain all the joints
39- specified in the urdf , otherwise a reduced model containing
40- only the specified joints is created.
39+ joints_list: Optional parameter containing the list of joints
40+ considered in the model. If empty, the model will contain all the
41+ joints specified in the URDF , otherwise a reduced model containing
42+ only the specified joints is created.
4143
4244 Returns:
4345 Identifier of the robot in iDynTree.
44-
46+
4547 Raises:
4648 ValueError:
4749 If the description is not URDF, or iDynTree is unable to load it.
@@ -52,17 +54,20 @@ def load_robot_description(description_name: str,
5254
5355 model_loader = idyn .ModelLoader ()
5456
55- if (joints_list is None ):
56- if not model_loader .loadModelFromFile (module .URDF_PATH , \
57- 'urdf' , \
58- get_package_dirs (module )):
59- raise ValueError (f"Unable to load { description_name } with iDynTree" )
57+ if joints_list is None :
58+ if not model_loader .loadModelFromFile (
59+ module .URDF_PATH , "urdf" , get_package_dirs (module )
60+ ):
61+ raise ValueError (
62+ f"Unable to load { description_name } with iDynTree"
63+ )
6064 else :
61- if not model_loader .loadReducedModelFromFile (module .URDF_PATH , \
62- joints_list , \
63- 'urdf' , \
64- get_package_dirs (module )):
65- raise ValueError (f"Unable to load { description_name } with iDynTree" )
65+ if not model_loader .loadReducedModelFromFile (
66+ module .URDF_PATH , joints_list , "urdf" , get_package_dirs (module )
67+ ):
68+ raise ValueError (
69+ f"Unable to load { description_name } with iDynTree"
70+ )
6671
6772 robot = model_loader .model ().copy ()
6873 return robot
0 commit comments