The next big step to take during the second approach is to force the robot to follow a predetermined path. How? Using a linear interpolation. Although with the joint’s interpolation there wasn’t any huge problem, this time it's completely different. Let me start the explanation with a little bit of theory.

When the robot is at the point P1, and its aim is to move to the position named P2, it has two ways to reach the target. With joints interpolation or with linear interpolation. In the first case the manipulator calculate an angular path of each connector. Let's say joints parameters of position P1 will be 0 deg in J1, 20 deg in J2, -15 deg in J3, 0 deg in J5 and the same in J6. To simplify the notation we will use registration like these: P1(0 20 -15 0 0). And so, the second location is: P2(0 -10 0 10 0). Algorithm will calculate the differences, for J2 it’s -30 deg, for J3 it’s 15 deg and for J5 it’s 10 deg. We know maximum speed for each joint, so we can calculate the slowest change. In our example, the second joint has the longest way to travel, but the slowest joint during this movement is the third one. Therefore we need to divide our angular path of each joint and spread the resulting points accordingly over time to adapt the speed of the resultant movement to the slowest of the joints. It is worth mentioning that all the calculations take place in the joints positioning system, so if P1 and P2 are given in cartesian coordinates, they should be converted into a joints coordinates. How the geometry calculation class works is a quite long story, great for a new topic.

Returning to the previous topic, why linear interpolation is so complicated? Well, first of all, all iterations of interpolation are calculated in cartesian coordinates. This fact alone is nothing significant, because these coordinates are just scalars, so we can divide the path to small vectors and convert them to discrete path made of many points. But now, every of the resulting point have to be calculated to joints positioning system. And due to the fact that the calculation of inverse kinematics is the most difficult task for the controller, it complicates us the whole job. Another trouble is speed setting. During the way from one of resulting mid-points to another with the same linear speed, all joints have a different angular speed (and it’s changing over time). So, if we want to maintain the linear speed of the gripper during the whole movement, we need to predict unknown for us speed of the slowest joint.

However, the calculated points, and especially in this case, settings of each joint, are sended to the motion controlling class. Positions of joints are controlled by independent PID regulators, so in true these coordinates are just an indication of where we would like to place gripper at the right time.

What we could or better should do is to make the algorithm that takes into account also the acceleration of the movement.