Issue with Matlab-function 'rpy2r()'

196 views
Skip to first unread message

Matthias Domnik

unread,
Jun 20, 2018, 3:43:52 PM6/20/18
to Robotics & Machine Vision Toolboxes
Hello,

I pretty sure that there is something wrong with the function 'rpy2r()'. When I choose the 'xyz'-convention, the following code will be executed:

case {'xyz', 'arm'}
           
% XYZ order
           
if numrows(roll) == 1
                R
= rotx(yaw) * roty(pitch) * rotz(roll);
           
else
                R
= zeros(3,3,numrows(roll));
               
for i=1:numrows(roll)
                    R
(:,:,i) = rotx(yaw(i)) * roty(pitch(i)) * rotz(roll(i));
               
end
           
end

As you can see, the rotation with respect to the x-axis is performed using the value of yaw and vice versa. Using this convetion delivers me wrong results everytime, but when I switch the arguments of 'rotx' and 'rotz' like this:

% [...]
                R
= rotx(roll) * roty(pitch) * rotz(yaw);
%[...]

Then everything works fine. Is this maybe a bug or am I just wrong?

Thank you in advance.

Best regards
Matthias

Matthias Domnik

unread,
Jun 20, 2018, 3:47:46 PM6/20/18
to Robotics & Machine Vision Toolboxes
I forgot to say that I use release 10.2 of the toolbox.

Erik van Oene

unread,
Jun 28, 2018, 5:27:27 PM6/28/18
to Robotics & Machine Vision Toolboxes
This is a very common misunderstanding .

every text book is mixing up XYZ and ZYX sequences but meaning the same sequence... the difference is that they mean this sequence are w.r.t. to initial frame of the newly obtained frame, which is actually the same as reversing the matrix multiplication.

Erik

Op woensdag 20 juni 2018 21:47:46 UTC+2 schreef Matthias Domnik:

Peter Corke

unread,
Jul 8, 2018, 8:47:53 AM7/8/18
to Robotics & Machine Vision Toolboxes
It is an area of great confusion, and different people think about it in different ways.  roll/pitch/yaw only make sense when you think about a rigid body in space.  XYZ convention makes sense when the axes on the body have Z forward, X up and Y to the right, which is a common frame for a robot end effector (the convention for vehicles is different).  The first thing you do is point the body in the right direction in the horizontal plane, that's the yaw motion and the rotation is about the X axis.  So the first thing we do is rotate about X by the yaw angle.  Next we pitch the body, lift the nose up or down, that's a rotation about the Y axis by the pitch angle.  Finally, we rotate about the body axis, the X axis, by the roll angle.
Reply all
Reply to author
Forward
0 new messages