## 3 Materials and Methods  
Consider the problem of finding the inverse kinematics at a fixed position \(P\) and orientation of the gripper at angle \(\alpha\) (Figure 6). The algorithm for finding IK, taking into account the types of solutions, is based on the following main idea: Searching for a solution from the gripper to the base of the robot. Step 1. Input data. The number of rotational joints n is known. Input: The lengths of the links \(a_{i}\) (if there are translational connections, it is necessary to determine the change of the corresponding lengths \(a_{kmin}\leq a_{k}\leq a_{kmax}\)); The joint constraints \(\theta_{imin}\leq\theta_{i}\leq\theta_{imax}\) of the rotational joints; The coordinates \(P_{x}\) and \(P_{y}\) of point \(P\) from the gripper; If it is necessary to take into account the orientation of the gripper, the angle \(\alpha\) is entered, otherwise it is assumed that point \(P_{n}\equiv P\). Step 2. Determining point \(P_{n}\). If angle \(\alpha\) is set, the coordinates of point \(P_{n}\) are:  
\[ \begin{array}{l}\left|P_{nx}=P_{x}+a_{g}cos\alpha\right.\\ P_{ny}=P_{y}+a_{g}sin\alpha\end{array}  \tag{7}\]  
Step 3. Checking if point \(P_{n}\) is reachable  
Reachability is a problem that depends on the lengths of the links, i.e., the proportions between them and the joint constraints. It is assumed that initially no joint restrictions are imposed and the problem is divided into two parts: maximally distant points--external reachability limit--and points that cannot be reached with folded links--internal reachability limit (Figure 8). The condition for external reachability to point P_n can be intuitively determined:  
\[\sqrt{P_{nx}^{2}+P_{ny}^{2}}\leq R=\sum_{i=1}^{n}a_{i}+a_{g} \tag{8}\]  
Point \(P_{n}\) is reachable if inequality (8) is satisfied. Here, \(P_{nx}\) and \(P_{ny}\) are the coordinates of a point \(P_{n}\), that the robot is trying to reach. This inequality (8) defines a circle with center at the base of the robot and radius R.  
Figure 7: Basic steps of the algorithm for solving IK. The second condition--of internal reachability--is more complicated to define. If the longest link \(a_{imax}\) is shorter than the sum of all other links and no joint constraints are imposed, all points of the circle with radius R (8) are reachable. An inner circle centered at the base of the robot, which is not reachable, appears if \(a_{imax}\) is longer than the sum of all other links (Figure 8). The radius r of this circle is calculated from:  
\[\sqrt{P_{nx}^{2}+P_{ny}^{2}}\geq r=a_{imax}-\sum_{i=1}^{m}a_{i}+a_{g} \tag{9}\]  
In this case, point \(P_{n}\) is reachable if inequalities (8) and (9) are satisfied. In this step, a check can also be performed for a unique solution, which occurs if \(P_{n}\) lies on a circle defined by Equations (8) or (9). Step 4. Setting the number and distribution of points on the circles. The number of circles for which points must be generated depends on the number n of robot links. It also determines the number of nested loops. Thus, if there are no translational connections, the number of nested loops k will be:  
\[k=n-2 \tag{10}\]  
Since it is not necessary to rotate the gripper and the first two links of the robot. The number of points and the manner of their distribution on the generated circles is set. A simple option is to set evenly distributed points along the circle. The number of points increases the precision of the algorithm, but also increases the calculations and the time for its execution. Step 5. Nested loops for defining points of interest. Points \(P_{c(i,j)}\), belonging to a circle with center \(P_{i}\) and radius \(R_{i}=a_{i}\), are defined. In the algorithm given in Figure 7 this is done using polar coordinates and increasing the angle \(\gamma\) (see Figure 6). Syntax from Visual LISP for AutoCAD is used, which has built-in functions for working with geometric objects. For example, the function {polar < point angle distance>} defines a new point relative to a previous one using polar coordinates.