LESSON

# Multi-dimensional trajectory

#### Share

#### Transcript

Many machines and robots have got multiple axis of motion. An industrial robot typically has six joints and they have to move smoothly and in a coordinated fashion. A technique we can use to help us is linear interpolation. Consider this simple function here where x of s is a function of an initial value of x and a final value of x. And, s varies from 0 to 1. In this case, then, x of s is some sort of intermediate value. X of 0 is the initial value, x of 1 is the final value, and x of 0.5 is halfway in between the initial and final value. Now, x could be a vector which makes the multi-dimensional case quite straightforward. For instance, it could be the xyz position of some sort of machine or simple robot. So, x is a vector with the three elements xyz and we can interpolate linearly between an initial position, an initial xyz and a final xyz. S is a scalar which varies from 0 to 1.

So, what is s? Well, S is a scalar that varies smoothly from 0 to 1. And, if S is a smooth function of time, then x will be a smooth function of time since x is simply a linear function of S. We already know how to make a smoothly varying function of time. It can be a polynomial function of time or it could be a trapezoidal velocity profile function of time. Let’s look at a two-dimensional example. We want to move in the xy plane and I’ve got a starting point and an ending point. Now, I want to move in a straight line from the start to the end. I’m going to assign some arbitrary coordinates to the start and the end. We’re back in MATLAB and now our first point is a vector, not a scalar. So, the first point is the coordinate 10, 20, and our last point is a vector 30, 10. And this time, I’m going to use the function jtraj, stands for joint interpolated trajectory. I’m going to move from the first point to the last point in 50 time steps, and we see it all scrolling past. If we scroll back, we see that the first point has indeed got the vector value of 10 and 20, and the last point has got the value of 30 and 10.

Let’s plot x as a function of time and we can see here that our first axis has moved from 10 up to 30, second axis has moved from 20 down to 10. This function also returns the velocity. So, I can add that as an extra output argument, XD. And now, we see x velocity as well and I can plot XD versus time, and we can see that the velocity of each axis starts and ends at 0 and has a finite value in between. The function also allows me to specify an initial and final velocity for the trajectory. So, if I ask for the initial velocity to be 0 which is the default condition, if I ask for the final velocity to be equal to 10. Now, if I plot the trajectory versus time, we can see that at the end of a trajectory, the slopes of a line are not equal to 0 and that’s because it is achieving its destination position at a finite velocity as we specified.

Let’s consider a more complex two-dimensional example. I’m going to start and end at this point in the XY plane. I’m going to move to this point, this point, this point, and back to where I started from. So, there are now three via points. I can assign some arbitrary coordinates to these. In order to move smoothly through the via points, we need to introduce blends and we talked about blends in a previous section. Here, we want to apply this idea of blends which, in this example, is shown for a scalar variable x. We want to apply it to a multi-dimensional case because now we’re talking about a robot moving in the xy plane.

So now, each of the positions XI is a vector rather than a scalar. Now, we’re going to look at a scenario where points on the trajectory are vector quantities, two-vector in this case, and we have via points. Let’s do this square trajectory in MATLAB.

Our starting coordinate is 40, 50 and the via points are 60, 30 which is one row of the matrix, 40, 10 which is another row of the matrix, 20, 30 and we finish where we started. And, that’s the list of via points. Now, I use the Toolbox function, mstraj. I pass in the list of via points. Passing the speed at which we’re going to move along the path, the time of the segments is default. Now, start coordinate. The time step, 0.1 seconds and the acceleration time, which I'm going to consider to be just 1 second. And, I’ve created in the workspace variable x. It’s got 435 rows, so that means that the trajectory took 435 time steps to execute each time steps 0.1 seconds. That’s 43.5 second to execute.

I can plot x versus time and we can see the trajectory of the first and second coordinates versus time first coordinate shown in blue. If I plot the first coordinate against the second coordinate, so that could be the x coordinate and that could be the y coordinate. I have a plot like this. So, this shows the motion of the point on the xy plane and, indeed, it has the square profile that we are looking for, but it’s got rounded corners because we have specified a finite acceleration time. Let’s consider now an extra degree of difficulty. Let’s consider that the machine is capable of moving at 2 meters a second in the x direction, but only 1 meter per second in the y direction.

We need to take this in to account when we figure the trajectory for the robot. Consider again this two-dimensional example and this is the path that we want from the start to the end, that’s our desired path. But if the robot is capable of moving more quickly in the x direction than in the y direction, the path might look something like this. It will go very, very quickly in the x direction and also move a little bit in the y direction. But then, the x-axis will have achieved its goal, so it will stop moving. But, the y-axis which is moving more slowly has to keep on going, and so we end up with this dogleg path instead of our desired path. If I was cutting material on something like a flatbed profiling machine, then I’d be rather upset if I had this path rather than the desired one.

So in order to achieve the desired path, we need to take in to account the velocity of each of the axes. We need to work out how long the slowest axis requires to get to the next via point. And then, we scale the velocity of the other axes so that they all arrive at the same time at the via point, and then they all set off again to the next via point. We repeat this process indefinitely.

Now, we’re going to repeat the trajectory, but this time we are going to specify the velocities of the axis being different. So, previously, the velocity was 2 units per second in the x and y direction. Now, I’m going to specify a very slow x-axis, only 1 unit per second, and a fast y-axis. If we now look at the trajectory level in our workspace, we see it’s got 835 rows, 0.1 second time step, so that means the trajectory now takes 83 seconds, almost twice as long. And, that’s to be expected because, now, the trajectory is being paced by the slowest axis.

The slowest axis now can only move at only 1 unit per second. Previously, it was 2 units per second, so we are limited now by an axis which is half the original speed, the trajectory has taken roughly twice as long to execute. I can plot x versus time. We can see the 835 time steps and I can plot x versus y.

We learn to compute a trajectory that involves simultaneous smooth motion of many robot joints.

### Skill level

Undergraduate mathematics

This content assumes high school level mathematics and requires an understanding of undergraduate-level mathematics; for example, linear algebra - matrices, vectors, complex numbers, vector calculus and MATLAB programming.