8 from typing
import Tuple
10 from .
import WITH_HPP_FCL, WITH_HPP_FCL_BINDINGS
11 from .
import pinocchio_pywrap_default
as pin
13 nle = pin.nonLinearEffects
17 filename, *args, **kwargs
18 ) -> Tuple[pin.Model, pin.GeometryModel, pin.GeometryModel]:
19 """Parse the URDF file given in input and return a Pinocchio Model followed by corresponding GeometryModels of types specified by geometry_types, in the same order as listed.
21 - filename - name of the urdf file to load
22 - package_dirs - where the meshes of the urdf are located. (default - None)
23 - root_joint - Joint at the base of the model (default - None)
24 - root_joint_name - Name for the root_joint (default - "root_joint")
25 - verbose - print information of parsing (default - False)
26 - meshLoader - object used to load meshes (default - hpp::fcl::MeshLoader)
27 - geometry_types - Which geometry model to load. Can be pin.GeometryType.COLLISION, pin.GeometryType.VISUAL or both. (default - [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL])
29 Tuple of the models, in this order : model, collision model, and visual model.
32 model, collision_model, visual_model = buildModelsFromUrdf(filename, root_joint, verbose, meshLoader, geometry_types, root_joint_name="root_joint_name")
34 Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons, it is treated as operational frame and not as a joint of the model.
37 arg_keys = [
"package_dirs",
"root_joint",
"verbose",
"meshLoader",
"geometry_types"]
39 if isinstance(args[2], str):
49 for key, arg
in zip(arg_keys, args):
50 if key
in kwargs.keys():
51 raise TypeError(
"Function got multiple values for argument ", key)
66 ) -> Tuple[pin.Model, pin.GeometryModel, pin.GeometryModel]:
67 if geometry_types
is None:
68 geometry_types = [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL]
70 if root_joint
is None:
71 model = pin.buildModelFromUrdf(filename)
72 elif root_joint
is not None and root_joint_name
is None:
73 model = pin.buildModelFromUrdf(filename, root_joint)
75 model = pin.buildModelFromUrdf(filename, root_joint, root_joint_name)
77 if verbose
and not WITH_HPP_FCL
and meshLoader
is not None:
79 "Info: MeshLoader is ignored. Pinocchio has not been compiled with HPP-FCL."
81 if verbose
and not WITH_HPP_FCL_BINDINGS
and meshLoader
is not None:
83 "Info: MeshLoader is ignored. The HPP-FCL Python bindings have not been installed."
85 if package_dirs
is None:
90 if not hasattr(geometry_types,
"__iter__"):
91 geometry_types = [geometry_types]
93 for geometry_type
in geometry_types:
94 if meshLoader
is None or (
not WITH_HPP_FCL
and not WITH_HPP_FCL_BINDINGS):
95 geom_model = pin.buildGeomFromUrdf(
96 model, filename, geometry_type, package_dirs=package_dirs
99 geom_model = pin.buildGeomFromUrdf(
103 package_dirs=package_dirs,
104 mesh_loader=meshLoader,
106 lst.append(geom_model)
113 Call createData() on each Model or GeometryModel in input and return the results in
114 a tuple. If one of the models is None, the corresponding data object in the result
117 return tuple([
None if model
is None else model.createData()
for model
in models])
121 filename, *args, **kwargs
122 ) -> Tuple[pin.Model, pin.GeometryModel, pin.GeometryModel]:
123 """Parse the Sdf file given in input and return a Pinocchio Model and a list of Constraint Models, followed by corresponding GeometryModels of types specified by geometry_types, in the same order as listed.
125 - filename - name of the urdf file to load
126 - package_dirs - where the meshes of the urdf are located. (default - None)
127 - root_joint - Joint at the base of the model (default - None)
128 - root_link_name - Name of the body to use as root of the model (default - "")
129 - root_joint_name - Name for the root_joint (default - "root_joint")
130 - parent_guidance - Joint names which should be preferred for cases where two joints can qualify as parent. The other joint appears in the constraint_model. If empty, joint appearance order in .sdf is taken as default.
131 - verbose - print information of parsing (default - False)
132 - meshLoader - object used to load meshes (default - hpp::fcl::MeshLoader)
133 - geometry_types - Which geometry model to load. Can be pin.GeometryType.COLLISION, pin.GeometryType.VISUAL, both or None. (default - None])
135 Tuple of the models, in this order : model, collision model, and visual model.
138 model, collision_model, visual_model = buildModelsFromSdf(filename, root_joint, root_link_name, parent_guidance, verbose, meshLoader, geometry_types, root_joint_name="root_joint_name")
152 if isinstance(args[3], str):
164 for key, arg
in zip(arg_keys, args):
165 if key
in kwargs.keys():
166 raise TypeError(
"Function got multiple values for argument ", key)
178 root_joint_name=None,
179 parent_guidance=None,
184 if parent_guidance
is None:
187 if geometry_types
is None:
188 geometry_types = [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL]
190 if root_joint
is None:
191 model, constraint_models = pin.buildModelFromSdf(
192 filename, root_link_name, parent_guidance
194 elif root_joint
is not None and root_joint_name
is None:
195 model, constraint_models = pin.buildModelFromSdf(
196 filename, root_joint, root_link_name, parent_guidance
199 model, constraint_models = pin.buildModelFromSdf(
200 filename, root_joint, root_link_name, root_joint_name, parent_guidance
202 if verbose
and not WITH_HPP_FCL
and meshLoader
is not None:
204 "Info: MeshLoader is ignored. Pinocchio has not been compiled with HPP-FCL."
206 if verbose
and not WITH_HPP_FCL_BINDINGS
and meshLoader
is not None:
208 "Info: MeshLoader is ignored. The HPP-FCL Python bindings have not been installed."
210 if package_dirs
is None:
213 lst = [model, constraint_models]
215 if not hasattr(geometry_types,
"__iter__"):
216 geometry_types = [geometry_types]
218 for geometry_type
in geometry_types:
219 if meshLoader
is None or (
not WITH_HPP_FCL
and not WITH_HPP_FCL_BINDINGS):
220 geom_model = pin.buildGeomFromSdf(
221 model, filename, geometry_type, root_link_name, package_dirs
224 geom_model = pin.buildGeomFromSdf(
225 model, filename, geometry_type, root_link_name, package_dirs, meshLoader
227 lst.append(geom_model)
233 """Parse the Mjcf file given in input and return a Pinocchio Model followed by corresponding GeometryModels of types specified by geometry_types, in the same order as listed.
235 - filename - name of the urdf file to load
236 - package_dirs - where the meshes of the urdf are located. (default - None)
237 - root_joint - Joint at the base of the model (default - None)
238 - root_joint_name - Name for the root_joint (default - "root_joint")
239 - verbose - print information of parsing (default - False)
240 - meshLoader - object used to load meshes (default - hpp::fcl::MeshLoader)
241 - geometry_types - Which geometry model to load. Can be pin.GeometryType.COLLISION, pin.GeometryType.VISUAL or both. (default - [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL])
242 - contacts - Boolean to know if contraint models are wanted (default - False)
244 Tuple of the models, in this order : model, collision model, and visual model, or model, constraint_list, collision model, and visual model, if contacts is True.
247 model, collision_model, visual_model = buildModelsFromMJCF(filename, root_joint, verbose, meshLoader, geometry_types, root_joint_name="root_joint_name")
250 arg_keys = [
"root_joint",
"verbose",
"meshLoader",
"geometry_types",
"contacts"]
252 if isinstance(args[1], str):
262 for key, arg
in zip(arg_keys, args):
263 if key
in kwargs.keys():
264 raise TypeError(
"Function got multiple values for argument ", key)
274 root_joint_name=None,
280 if geometry_types
is None:
281 geometry_types = [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL]
284 if root_joint
is None:
285 model = pin.buildModelFromMJCF(filename)
286 elif root_joint
is not None and root_joint_name
is None:
287 model = pin.buildModelFromMJCF(filename, root_joint)
289 model, contact_models = pin.buildModelFromMJCF(
290 filename, root_joint, root_joint_name
293 if verbose
and not WITH_HPP_FCL
and meshLoader
is not None:
295 "Info: MeshLoader is ignored. Pinocchio has not been compiled with HPP-FCL."
297 if verbose
and not WITH_HPP_FCL_BINDINGS
and meshLoader
is not None:
299 "Info: MeshLoader is ignored. "
300 "The HPP-FCL Python bindings have not been installed."
305 lst.append(contact_models)
307 if not hasattr(geometry_types,
"__iter__"):
308 geometry_types = [geometry_types]
310 for geometry_type
in geometry_types:
311 if meshLoader
is None or (
not WITH_HPP_FCL
and not WITH_HPP_FCL_BINDINGS):
312 geom_model = pin.buildGeomFromMJCF(model, filename, geometry_type)
314 geom_model = pin.buildGeomFromMJCF(
315 model, filename, geometry_type, mesh_loader=meshLoader
317 lst.append(geom_model)