Ask Your Question

const Eigen::Affine3d; rotation()

asked 2018-06-14 09:32:12 -0500

JonasG gravatar image

Hey, I have solved the forward kinematics with moveit.

kinemtic_state->setJointGroupPositions(joint_model_group, joint_values);
const Eigen::Affine3d &arm_link_5_state = kinematic_state->getGlobalLinkTransform("arm_link_5");

x = arm_link_5_state.translation().x();
y = arm_link_5_state.translation().y();
z = arm_link_5_state.translation().z();

xx = arm_link_5_state.rotation().??;
xy = arm_link_5_state.rotation().??;
xz = arm_link_5_state.rotation().??;

I don't know how to assign the value of xx, xy, xz of the rotation matrix.

I tried:

   xx = arm_link_5_state.rotation().xx();
   xx = arm_link_5_state.rotation().x().x();
   xx = arm_link_5_state.rotation().nx();
   xx = arm_link_5_state.rotation(0,0);

Error: const LinearMatrixType has no member named xx

I don't find the class where it is declared.

It would be great if someone can help me out.

Best regards, Jonas

edit retag flag offensive close merge delete


The accessor for the linear part of the affine transform is .linear(), not .rotation(). See docs here.

stevejp gravatar imagestevejp ( 2018-06-14 11:44:48 -0500 )edit

.linear().xx()? I don't find it in the doc.

JonasG gravatar imageJonasG ( 2018-06-14 11:47:18 -0500 )edit

Check out this tutorial and if you still can't figure it out update your question.

stevejp gravatar imagestevejp ( 2018-06-14 11:56:04 -0500 )edit

In my code I print the rotation with

ROS_INFO_STREAM("Rotation: " << arm_link_5_state.rotation());

and that works well.

I want to extract the individual values of the rotation matrix.

Thanks for your help @stevejp

JonasG gravatar imageJonasG ( 2018-06-14 11:57:53 -0500 )edit

Now it works.

Thanks for that @stevejp

JonasG gravatar imageJonasG ( 2018-06-14 12:21:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-14 12:15:45 -0500

stevejp gravatar image

Ah I misspoke earlier, .rotation() is fine for pulling out the rotation matrix. To access individual elements you can do Eigen::Matrix3d rot = arm_link_5_state.rotation(), and then xx = rot(0,0), etc.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-06-14 09:32:12 -0500

Seen: 793 times

Last updated: Jun 14 '18