0

Say that I have a fixed point $X$ in the world frame of reference (that I'm gonna call $X^{\{w\}}$). Moreover, I have a flying robot that can be anywhere in this space.

Its position in the world is denoted $P^{\{w\}}$. The robot can not only move freely but it can also rotate freely in all three axes.

Using $X^{\{w\}}$, $P^{\{w\}}$ and the 3 angle rotations on the three axes made by the robot ($\phi_{x}$, $\phi_{y}$ and $\phi_{z}$), how can I obtain $X^{\{P\}}$ (the point $X$ as seen by the robot)?

Edit: by the angles $\phi_{x}$, $\phi_{y}$ and $\phi_{z}$, I mean the robot's roll, pitch and yaw. An illustration of the angle $\phi_{z}$ in the 2D XY plane:

Robot's position <span class=$P$ and angle $\phi_z$ in 2D">

  • Are the three angles sequential rotations (first do x then rotate about the new y etc) or are they related to angles that the current robot frame makes with the world frames axes? – Michael Stachowsky Nov 16 '18 at 11:45
  • If sequential, what order are they done in? – Michael Stachowsky Nov 16 '18 at 11:45
  • They are the angular differences between the robot's axis and the world frame axes. For example, imagining that the robot is at point $(0,0,0)$, $\phi_x$ is the angle between the robot's X axis and world's X axis (basically, the robot's orientation). – ebernardes Nov 16 '18 at 11:48
  • They are not sequential, the robot can rotate in all 3 axes freely and at the same time. – ebernardes Nov 16 '18 at 11:49
  • I think you need to be a little more specific before we can get the solution, which is ultimately just going to be a translation matrix. The robot's x axis has 3 such orientation angles - one with the world's x, y, and z axes. All told there are 9 orientation angles, which are usually represented as the cosines of their angles for computational reasons and are known as the "direction cosines". Some are redundant. With the direction cosines you can get your rotation matrix – Michael Stachowsky Nov 16 '18 at 13:17
  • The thing is, I'm trying to find a general solution to this problem. The robot can "see" the point somehow (in its own reference frame), and I know the exact position of the robot and its exact orientation.

    I wanna know the general solution (which will indeed be a matrix equation) to find the point's position in the world frame, giving everything that I have.

    – ebernardes Nov 16 '18 at 14:35
  • Indeed. Luckily this is a very well solved problem so I can help you with the solution. However, there are many ways to solve it. The easiest way is to get a set of 3 angles and a point. The interpretation of those angles is what really matters, though. In your description of the three angles you have, you do not have enough information to solve the problem. Can you edit the question to explain exactly what those three angles are? I think from there we can compute what you need – Michael Stachowsky Nov 16 '18 at 15:02
  • Sorry for the misunderstanding, the angles I have are the robot's classical roll, pitch and yaw angles inside a well-defined world reference frame. Thanks a lot for your help! – ebernardes Nov 16 '18 at 15:15
  • I added a simple 2D illustration to show you one of the angles. – ebernardes Nov 16 '18 at 15:27
  • It basically becomes solving a linear equation system one time for every time instance we have matrices representing the mobile frame for. We need to know the order the rotations are applied so that we can find the rotation matrix. – mathreadler Nov 16 '18 at 17:08

1 Answers1

2

NOTE: this answer is the "easy" method. There are a lot of different and more efficient ways to represent rotations, but this will solve your problem.

To begin we need to define three rotation matrices: each one representing a rotation about a different axis. More information here. We have:

Rotate about the x axis:

$$R_x(\theta_x) = \begin{bmatrix} 1 & 0 &0 \\ 0 & \cos(\theta_x) & -\sin(\theta_x) \\ 0 & \sin(\theta_x) & \cos(\theta_x) \end{bmatrix}$$

Rotate about the y axis:

$$R_y(\theta_y) = \begin{bmatrix} \cos(\theta_y) & 0 & \sin(\theta_y) \\ 0 & 1 & 0 \\ -\sin(\theta_y) & 0 & \cos(\theta_y) \end{bmatrix}$$

Rotate about the z axis:

$$R_z(\theta_z) = \begin{bmatrix} \cos(\theta_z) & -\sin(\theta_z) &0 \\ \sin(\theta_z) & \cos(\theta_z) & 0 \\ 0 & 0 & 1 \end{bmatrix}$$

We now need to figure out an order of rotation. This is usually up to you and for much more information please see here. For now we'll just assume you're doing the order x-y-z. It's up to you to figure out the order you want! Once you rotate with one matrix your coordinate axes move, so the order is semi-important. As long as you are consistent you're OK.

With the order I chose, you need to create a rotation matrix, $R = R_z(\theta_z)R_y(\theta_y)R_x(\theta_x)$. Note the order of the matrices - x is the first rotation, and thus it appears at the end of that expression.

We are now about to do something odd and something else that is convenient.

The odd thing: The rotation matrix will only rotate a vector, but it will not translate a point. You know $X^{\{W\}}$ and want that point in the robot's frame, but the robot and the world do not share an origin. You'll need to simultaneously rotate the point so that it is referenced with respect to the robot's coordinate axes, and then translate it so that the point is reckoned from the robot's origin.

The convenient thing: I'm very lazy today. I'm going to assume that you actually have $X^{\{P\}}$ and you want $X^{\{W\}}$, instead of what you said. This is because you have the robot's angles but a world point. In order to go the other way you need to figure out the opposite angles - what are the orientations of the world's axis with respect to the robot. There are negatives involved.

There are MANY ways to do this. If you just need to know and don't want a single matrix equation, then the answer is:

$$X^{\{W\}} = RX^{\{P\}} - P^{\{W\}}$$

This is read as: "First we rotate the point so that the point's coordinates are with respect to a frame that is centered at the world's origin but oriented to align with the robot. Next, we move the point into a new frame so that the origin is where the robot is.

  • Thanks a lot! Just a last question: If I want to find the X_P from X_W, I'd have to inverse this rotation matrix. Would it be the same as multiplying all the three simple rotation matrices in the reverse order (and switching the signal of the 3 angles)? – ebernardes Nov 21 '18 at 15:34
  • Yes, that's correct – Michael Stachowsky Nov 22 '18 at 01:54