Disclosure of Invention
The object of the present invention is to solve at least one of the technical drawbacks mentioned.
Therefore, the invention aims to provide a space track smoothing method based on optimal speed control, which can ensure the continuity of the speed direction, can conveniently position the space position of the end effector of the mechanical arm at any time and is convenient to control.
In order to achieve the above object, an embodiment of the present invention provides a spatial trajectory smoothing method based on optimal speed control, including the following steps:
step S1, acquiring a starting point Ps, a middle point Pm, a terminal point Pe, a preset turning area radius r and a preset parameter flag _ dist of a space track of the robot mechanical arm operation, wherein a first simple track is formed between the starting point Ps and the middle point Pm, and a second simple track is formed between the middle point Pm and the terminal point Pe;
step S2, comparing the preset turning zone radius r with the lengths of the first simple trajectory and the second simple trajectory, and if the preset turning zone radius r does not exceed half of the length of the first simple trajectory and does not exceed half of the length of the second simple trajectory, performing step S3;
step S3, selecting the turning mode of the robot as equal-length turning or equal-time turning, and calculating to obtain the coordinates of a transition point M formed by the intersection of a first simple track and a second simple track and the coordinates of points S and E of the intersection of the first simple track and the second simple track and a preset circle respectively;
and S4, establishing a local coordinate system according to the coordinates of the S, M point and the E point obtained by calculation, and calculating a track equation of the turning area of the space track under the local coordinate system, wherein the track equation is a quadratic curve of the smooth turning area.
Further, in the step S2, it is determined whether the preset turning zone radius r exceeds a half of the length of the first simple trajectory using the following equation,
wherein,is a vector pointing from the starting point Ps to the midpoint Pm,is a vector pointing from the midpoint Pm to the end point Pe.
Further, in the step S3, when the selected turning mode is an equal-length turning, calculating S, M and E point coordinates includes the following steps:
according to the requirement of equal-length turningRespectively superposing the coordinates of the middle points M by adopting a vector superposition method The vector with the length r in the two directions can obtain the starting point coordinate S and the end point coordinate E of the turning area, wherein the middle point M is the point Pm, and the point coordinates of the points S and E are calculated as follows:
further, in the step S3, when the selected turning mode is an equal-time turning mode, the method includes the following steps:
t 1-t 2 are satisfied according to the equal-time turning requirement, wherein t1 is the turning time of the SM section, t2 is the turning time of the ME section,
t=mim(t1,t2),
substituting the speed plan, and calculating to obtain S, E point-to-M point distance dists,distE,
Further, in the step S4, the calculating a trajectory equation of a turning area of the spatial trajectory in the local coordinate system includes the following steps:
step S41, calculating coordinate transformation parameters θ and a, including the steps of:
<math>
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open = '[' close = ']'>
<mtable>
<mtr>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mo>-</mo>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
</mtable>
</mfenced>
<mo>,</mo>
</mrow>
</math>
wherein, theta is the angle of the coordinate axis for rotation transformation, A is the rotation matrix,
step S42, deriving vector coordinatesAndthe method comprises the following steps:
wherein,is composed ofA representation in the local coordinate system is provided,is composed ofA representation in the local coordinate system is provided,
step 43, calculating a trajectory equation y of the turning area of the space trajectory in the local coordinate system as follows:
y=ax2,
wherein,a is a parameter of a quadratic curve corresponding to the trajectory equation, o is S-As, O is the representation of the coordinates of the local coordinate system originally in the global coordinate system, and is the translation part in the coordinate transformation process, S (x)s,ys),m(xm,ym),e(xe,ye) Respectively are the coordinates of the starting point, the middle point and the end point of the turning area.
According to the space track smoothing method based on the speed optimal control, a quadratic curve of a running space track of a robot mechanical arm can be transformed into a smooth turning area expression through coordinates, so that the continuity of the speed direction is guaranteed, a turning scheme with smooth acceleration, speed and displacement is obtained through smooth transition of two straight-line tracks and combination of S-shaped speed planning, the track is simple and visual, the space position of an end effector of the mechanical arm at any moment can be conveniently positioned, and the control is convenient. Meanwhile, the track is a simple quadratic curve, so that the obstacle avoidance space can be simply and conveniently calculated. In addition, the invention can adapt to two turning requirements of equal distance and equal time, and users can conveniently compare and select a better scheme according to actual conditions.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative and intended to be illustrative of the invention and are not to be construed as limiting the invention.
The invention provides a space track smoothing method based on optimal speed control, which utilizes the smoothing characteristic of a quadratic curve to generate the quadratic curve according to the starting point and the end point of two linear paths and the turning radius of a clamped turning area, smoothly connects the two linear paths, and generates a smooth turning area expression by transforming coordinates of the quadratic curve, thereby ensuring the continuity of the speed direction.
As shown in fig. 1, the method for smoothing a spatial trajectory based on optimal speed control according to an embodiment of the present invention includes the following steps:
and step S1, acquiring a starting point Ps, a middle point Pm, an end point Pe, a preset turning area radius r and a preset parameter flag _ dist of a space track of the robot mechanical arm operation. A first simple track is formed between the starting point Ps and the middle point Pm, and a second simple track is formed between the middle point Pm and the end point Pe. The preset parameter flag _ dist is a parameter for taking equidistant turning or isochronous turning, and is equidistant turning when the value is 1, or is isochronous turning otherwise.
FIG. 2 is a schematic diagram of first and second simple traces according to an embodiment of the present invention.
First, the definition of the turning zone is explained: and at a transition point M formed by the intersection of the two simple tracks, taking the transition point as an origin point, taking a certain specific value R as a radius to make a circle, intersecting the two simple tracks at the two points S and E, and taking an area enclosed by the line segments SM, ME and the circular arc ES as a turning area. Referring to fig. 2, the starting point of the first simple trajectory is Ps and the end point is the transition point M; the starting point of the second simple trajectory is M and the end point is Pe. The first and second simple trajectories are both straight trajectories.
Before planning the track of the turning area, determining the plane of the current path by two intersecting simple tracks, establishing a coordinate conversion equation of a two-dimensional plane and a three-dimensional space, and then determining the coordinates of each key point on the two-dimensional plane. The subsequent steps are all performed on this plane.
And step S2, comparing the preset turning zone radius r with the lengths of the first simple track and the second simple track, and if the preset turning zone radius r does not exceed half of the length of the first simple track and does not exceed half of the length of the second simple track, executing step S3.
In the step, the following formula is adopted to judge whether the radius r of the preset turning area exceeds half of the length of the first simple track,
wherein,is a vector pointing to the midpoint Pm from the starting point Ps, i.e. the first simple track in the original tracks,is a vector pointing from the midpoint Pm to the end point Pe, i.e., the second simple trajectory among the original trajectories.
And step S3, selecting the turning mode of the robot as equal-length turning or equal-time turning, and calculating to obtain the coordinates of a transition point M formed by the intersection of the first simple track and the second simple track and the coordinates of the points S and E of the intersection of the first simple track and the second simple track and the preset circle respectively.
Specifically, equidistant planning or isochronous planning is performed according to the starting point Ps, the middle point Pm, the end point Pe and the preset turning area radius r. The equidistant plan can be determined directly from the turning radius r. For isochronous planning, the time from the turning starting point to the transition point is obtained through S-shaped speed planning, and the turning end point position is calculated, so that the coordinates of the turning area starting point and the turning area end point are obtained. That is, the present invention can support both isochronous and equidistant turn zone algorithms based on S-type speed planning.
The following describes the peer planning and isochronous planning separately.
When the selected turning mode is equal-length turning, the calculation of S, M and E point coordinates comprises the following steps:
the turning in the equal length mode requires that the lengths from the turning zone starting point to the turning zone middle point and from the turning zone middle point to the turning zone ending point are equal, namelyAccording to the requirement of equal-length turningRespectively superposing the coordinates of the middle points M (the middle points M are the points Pm) by adopting a vector superposition methodAnd obtaining the coordinates of the starting point S and the ending point E of the turning area by using vectors with the length r in the two directions.
When the selected turning mode is equal-time turning, the method comprises the following steps:
the equal-time turning mode requires that the time from the turning zone starting point to the turning zone middle point and the time from the turning zone middle point to the turning zone ending point are equal, namely t1 is t2, wherein t1 is the turning time of the SM section, t2 is the turning time of the ME section,
t=min(t1,t2),(4)
substituting the speed plan, and calculating to obtain S, E point-to-M point distance dists、dists,
And establishing a local coordinate system according to the S, M, E coordinates calculated in the step S3, and transferring the problem to the local coordinate system for solving through coordinate transformation, so that the obtained trajectory equation of the turning area of the trajectory in the local coordinate system is a simple quadratic curve. The following is a solution process for calculating the curve equation of the turning region satisfying the smoothing condition.
And step S4, establishing a local coordinate system according to the coordinates of the S, M point and the E point obtained by calculation, and calculating a track equation of a turning area of the space track in the local coordinate system, namely a turning area track equation. Wherein the trajectory equation is a quadratic curve of the smooth turning zone.
In the algorithm process, the expression of the quadratic curve equation is established in a local coordinate system and is mapped with a global coordinate system through linear transformation.
Step S41, calculating coordinate transformation parameters θ and a, including the steps of:
<math>
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open = '[' close = ']'>
<mtable>
<mtr>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mo>-</mo>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
</mtable>
</mfenced>
<mo>,</mo>
<mo>-</mo>
<mo>-</mo>
<mo>-</mo>
<mrow>
<mo>(</mo>
<mn>8</mn>
<mo>)</mo>
</mrow>
</mrow>
</math>
wherein, theta is the angle of the coordinate axis for rotation transformation, A is the rotation matrix,
step S42, deriving vector coordinatesAndthe method comprises the following steps:
wherein,is composed ofThe representation in the local coordinate system is shown,is composed ofIn the representation under the local coordinate system, the coordinate transformation can be decoupled into translation and rotation. For the transformation of vectors, the translation part of the coordinate transformation is eliminated, leaving only the rotation part, so that the representations at the two coordinates can be directly linked by the transformation matrix a.
Step S43, calculating a trajectory equation y of the turning area of the spatial trajectory in the local coordinate system as:
y=ax2,
wherein,a is the parameter of the quadratic curve corresponding to the trajectory equation, o is S-As, the coordinate of the local coordinate system is originally expressed in the global coordinate system, and is a translation part in the coordinate transformation process,s(xs,ys),m(xm,ym),e(xe,ye) The coordinates of the starting point, the middle point and the end point of the turning area are respectively.
FIG. 3 is a flow chart of a spatial trajectory smoothing method based on velocity optimization control according to another embodiment of the present invention.
In step S301, Ps, Pm, r, and flag _ dist are input.
Step S302, the turning radius is judged, and the turning radius is not more than half of any simple track.
Specifically, it is judged that the turning section radius r does not exceed half the length of the first simple trajectory, and does not exceed half the length of the second simple trajectory,
and step S303, adopting an equal-length turning strategy.
The turning in the equal length mode requires that the lengths from the turning zone starting point to the turning zone middle point and from the turning zone middle point to the turning zone ending point are equal, namely
And step S304, adopting an equal-time turning strategy.
The equal-time turning mode requires that the time from the turning zone starting point to the turning zone middle point and the time from the turning zone middle point to the turning zone ending point are equal, namely t1 is t 2.
It should be noted that step S303 and step S304 may alternatively be executed.
In step S305, S, M, E three-point coordinates are obtained.
And step S306, solving a coordinate transformation matrix.
Wherein, <math>
<mrow>
<mi>A</mi>
<mo>=</mo>
<mfenced open = '[' close = ']'>
<mtable>
<mtr>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mo>-</mo>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow>
<mi>sin</mi>
<mi>θ</mi>
</mrow>
</mtd>
<mtd>
<mrow>
<mi>cos</mi>
<mi>θ</mi>
</mrow>
</mtd>
</mtr>
</mtable>
</mfenced>
<mo>.</mo>
</mrow>
</math>
and step S307, solving local coordinates of the SM and ME vectors.
Wherein,
and step S308, deriving parabolic parameters, coordinates of each point and relative coordinates of the origin of the local coordinate system by a formula.
Step S309, outputs the trajectory parameter and the coordinate transformation parameter.
y=·ax2,
Wherein,a is the parameter of the quadratic curve corresponding to the trajectory equation, o is S-As, and O is the coordinate of local coordinate system and is originally in global coordinateThe representation under the system, which is the translation component in the coordinate transformation process, s (x)s,ys),m(xm,ym),e(xe,ye) The coordinates of the starting point, the middle point and the end point of the turning area are respectively.
According to the space track smoothing method based on the speed optimal control, a quadratic curve of a running space track of a robot mechanical arm can be transformed into a smooth turning area expression through coordinates, so that the continuity of the speed direction is guaranteed, a turning scheme with smooth acceleration, speed and displacement is obtained through smooth transition of two straight-line tracks and combination of S-shaped speed planning, the track is simple and visual, the space position of an end effector of the mechanical arm at any moment can be conveniently positioned, and the control is convenient. Meanwhile, the track is a simple quadratic curve, so that the obstacle avoidance space can be simply and conveniently calculated. In addition, the invention can adapt to two turning requirements of equal distance and equal time, and users can conveniently compare and select a better scheme according to actual conditions.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made in the above embodiments by those of ordinary skill in the art without departing from the principle and spirit of the present invention. The scope of the invention is defined by the appended claims and equivalents thereof.