|
7 | 7 | # Load the URDF model using a free-flyer as root joint
|
8 | 8 | model = pinocchio.buildModelFromUrdf("/home/ubuntu/ws_ros/src/auv_controllers/ik_solvers/examples/urdf/uvms.urdf", pinocchio.JointModelFreeFlyer())
|
9 | 9 |
|
10 |
| -joint_names_to_lock = [ |
11 |
| - "alpha_rs1_130_joint", |
12 |
| - "alpha_rs1_139_joint", |
13 |
| - "alpha_axis_a", |
14 |
| - "thruster1_joint", |
15 |
| - "thruster2_joint", |
16 |
| - "thruster3_joint", |
17 |
| - "thruster4_joint", |
18 |
| - "thruster5_joint", |
19 |
| - "thruster6_joint", |
20 |
| - "thruster7_joint", |
21 |
| - "thruster8_joint" |
22 |
| -] |
23 |
| - |
24 |
| -# Convert the joint names to joint IDs |
25 |
| -joint_ids_to_lock = [ |
26 |
| - model.getJointId(name) for name in joint_names_to_lock if model.existJointName(name) |
27 |
| -] |
| 10 | +controlled_joints = ["universe", "root_joint", "alpha_axis_b", "alpha_axis_c", "alpha_axis_d", "alpha_axis_e"] |
| 11 | +locked_joints = [model.getJointId(model.names[idx]) for idx, joint in enumerate(model.joints) if model.names[idx] not in controlled_joints] |
28 | 12 |
|
29 | 13 | q_ref = pinocchio.neutral(model)
|
30 |
| -model = pinocchio.buildReducedModel(model, joint_ids_to_lock, q_ref) |
| 14 | +model = pinocchio.buildReducedModel(model, locked_joints, q_ref) |
31 | 15 | data = model.createData()
|
32 | 16 |
|
33 |
| -# rot = R.random() |
34 |
| -q = pinocchio.neutral(model) |
35 |
| -# q[:3] = np.random.rand(3) |
36 |
| -# q[3:7] = rot.as_quat().reshape(-1) |
37 |
| - |
38 |
| -for idx, joint in enumerate(model.joints): |
39 |
| - joint_name = model.names[idx] |
40 |
| - nq = joint.nq # Number of configuration variables for this joint |
41 |
| - print(f"{joint_name}: index in q = {joint.idx_q}, nq = {nq}") |
42 |
| - |
43 |
| -print(q) |
44 |
| -print(len(q)) |
45 |
| - |
46 |
| -# Perform the forward kinematics over the kinematic tree |
47 |
| -pinocchio.forwardKinematics(model, data, q) |
48 |
| -pinocchio.updateFramePlacements(model, data) |
49 |
| -pinocchio.computeJointJacobians(model, data, q) |
50 |
| - |
51 |
| -# # Get the index of the base link |
52 |
| -joint_name = "alpha_axis_b" |
53 |
| -joint_id = model.getJointId(joint_name) |
54 |
| -joint_idx = model.joints[joint_id].idx_v |
55 |
| - |
56 |
| -frame_name = "alpha_tcp" |
57 |
| -frame_id = model.getFrameId(frame_name) |
58 |
| -print(f"Frame ID of {frame_name}: {frame_id}") |
59 |
| - |
60 |
| -J = pinocchio.getFrameJacobian(model, data, model.getFrameId(frame_name), pinocchio.ReferenceFrame.LOCAL_WORLD_ALIGNED) |
61 |
| -# J = pinocchio.getJointJacobian(model, data, joint_id, pinocchio.ReferenceFrame.LOCAL) |
62 |
| - |
63 |
| -print(f"Jacobian of {joint_name}:") |
64 |
| -print(J) |
| 17 | +for i, joint in enumerate(model.names): |
| 18 | + print(model.getJointId(joint), joint) |
0 commit comments