ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion; myQuaternion.setRPY(0,0,a); myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.x. ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. Hope this helps

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;
 myQuaternion.setRPY(0,0,a);
myQuaternion.normalize();

myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.x. ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;

myQuaternion.setRPY(0,0,a);

myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.x. ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

and this is only for yaw, of course you can exchange the first two 0 with whatever you want

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;

myQuaternion.setRPY(0,0,a);

myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.x. myQuaternion.getX() ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

and this is only for yaw, of course you can exchange the first two 0 with whatever you want

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;

myQuaternion.setRPY(0,0,a);

myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.getX() ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. everything. But this can be the reason, why your result looked different than the one from the online calculator. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

and this is only for yaw, of course you can exchange the first two 0 with whatever you want

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;

myQuaternion.setRPY(0,0,a);

myQuaternion.normalize();
myQuaternion=myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.getX() ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. But this can be the reason, why your result looked different than the one from the online calculator. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

and this is only for yaw, of course you can exchange the first two 0 with whatever you want

I'll just post my code i am using for this since there isn't much to explain about it:

tf2::Quaternion myQuaternion;

myQuaternion.setRPY(0,0,a);
myQuaternion.setRPY(r,p,y);

myQuaternion=myQuaternion.normalize();

and you are done.

you then get the quaternion parts with e.g myQuaternion.getX() ...

The normalize part is only in there since i had issues in the past with not normalized quaternions being rejected by some libraries so i just normalize everything. But this can be the reason, why your result looked different than the one from the online calculator. Hope this helps

EDIT: you need the following libraries: tf2/LinearMath/Quaternion.h

and this is only for yaw, of course you can exchange the first two 0 with whatever you want