Disclosure of Invention
The invention aims to provide an inverse solution multi-solution selection and time optimal trajectory planning algorithm for a mechanical arm, which is simple and efficient in algorithm architecture and has the capability of quickly selecting the most appropriate group of solutions from the inverse solution multi-solutions and planning the time optimal trajectory.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the mechanical arm inverse solution multi-solution selection and time optimal trajectory planning algorithm is characterized in that: on the basis of a kinematic forward solution and a kinematic inverse solution, the overall algorithm framework of the method is composed of: the method comprises an inverse solution multi-solution selection algorithm and a time optimal trajectory planning algorithm. The general idea of solving the multi-solution selection algorithm is as follows: and performing forward-inverse solution or inverse-forward solution conversion according to the current pose of the mechanical arm, and taking the inverse solution with the minimum norm of the difference between the conversion result and the current pose of the mechanical arm as the most appropriate solution. The overall idea of the time optimal trajectory planning algorithm is as follows: and (3) carrying out track planning by using a seventh polynomial track planning method, calculating values corresponding to all constraint conditions under the track, verifying whether the values are equal to constraint condition thresholds or not, if not, taking the difference value between the values and the corresponding constraint condition thresholds to carry out proportional control and negative feedback to the original track planning time so as to reduce the difference value, and simultaneously, distinguishing and determining whether the negative feedback is carried out on different constraint conditions or not by using activation conditions.
Taking the point-to-point trajectory planning of a five-degree-of-freedom mechanical arm in a Cartesian space as an example, the algorithm comprises the following four steps:
the first step is as follows: a kinematic positive solution.
Firstly, establishing a mechanical arm base coordinate system {0}, each joint coordinate system {1,2.3.4} and a terminal coordinate system {5}, and establishing a mechanical arm D-H parameter table according to mechanical arm structure parameters;
TABLE 1.1D-H PARAMETER TABLE FOR MECHANICAL ARM
Secondly, obtaining a homogeneous transformation matrix among the coordinates according to the established coordinate system and the D-H parameter table of the mechanical arm; from the coordinate system oi-1-xi-1yi-1zi-1To the coordinate system oi-xiyiziIs transformed into
Thirdly, according to the homogeneous transformation matrix between the base coordinate system and the tail end coordinate system of the mechanical arm
The position of the robot arm tip relative to the base coordinate system and the pose of the robot arm tip relative to the base coordinate system are obtained, i.e., the kinematic positive solution p of the robot arm is Forward _ kinematics (θ), where p is [ x y z α β γ ═ y]To know the pose of the end of the arm, θ ═ θ1 θ2 θ3 θ4 θ5]The calculated joint angles of the robot.
The second step is that: inverse kinematics solution.
(i) can be obtained from the formula (2)
The first column and the fourth column of equation (2) are made equal, so that six equations can be obtained;
based on the six equations obtained above, the equation can be solved in turn to obtain theta1Two solutions of, each theta1Can determine theta5Two solutions of (each group of (theta)1,θ5) Can determine theta3Two solutions of (a) and then finding theta1A solution of (a) and theta4A solution of (a); summarizing, a total of eight solutions, i.e., Inverse kinematics solution θ of the mechanical arm — Inverse of Inverse kinematics (i, p), (i ∈ [1,8]), can be obtained])。
The third step: trajectory planning based on a seventh order polynomial.
In order to ensure that the acceleration is continuous and avoid the shock caused by sudden acceleration when the mechanical arm is started and stopped, a seventh-order polynomial can be adopted for optimization, and the optimization aim is to ensure that the acceleration is continuously derivable, namely the acceleration of a planning starting point and a terminal point of a constraint track is large. The specific mechanical arm tail end track planning formula is
Secondly, constraint conditions are given, namely the positions, the speeds, the angular speeds and the acceleration of the starting point and the end point are respectively as follows:
substituting formula (5) for formula (4) to obtain the coefficients of a seventh-order polynomial
Namely, the seven-degree polynomial track planning which aims at acceleration continuous guidance is completed.
The fourth step: and optimizing the track.
The inverse solution multi-solution selection algorithm: first, a set of solutions i ═ 1 is sequentially selected from eight sets of solutions of the inverse arm solution, (i ∈ [1,8], and]) (ii) a Then, reading the current joint angle theta of the mechanical arm ═ theta1 θ2 θ3 θ4 θ5]Carrying out forward solution according to the current pose of the mechanical arm to obtain the current end pose, and carrying out inverse solution according to the current end pose to obtain each joint angle theta under the i-th group of inverse solutionsi=[θi1 θi2 θi3 θi4 θi5]Finally compare | θi-θ|≤εθIn which epsilonθFor self-defining an angle threshold value, the method is used for distinguishing the most appropriate solution from eight sets of inverse solutions, if thetai-θ|≤εθIf the solution is satisfied, the solution is the optimal solution; if not, another group of inverse solutions is taken for recalculation and comparison;
time optimal trajectory optimization algorithm based on condition proportional control
The algorithm can be divided into two cases:
case 1: the angular velocity of the planned trajectory obtained in the third step
And angular acceleration
Although all meet the actuator specification, i.e. the maximum angular velocity at which the joint can execute
And angular acceleration
But with a planning time T equal to T
f-t
0Longer, not optimal, where t
0,t
fThe times of passing the starting point and the ending point, respectively. At this point, the planning time needs to be reduced to achieve time optimization while meeting actuator specifications.
Case 2: the angular velocity of the planned trajectory obtained in the third step
And angular acceleration
Albeit greater than the actuator specification, i.e. the maximum angular velocity at which the joint can execute
And angular acceleration
The simplest solution at this time is to increase the planning time to achieve time optimization while meeting the actuator specifications.
According to the two situations, the time controller based on the condition proportional control can be designed without iteration, is simple and easy to realize and combines the proportional-integral-derivative (PID) control principle:
wherein
The adjusting parameters are respectively the error adjusting parameters of the speed and the acceleration in the time optimal controller, and are similar to the proportional parameters in the PID control principle. Whether the proportional control in equation (7) is activated depends on whether its corresponding actuator specification is satisfied, i.e., the origin of the conditional proportional control. In particular, it is possible to use, for example,
and
may be defined individually by joints or axes. Under ideal conditions, the planning time T is T ═ T
f-t
0When the optimal angular velocity and angular acceleration of the planned trajectory are equal to the maximum angular velocity and angular acceleration allowed by the actuator specifications, i.e. the angular velocity and angular acceleration of the planned trajectory are equal to the maximum angular velocity and angular acceleration allowed by the actuator specifications
In addition, according to the requirements of multiple constraints and multiple targets, the maximum jerk term and other kinematic and dynamic constraint terms are required to be added into the right formula (7). In order to improve the transient performance of the time-optimal controller, integral control and derivative control are also required to be added with reference to PID control.
The algorithm must first discuss
case 1 and discuss
case 2 to ensure that constraints such as actuator specifications are fully satisfied. Firstly, initializing planning parameters: planning starting point p
0Planning an end point p
fPlanning exercise time T ═ T
f-t
0(ii) a Secondly, interpolating and planning the track based on a seventh-order polynomial:
the resulting inverse solution is again used to find each joint angle:
finally, whether
situation 1 is satisfied is determined:
if so, the planning time T-T is reduced by equation (7)
f-t
0Replanning the track; if not,
case 2 is entered. In
case 2, as in
case 1, first based onAnd (3) a seventh-order polynomial interpolation planning track:
the resulting inverse solution is again used to find each joint angle:
finally, whether situation 2 is satisfied is determined: if so, increasing the programming time T-T by equation (7)f-t0Replanning the track; if not, case 2 exits. The two case discussion ends.
Output (c)
The algorithm ends as a given of the joint control.
In the algorithm, the order of polynomial interpolation track planning is determined by specific track planning requirements, and is not limited to seven times; in joint space, in continuous trajectory planning, the algorithm can obtain the same effect; the algorithm is also suitable for other multi-degree-of-freedom mechanical arms or series robots with multiple inverse solutions.
Compared with the prior art, the invention has the following beneficial effects: the inverse solution multi-solution selection and time optimal trajectory planning algorithm for the mechanical arm, provided by the invention, does not adopt an iteration principle, is simple and efficient in algorithm architecture, has the capability of quickly selecting the most appropriate one group of solutions from the inverse solution multi-solutions and planning the time optimal trajectory, can quickly select the most appropriate one group of solutions from the inverse solution multi-solutions according to the current pose of the mechanical arm, effectively avoids a singular position type, realizes smooth switching among different inverse solutions, and ensures the continuity and non-oscillation of control and action of the mechanical arm; and a trajectory planning method combining the seventh polynomial and the conditional proportional control is utilized to plan a trajectory with optimal time, so that smooth and continuous guidance of joint angles, angular velocities, angular accelerations and angular jerks is ensured, multi-target and multi-constraint conditions are met, and the actuator specifications, such as joint angular velocity maximum value constraint or joint angular acceleration maximum value constraint, are met. The algorithm greatly reduces the calculation amount of multi-solution selection and trajectory planning, can realize real-time and efficient time optimal trajectory planning, and can be popularized and applied to low-calculation force controllers.
Detailed Description
The invention is further explained with reference to the drawings.
The invention aims to provide an inverse solution multi-solution selection and time optimal trajectory planning algorithm for a mechanical arm, which is simple and efficient in algorithm architecture and has the capability of quickly selecting the most appropriate group of solutions from the inverse solution multi-solutions and planning the time optimal trajectory.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the mechanical arm inverse solution multi-solution selection and time optimal trajectory planning algorithm is characterized in that: on the basis of a kinematic forward solution and a kinematic inverse solution, the overall algorithm framework of the method is composed of: the method comprises an inverse solution multi-solution selection algorithm and a time optimal trajectory planning algorithm. The general idea of solving the multi-solution selection algorithm is as follows: and performing forward-inverse solution or inverse-forward solution conversion according to the current pose of the mechanical arm, and taking the inverse solution with the minimum norm of the difference between the conversion result and the current pose of the mechanical arm as the most appropriate solution. The overall idea of the time optimal trajectory planning algorithm is as follows: and (3) carrying out track planning by using a seventh polynomial track planning method, calculating values corresponding to all constraint conditions under the track, verifying whether the values are equal to constraint condition thresholds or not, if not, taking the difference value between the values and the corresponding constraint condition thresholds to carry out proportional control and negative feedback to the original track planning time so as to reduce the difference value, and simultaneously, distinguishing and determining whether the negative feedback is carried out on different constraint conditions or not by using activation conditions.
As shown in fig. 1, taking a five-degree-of-freedom mechanical arm to perform point-to-point trajectory planning in cartesian space as an example, the algorithm includes the following four steps:
the first step is as follows: a kinematic positive solution.
Firstly, as shown in FIG. 2, establishing a mechanical arm basic coordinate system {0}, each joint coordinate system {1,2.3.4} and a terminal coordinate system {5}, and establishing a mechanical arm D-H parameter table according to mechanical arm structure parameters;
TABLE 1.1D-H PARAMETER TABLE FOR MECHANICAL ARM
Secondly, obtaining a homogeneous transformation matrix among the coordinates according to the established coordinate system and the D-H parameter table of the mechanical arm; from the coordinate system oi-1-xi-1yi-1zi-1To the coordinate system oi-xiyiziIs transformed into
Thirdly, according to the homogeneous transformation matrix between the base coordinate system and the tail end coordinate system of the mechanical arm
Obtaining a coordinate system of the end of the robot arm relative to the baseThe position of the robot arm tip and the attitude of the robot arm tip relative to the base coordinate system, i.e., the kinematic positive solution of the robot arm, p, Forward _ kinematics (θ), where p is [ x y z α β γ ═ y]To know the pose of the end of the arm, θ ═ θ1 θ2 θ3 θ4 θ5]The calculated joint angles of the robot.
The second step is that: inverse kinematics solution.
(i) can be obtained from the formula (2)
The first column and the fourth column of equation (2) are made equal, so that six equations can be obtained;
based on the six equations obtained above, the equation can be solved in turn to obtain theta1Two solutions of, each theta1Can determine theta5Two solutions of (each group of (theta)1,θ5) Can determine theta3Two solutions of (a) and then finding theta1A solution of (a) and theta4A solution of (a); summarizing, a total of eight solutions, i.e., Inverse kinematics solution θ of the mechanical arm — Inverse of Inverse kinematics (i, p), (i ∈ [1,8]), can be obtained])。
The third step: trajectory planning based on a seventh order polynomial.
In order to ensure that the acceleration is continuous and avoid the shock caused by sudden acceleration when the mechanical arm is started and stopped, a seventh-order polynomial can be adopted for optimization, and the optimization aim is to ensure that the acceleration is continuously derivable, namely the acceleration of a planning starting point and a terminal point of a constraint track is large. The specific mechanical arm tail end track planning formula is
Secondly, constraint conditions are given, namely the positions, the speeds, the angular speeds and the acceleration of the starting point and the end point are respectively as follows:
substituting formula (5) for formula (4) to obtain the coefficients of a seventh-order polynomial
Namely, the seven-degree polynomial track planning which aims at acceleration continuous guidance is completed.
The fourth step: and optimizing the track.
The inverse solution multi-solution selection algorithm: first, a set of solutions i ═ 1 is sequentially selected from eight sets of solutions of the inverse arm solution, (i ∈ [1,8], and]) (ii) a Then, reading the current joint angle theta of the mechanical arm ═ theta1 θ2 θ3 θ4 θ5]Carrying out forward solution according to the current pose of the mechanical arm to obtain the current end pose, and carrying out inverse solution according to the current end pose to obtain each joint angle theta under the i-th group of inverse solutionsi=[θi1 θi2 θi3 θi4 θi5]Finally compare | θi-θ|≤εθIn which epsilonθFor self-defining an angle threshold value, the method is used for distinguishing the most appropriate solution from eight sets of inverse solutions, if thetai-θ|≤εθIf the solution is satisfied, the solution is the optimal solution; if not, another group of inverse solutions is taken for recalculation and comparison;
time optimal trajectory optimization algorithm based on condition proportional control
The algorithm can be divided into two cases:
case 1: the angular velocity of the planned trajectory obtained in the third step
And angular acceleration
Although all meet the actuator specification, i.e. the maximum angular velocity at which the joint can execute
Angle of harmonyAcceleration of a vehicle
But with a planning time T equal to T
f-t
0Longer, not optimal, where t
0,t
fThe times of passing the starting point and the ending point, respectively. At this point, the planning time needs to be reduced to achieve time optimization while meeting actuator specifications.
Case 2: the angular velocity of the planned trajectory obtained in the third step
And angular acceleration
Albeit greater than the actuator specification, i.e. the maximum angular velocity at which the joint can execute
And angular acceleration
The simplest solution at this time is to increase the planning time to achieve time optimization while meeting the actuator specifications.
According to the two situations, the time controller based on the condition proportional control can be designed without iteration, is simple and easy to realize and combines the proportional-integral-derivative (PID) control principle:
wherein
The adjusting parameters are respectively the error adjusting parameters of the speed and the acceleration in the time optimal controller, and are similar to the proportional parameters in the PID control principle. Whether the proportional control in equation (7) is activated depends on whether its corresponding actuator specification is satisfied, i.e., the origin of the conditional proportional control. In particular, it is possible to use, for example,
and
may be defined individually by joints or axes. Under ideal conditions, the planning time T is T ═ T
f-t
0When the optimal angular velocity and angular acceleration of the planned trajectory are equal to the maximum angular velocity and angular acceleration allowed by the actuator specifications, i.e. the angular velocity and angular acceleration of the planned trajectory are equal to the maximum angular velocity and angular acceleration allowed by the actuator specifications
In addition, according to the requirements of multiple constraints and multiple targets, the maximum jerk term and other kinematic and dynamic constraint terms are required to be added into the right formula (7). In order to improve the transient performance of the time-optimal controller, integral control and derivative control are also required to be added with reference to PID control.
The algorithm must first discuss
case 1 and discuss
case 2 to ensure that constraints such as actuator specifications are fully satisfied. Firstly, initializing planning parameters: planning starting point p
0Planning an end point p
fPlanning exercise time T ═ T
f-t
0(ii) a Secondly, interpolating and planning the track based on a seventh-order polynomial:
the resulting inverse solution is again used to find each joint angle:
finally, whether
situation 1 is satisfied is determined:
if so, the planning time T-T is reduced by equation (7)
f-t
0Replanning the track; if not,
case 2 is entered. In
case 2, as in
case 1, the trajectory is first interpolated based on a seventh order polynomial:
the resulting inverse solution is again used to find each joint angle:
finally, whether situation 2 is satisfied is determined: if so, increasing the programming time T-T by equation (7)f-t0Replanning the track; if not, case 2 exits. The two case discussion ends.
Output (c)
The algorithm ends as a given of the joint control.
The algorithm flow chart is shown in fig. 3. Fig. 4-9 are the results of the trajectory planning optimization from point to point in cartesian space, which are: each joint angle, each joint angular velocity, each joint angular acceleration, each joint angular jerk, the tip position, and the tip attitude. Fig. 10-11 are time optimization processes with initial planning times of 10s and 20s, respectively.
In the algorithm, the order of polynomial interpolation track planning is determined by specific track planning requirements, and is not limited to seven times; in joint space, in continuous trajectory planning, the algorithm can obtain the same effect; the algorithm is also suitable for other multi-degree-of-freedom mechanical arms or series robots with multiple inverse solutions.
Compared with the prior art, the invention has the following beneficial effects: the inverse solution multi-solution selection and time optimal trajectory planning algorithm for the mechanical arm, provided by the invention, does not adopt an iteration principle, is simple and efficient in algorithm architecture, has the capability of quickly selecting the most appropriate one group of solutions from the inverse solution multi-solutions and planning the time optimal trajectory, can quickly select the most appropriate one group of solutions from the inverse solution multi-solutions according to the current pose of the mechanical arm, effectively avoids a singular position type, realizes smooth switching among different inverse solutions, and ensures the continuity and non-oscillation of control and action of the mechanical arm; and a trajectory planning method combining the seventh polynomial and the conditional proportional control is utilized to plan a trajectory with optimal time, so that smooth and continuous guidance of joint angles, angular velocities, angular accelerations and angular jerks is ensured, multi-target and multi-constraint conditions are met, and the actuator specifications, such as joint angular velocity maximum value constraint or joint angular acceleration maximum value constraint, are met. The algorithm greatly reduces the calculation amount of multi-solution selection and trajectory planning, can realize real-time and efficient time optimal trajectory planning, and can be popularized and applied to low-calculation force controllers.