shortcuts.py
Go to the documentation of this file.
1 #
2 # Copyright (c) 2018-2020 CNRS INRIA
3 #
4 
5 ## In this file, some shortcuts are provided ##
6 
7 from . import pinocchio_pywrap as pin
8 from . import WITH_HPP_FCL, WITH_HPP_FCL_BINDINGS
9 
10 nle = pin.nonLinearEffects
11 
12 def buildModelsFromUrdf(filename, package_dirs=None, root_joint=None, verbose=False, meshLoader=None, geometry_types=[pin.GeometryType.COLLISION,pin.GeometryType.VISUAL]):
13  """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.
14  Examples of usage:
15  # load model, collision model, and visual model, in this order (default)
16  model, collision_model, visual_model = buildModelsFromUrdf(filename[, ...], geometry_types=[pin.GeometryType.COLLISION,pin.GeometryType.VISUAL])
17  model, collision_model, visual_model = buildModelsFromUrdf(filename[, ...]) # same as above
18 
19  model, collision_model = buildModelsFromUrdf(filename[, ...], geometry_types=[pin.GeometryType.COLLISION]) # only load the model and the collision model
20  model, collision_model = buildModelsFromUrdf(filename[, ...], geometry_types=pin.GeometryType.COLLISION) # same as above
21  model, visual_model = buildModelsFromUrdf(filename[, ...], geometry_types=pin.GeometryType.VISUAL) # only load the model and the visual model
22 
23  model = buildModelsFromUrdf(filename[, ...], geometry_types=[]) # equivalent to buildModelFromUrdf(filename[, root_joint])
24  """
25 
26  if root_joint is None:
27  model = pin.buildModelFromUrdf(filename)
28  else:
29  model = pin.buildModelFromUrdf(filename, root_joint)
30 
31  if verbose and not WITH_HPP_FCL and meshLoader is not None:
32  print('Info: MeshLoader is ignored. Pinocchio has not been compiled with HPP-FCL.')
33  if verbose and not WITH_HPP_FCL_BINDINGS and meshLoader is not None:
34  print('Info: MeshLoader is ignored. The HPP-FCL Python bindings have not been installed.')
35  if package_dirs is None:
36  package_dirs = []
37 
38  lst = [model]
39 
40  if not hasattr(geometry_types, '__iter__'):
41  geometry_types = [geometry_types]
42 
43  for geometry_type in geometry_types:
44  if meshLoader is None or (not WITH_HPP_FCL and not WITH_HPP_FCL_BINDINGS):
45  geom_model = pin.buildGeomFromUrdf(model, filename, geometry_type, package_dirs)
46  else:
47  geom_model = pin.buildGeomFromUrdf(model, filename, geometry_type, package_dirs, meshLoader)
48  lst.append(geom_model)
49 
50  return tuple(lst)
51 
52 def createDatas(*models):
53  """Call createData() on each Model or GeometryModel in input and return the results in a tuple.
54  If one of the models is None, the corresponding data object in the result is also None.
55  """
56  return tuple([None if model is None else model.createData() for model in models])
def createDatas(models)
Definition: shortcuts.py:52
def buildModelsFromUrdf(filename, package_dirs=None, root_joint=None, verbose=False, meshLoader=None, geometry_types=[pin.GeometryType.COLLISION, pin, GeometryType, VISUAL)
Definition: shortcuts.py:12


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04