Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with buildReducedModel #2313

Open
stephane-caron opened this issue Jul 4, 2024 Discussed in #2311 · 2 comments
Open

Error with buildReducedModel #2313

stephane-caron opened this issue Jul 4, 2024 Discussed in #2311 · 2 comments

Comments

@stephane-caron
Copy link
Collaborator

stephane-caron commented Jul 4, 2024

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 #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.

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!

@Zionshang
Copy link

I haven't looked at your URDF file in detail, but it's probably because some names of joint in the URDF are same as some names of link. You need to check the urdf in detail.

@maymohan
Copy link

@Zionshang You were right!

In case anyone else has the same issue, I changed the joint names of the following joints by adding the suffix "_fixed": head_camera, right_hand, right_hand_camera, right_hand_camera_axis, right_hand_range, right_hand_accelerometer, right_gripper_base, left_hand, left_hand_camera, left_hand_camera_axis, left_hand_range, left_hand_accelerometer, left_gripper_base.

My modified URDF file can be found on my fork of the Rethink SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants