# Transformation a robot in 2D?

I'm watching this video at 36.00 min. The guy gave an example but I'm not sure what is the problem. He stated that if we want to move a robot then we should to the following

for inhomogeneous case, $$x' = Rx + t \\ R = \begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix}$$ where $t$ is the translation vector and $x$ is the previous position.

in homogeneous case, $$x' = \begin{bmatrix} R & \bf{t} \\ \bf{0}^{T} & 1 \end{bmatrix} x$$ Now, he gave an example in which $$t = \begin{bmatrix} 1 \\ 0 \end{bmatrix} , x = \begin{bmatrix} 0.7 \\ 0.5 \end{bmatrix}$$ My solution is as the following in Matlab

% inhomogeneous case
>> a = 45;
>> R = [cosd(a) -sind(a); sind(a) cosd(a)];
>> t = [1; 0];
>> x = [0.7; 0.5];
>> xnew = R*x + t
xnew =

1.1414
0.8485


For homogeneous case

>> xn = [R t; 0 0 1]*[x ; 1]

xn =

1.1414
0.8485
1.0000


Both have same result, but the guy got another result. What exactly he did is

>> xf = [R x; 0 0 1]*[t ; 1]

xf =

1.4071
1.2071
1.0000


Why he did switch $t$ and $x$? I'm aware of the issue that he is trying to calculate the velocity but in fact he is computing the position. This mistake in the notation won't affect the final result.

Second question, why he assumed that the forward movement of the robot in the above example should be $$t = \begin{bmatrix}1\\0\end{bmatrix}$$ ? He said that because the robot always in the forward movement move in +x axis. Why this is the case? The movement in robot's frame is determined based on the direction of the robot and the distance the robot travels which is specified as hypotenuse length.

The problem is that the rotation matrix describes the rotation around the coordinate system center and not around the center of the robot, so here's what happens.

You wish to add to the robot position a vector which is oriented the same as he is (which is described by R), so how do you do this. You take a vector t which is rotated by 0 degrees (that is [1; 0] because of the angle convention), you multiply it by intensity (which is 1 because of 1m/s), you rotate it so it has the same direction as your robot (because it should move forward) and then you add that vector to the current position (which is described by x).

So you in the end you get x'=R*t+x which is the same thing he did.

EDIT: I forgot to mention that this is much easier to remember in homogeneous representation:

S=[R R x; R R y; 0 0 1]

which represents the "state" of the robot (it's position and orientation, as I mentioned, if it's looking to the right along x axis its angle is 0). So when you multiply the state of the robot with transformation matrix you get the new state. Transformation matrix is in the exact shape as the state matrix, so it's A=[R R tx; R R ty; 0 0 1]. So if you want only to translate the robot you make [R R; R R] identity matrix [1 0; 0 1], and if you want only to rotate the robot you make tx=ty=0. You can both rotate and translate the robot at the same time like this but keep in mind that the robot will first translate and then rotate (that is, it will translate with respect to the old orientation, not the new one). If you wish to rotate and then translate it, make a rotation transformation matrix and multiply it by the translation transformation matrix and then use that matrix as the transformation matrix which you will multiply with the state matrix (right side multiply as always). Order of matrices is of course important as matrix multiplication is not commutative.

Regards

First of all thanx for sharing a good video i have me first lecture of Computer vision tomorrow so i revised all the matrix and vector operations. Its been a while when i last studied these things

OK your Second Question The assumption is made to simplify the problem to understand .if we have a robot with too many variables changing at the same time it will become complicated. So we assume just for the sake of simplicity When i first studied we used to assume a simple robot just going forward to understand control theory.

Now the First Question Why you answer is wrong

Simple Logic(just plot the values with a graph) : robot was at x,y(0.7,0.5).it then moves another 1 Meter forward .which will end up increasing x and y eventually :) If your answer is right then the increased difference in your answer will give answer 1 by Pythagoras theorem

a^2 + b^2 = c^2


We cannot apply this x′=[R0Tt1]x formula straight forward because the teacher in the video said the distance of 1 meter it traveled is Local.

To change that local distance to global he uses the method Matrix multiplication with Vector.

There can be a lot more dicussion that can be done in solving these kind of questions.thats why i am posting the answer to see your response

• I'm sorry but I'm not convinced by either answers. Saying for the sake of simplicity makes no sense to me. If the robot is moving in a planar environment then the robot must be represented as a Cartesian coordinates ($x,y$) or polar coordinates ($p, \theta$). For the forward movement, the direction must be specified in advance whether in global or local frames otherwise the definition of forward should be investigated. The forward movement of a rigid body is simply the distance the rigid body travels in the direction of its heading. Feb 6 '14 at 5:11
• For the first question, I'm not sure but I think the formula should be $x' = R*t + x$ not $x' = R*x + t$ to get same answer. Feb 6 '14 at 5:12
• By the way, I found this formula in another book. this is why once I switch t and x I got the correct result which is the length of hypotenuse by doing $$\sqrt{(1.4071-0.7)^{2} + (1.2071-0.5)^{2}} = 1$$ Feb 6 '14 at 5:22
• You are right "The forward movement of a rigid body is simply the distance the rigid body travels in the direction of its heading" thats why he said its an assumption
– Neo
Feb 6 '14 at 5:48
• my friend i think you dont understand Translations.please refer the book where you found the formula
– Neo
Feb 6 '14 at 5:55