stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.67k stars 357 forks source link

Error with buildReducedModel #2313

Open stephane-caron opened 5 days ago

stephane-caron commented 5 days ago

I can reproduce the issue from the discussion below using this minimal example:

from robot_descriptions.loaders.pinocchio import load_robot_description

robot = load_robot_description("baxter_description")
reduced_model = pin.buildReducedModel(robot.model, [], robot.q0)

It seems related to the Baxter description (if we replace baxter_description with e.g. upkie_description, then buildReducedModel returns normally).

Discussed in https://github.com/stack-of-tasks/pinocchio/discussions/2311

Originally posted by **maymohan** July 2, 2024 Hello, I recently started using Pinocchio and am interested in building a reduced model for a single arm of a Baxter robot. I followed the example in the wiki. But, I get the following error: ` ValueError: Several frames match the filter - please specify the FrameType ` Here is a minimum working example of my code: ``` import pinocchio as pin import numpy as np # Build the model pinocchio_model_dir = "./models/" mesh_dir = pinocchio_model_dir urdf_filename = ("./baxter.urdf") # Load the urdf model model, collision_model, visual_model = pin.buildModelsFromUrdf(urdf_filename, mesh_dir) # Build the reduced model relevantJoints = ['right_s0', 'right_s1', 'right_e0', 'right_e1', 'right_w0', 'right_w1', 'right_w2'] jointsToLockIDs = [] initialJointConfig = np.array([0, #head 0, 0,0, 0.1,0,0,0, # Left arm 0, 0,0, 0.1,0,0,0 ])# Right arm for name in model.names: if not name in relevantJoints: if model.existJointName(name): jointsToLockIDs.append(model.getFrameId(name)) else: print('Warning: joint ' + str(name) + ' does not belong to the model!') model_reduced = pin.buildReducedModel(model, visual_model, jointsToLockIDs, initialJointConfig) ``` Here is [Baxter's URDF](https://github.com/RethinkRobotics/baxter_common/blob/master/baxter_description/urdf/baxter.urdf). I looked around quite a bit and could not find anyway to resolve the issue. I would appreciate any help in resolving the issue. Please let me know if I can provide any other information. Thank you for your help!