robotics
Article On Fast Jerk–, Acceleration– and Velocity–Restricted Motion Functions for Online Trajectory Generation
Burkhard Alpers
Department of Mechanical Engineering, Aalen University, D-73430 Aalen, Germany; [email protected]
Abstract: Finding fast motion functions to get from an initial state (distance, velocity, acceleration) to a final one has been of interest for decades. For a solution to be practically relevant, restrictions on jerk, acceleration and velocity have to be taken into account. Such solutions use optimization algorithms or try to directly construct a motion function allowing online trajectory generation. In this contribution, we follow the latter strategy and present an approach which first deals with the situation where initial and final accelerations are 0, and then relates the general case as much as possible to this situation. This leads to a classification with just four major cases. A continuity argument guarantees full coverage of all situations which is not the case or is not clear for other available algorithms. We present several examples that show the variety of different situations and, thus, the complexity of the task. We also describe an implementation in MATLAB® and results from a huge number of test runs regarding accuracy and efficiency, thus demonstrating that the algorithm is suitable for online trajectory generation.
Keywords: online trajectory generation; fast motion functions; seven segment profile; jerk restriction
1. Introduction Citation: Alpers, B. On Fast Jerk–, Acceleration– and Velocity–Restricted For achieving high throughput in handling machines, one of the most basic tasks Motion Functions for Online consists of quickly moving from one position to the next one, taking into account machine Trajectory Generation. Robotics 2021, restrictions regarding velocity, acceleration and jerk. This task is generally known as 10, 25. https://doi.org/10.3390/ “path and trajectory planning” for robots and other automatic machines [1,2], and beside robotics10010025 short execution times, other goals such as low energy consumption or low jerk have been considered in [3]. In this contribution, we restrict ourselves to a one-dimensional case Received: 7 January 2021 where a certain distance ∆s is given and a motion function s(t) is to be found, such that Accepted: 26 January 2021 symmetric restrictions regarding velocity v(t), acceleration a(t) and jerk j(t) apply, i.e., Published: 1 February 2021 −jmax ≤ j(t) ≤ jmax, −amax ≤ a(t) ≤ amax and −vmax ≤ v(t) ≤ vmax. The limit to the jerk function implicitly requires the acceleration function to be contin- Publisher’s Note: MDPI stays neutral uous, whereas the jerk function is allowed to have discontinuities. This task can be sub- with regard to jurisdictional claims in divided into subtasks regarding the given initial and final states (velocity and acceleration). published maps and institutional affil- In the classification given in the respective guideline of the German Association of Engi- iations. neers [4], 16 combinations are stated depending on whether the initial state (v(t0), a(t0)) is (0, 0) (called “rest”: R), (6= 0, 0) (G), (0, 6= 0) (U) or (6= 0, 6= 0) (B) (German abbreviations). The most well-known task is RR (“rest-to-rest”), which, in robotics, is usually called “point- to-point motion”. Kröger and Wahl [5] provide a different classification that also includes Copyright: © 2021 by the author. the types of restrictions, but for our purposes, the VDI classification suffices. Licensee MDPI, Basel, Switzerland. The task of finding a fast (sometimes also called “optimal”) motion function has This article is an open access article been investigated for several decades. Roughly, one can distinguish between two kinds distributed under the terms and of approaches: In the first approach, the task is formulated as a restricted optimization conditions of the Creative Commons problem and then well-known or self-developed algorithms from the fields of parameter Attribution (CC BY) license (https:// optimization or optimal control are used [6–10]. The class of functions considered are creativecommons.org/licenses/by/ often spline functions [6,7,10]. Lin et al. [8] use a specific class of piecewise-defined 4.0/).
Robotics 2021, 10, 25. https://doi.org/10.3390/robotics10010025 https://www.mdpi.com/journal/robotics Robotics 2021, 10, 25 2 of 26
functions (“seven segments”) which are optimized. Such approaches have the advantage that optimization can take into account further aspects by modifying the objective (goal) function, e.g., energy consumption or deviation from a certain path, and they can also handle variable restrictions on velocity, acceleration and jerk. On the other hand, they are more time-consuming, such that they are mainly used for so-called off-line trajectory construction taking place in advance as opposed to on-line trajectory planning where the trajectory is changed “on the fly” during a controller cycle due to unforeseen events [11,12]. The second approach constructs the motion function directly using piecewise-defined functions [1,13–22]. We first consider the most basic task, RR. Choosing a piecewise constant jerk function leads to the so-called seven-segment profile (depicted in Figure1 ) with continuous acceleration but discontinuous jerk, which has been fully specified in [1] (pp. 90–93) and can be found in industrial implementations [13] (Section 11.2). The approach has been extended to a 15-segment profile with piecewise constant snap in [1] (pp. 107–114), making the jerk function continuous. Considerable improvements have been achieved by using higher-order polynomials or the sigmoid function [14,15]. They provide fast motion functions with continuity in higher-order derivatives (or even all derivatives [15]) and are, hence, very suitable for vibration reduction. Smoothing can also be achieved by applying moving averages, as is shown in [16]. It is open whether and how the use of such advanced functions can be extended to motion tasks other than RR. When non-zero values are prescribed for initial and/or final velocities and/or acceleration, direct construction seems to be much harder. Nearly all contributions known to the author use the relatively simple seven-segment profile since this already leads to complex computations. The subtask GG (zero acceleration at initial and final states) has been dealt with for seven- segment profiles by [17] and [1], but both solutions are incomplete (for [17], cf. Kröger [10] (Section 4.1.2)) or can be improved (in [1], absolute values of the occurring minimal and maximal acceleration are assumed to be equal even if they are lower than the limit value, cf. Example 3.11, p. 84). Using, also, the seven-segment profile, Haschke et al. [18] developed an algorithm for the subtask BR (arbitrary initial state, rest), and Kröger and Wahl [5] and Kröger [12] provided a solution for the subtask BG, going through all possible branches in their decision tree. Their work shows the complexity of the task since they could provide only a small portion of their decision trees in their publications (cf. [5] (p. 106) for information on the number of nodes in these trees). For the general task BB (arbitrary values for initial and final velocities and accelera- tions), Ezair et al. [19] developed a recursive algorithm which even enables them to handle a case where initial and final values as well as restrictions are given for an arbitrary number of derivatives and higher orders of continuity can be achieved, but only for order 2 (i.e., continuous acceleration); the algorithm is fast enough for online trajectory generation. In this case, it provides a seven-segment profile but not necessarily the fastest one. As we will show, there might be several seven-segment profiles solving the problem with quite different execution times. Broquère [20] and Broquère et al. [21] present a complex algorithm for the seven-segment profile but, as observed by Kröger [12] (Section 4.1.2), their work does not provide a solution in all cases, and we will give examples in Section4 for configurations which are easily overseen. Recently, Sidobre and Desormeaux [22] modified the work in [20,21] and developed an algorithm where they claim to be able to reduce the general situation to just four simple sub-cases, but there is no proof, and the claim is not supported by extensive test runs with random values for all input data. It is the goal of this contribution to provide an algorithm for constructing a seven- segment profile for the general BB task which provenly covers all possible situations, has a clear systematic structure with manageable complexity and is efficient enough for being suitable for online trajectory generation. Note that our results have some overlap with those of Sidobre and Desormeaux [22], but we apply a different approach by reducing the general BB task as much as possible to the GG subtask using intermediate velocities. We do not claim to provide an optimal solution (although this might be the case) since we do not have mathematical proof for this. Therefore, we just label our solution as “fast” since, Robotics 2021, 10, x FOR PEER REVIEW 3 of 27
general BB task as much as possible to the GG subtask using intermediate velocities. We Robotics 2021, 10, 25 3 of 26 do not claim to provide an optimal solution (although this might be the case) since we do not have mathematical proof for this. Therefore, we just label our solution as “fast” since, at any time, at least one restriction is exactly fulfilled, but we also show that this does not atimply any time, global at leastoptimality. one restriction is exactly fulfilled, but we also show that this does not imply globalThe paper optimality. is structured as follows: In the next section, we present the seven-segment motionThe paperprofile is with structured modifications as follows: and Inrecall the nextthe “acceleration–velocity section, we present the plane” seven-segment introduced motionby Broquère profile et with al. modifications[20] and Broquère and recall[21]. Section the “acceleration–velocity 3 models the subtask plane” GG introducedwhere initial byand Broqu finalè revelocities et al. [20 are] and 0 and, Broqu basedère [on21 ].this, Section Section3 models 4 deals the with subtask the general GG where task. Section initial 5 anddiscusses final velocities implementation are 0 and, issues based and on this,describe Sections the4 deals results with of the the validation general task. in MATLAB Section5 ®. discussesSection 6 implementation summarizes the issues results and and describes discusses the further results work. of the validation in MATLAB®. Section6 summarizes the results and discusses further work. 2. Basic Models, Quantities and Visualizations 2. Basic Models, Quantities and Visualizations The task we want to solve in this contribution consists of finding a fast motion func- tionThe when task the we following want to solve eight in values this contribution are given: consists of finding a fast motion function when the following eight values are given: 𝑗 , 𝑎 , 𝑣 (each >0), such that −𝑗 ≤𝑗(𝑡)≤𝑗 , −𝑎 ≤𝑎(𝑡)≤𝑎 jmax, amax, vmax (each > 0), such that −jmax ≤ j(t) ≤ jmax, −amax ≤ a(t) ≤ amax and and −𝑣 ≤𝑣(𝑡)≤𝑣 ; initial conditions: 𝑣 , 𝑎 ; end conditions: 𝑣 , 𝑎 ; distance: Δs −(arbitraryvmax ≤ v (realt) ≤ numbers).vmax; initial conditions: vA, aA; end conditions: vE, aE; distance: ∆s (arbitraryNote real that numbers). the distance is meant to be the difference between the final and the initial Note that the distance is meant to be the difference between the final and the initial value of the path scale (∆𝑠 = 𝑠 −𝑠 ), not the “travelled distance”, which might be much s = s − s valuelonger of thewhen path the scale motion (∆ goesE backA ),first not and the then “travelled forward distance”, again. which might be much longer when the motion goes back first and then forward again. As in [20–22], we work with a so-called 7-segment motion profile, shown in Figure 1. As in [20–22], we work with a so-called 7-segment motion profile, shown in Figure1 . It is based on a piecewise constant jerk function together with initial conditions on velocity It is based on a piecewise constant jerk function together with initial conditions on velocity and acceleration. In this profile, the motion function has, at most, 4 segments where the and acceleration. In this profile, the motion function has, at most, 4 segments where the jerk is ±𝑗 and, at most, 3 segments with zero jerk. In the classical RR situation (“rest- jerk is ±j and, at most, 3 segments with zero jerk. In the classical RR situation (“rest- to-rest”,max see Figure 1a), the sign pattern of the jerk segments is (+,−,−,+), but we allow to-rest”, see Figure1a), the sign pattern of the jerk segments is (+, −, −, +), but we allow arbitrary patterns such as (+, −, +, −) to occur in order to have full coverage of all possi- arbitrary patterns such as (+, −, +, −) to occur in order to have full coverage of all possible ble configurations as will be seen later. Formally stated, we have: configurations as will be seen later. Formally stated, we have: 𝑗(𝑡) =±𝑗 in [𝑡 ,𝑡 ], [𝑡 ,𝑡 ], [𝑡 ,𝑡 ]and [𝑡 ,𝑡 ]; 𝑗(𝑡) =0 in [𝑡 ,𝑡 ], [𝑡 ,𝑡 ] and [𝑡 ,𝑡 ]. j( t) = ±jmax in [t0, t1], [t2, t3], [t4, t5] and [t6, t7]; j(t) = 0 in [t1, t2], [t3, t4] and [t5, t6]. Note that all of these intervals might have zero length. In the example displayed in FigureNote 1a, that the all maximal of these values intervals for mightvelocity have and zero acceleration length. In are the reached, example which displayed need innot Figurealways1a, be the the maximal case. Figure values 1b forprovides velocity an and example acceleration for the general are reached, situation which where need 𝑣 not , 𝑎 , always𝑣 and be 𝑎 the are case. non-zero. Figure1 Inb providesthat example, an example only 𝑎 for the is reached general and situation two of where the potentiallyvA, aA, vEsevenand asegmentsE are non-zero. have length In that zero. example, only amax is reached and two of the potentially seven segments have length zero.
(a) (b)
FigureFigure 1. 1.Seven-segment Seven-segment profile profile (a )(a for) for RR; RR; (b ()b for) for BB—two BB—two segments segments with with length length 0. 0.
InIn order order to to visualize visualize the the change change of of velocity velocity and and acceleration acceleration in in such such seven-segment seven-segment motionmotion functions, functions, Broqu Broquèreère [20 [20,21],21] introduced introduced the the velocity–acceleration velocity–acceleration plane, plane, shown shown in in Figure2. In this plane, motion functions are displayed mathematically as parametric curves (v(t), a(t)), t ∈ [t0, t7]. When one assumes that j(t) = ±jmax or 0, then the curves “move” 1 2 along square root curves or horizontally (e.g., from a(t) = jmaxt and v(t) = 2 jmaxt one Robotics 2021, 10, x FOR PEER REVIEW 4 of 27
Figure 2. In this plane, motion functions are displayed mathematically as parametric curves 𝑣(𝑡),𝑎(𝑡) , 𝑡 ∈ [𝑡 ,𝑡 ]. When one assumes that 𝑗(𝑡) =±𝑗 or 0, then the curves Robotics 2021, 10, 25 4 of 26 “move” along square root curves or horizontally (e.g., from 𝑎(𝑡) =𝑗 𝑡 and 𝑣(𝑡) = 𝑗 𝑡 one obtains 𝑎(𝑣) = 2𝑗 𝑣). The square root curves can be of the kind 𝑎= ± 𝑐 (𝑣 − 𝑐 ) (open to pthe right) or 𝑎=± 𝑐 (𝑐 −𝑣) (open to the left) with constantsp obtains a(v) = 2jmaxv). The square root curves can be of the kind a = ± c1(v − c2) 𝑐 ,𝑐 . We assume that the horizontalp motion only occurs when 𝑎(𝑡) =±𝑎 since oth- erwise, (openfaster tomotion the right) is possible. or a = ± Motionc1(c2 −alonv)g(open the square to the left)root with curves constants is onlyc 1possible, c2. We assume clockwisethat since the horizontalwhen the accelera motion onlytion is occurs positive when (resp.a(t) nega= ±ative),max since the velocity otherwise, must faster in- motion crease (resp.is possible. decrease). Motion The only along points the square where roota fast curves motion is function only possible might clockwisestay for a time since when the acceleration is positive (resp. negative), the velocity must increase (resp. decrease). of length >0 are the points (±𝑣 ,0). This is the case when there is a segment with zero jerk andThe acceleration. only points Figure where 2a ashows fast motion a repres functionentation mightof the classical stay for aRR time situation of length where >0 are the points (±vmax,0). This is the case when there is a segment with zero jerk and acceleration. 𝑣 and 𝑎 are reached. Note that only points within the area bounded by the left Figure2a shows a representation of the classical RR situation where vmax and amax are and right square root curves and the horizontal lines at 𝑎 and −𝑎 are admissible reached. Note that only points within the area bounded by the left and right square root since only those points can be reached from (0,0) and one can go back from there to (0,0) curves and the horizontal lines at a and −a are admissible since only those points without violating the restrictions (a larger openingmax of maxthe square root curve corresponds can be reached from (0,0) and one can go back from there to (0,0) without violating the to a higher value of 𝑗 ). The velocity–acceleration plane has one particular “pitfall” restrictions (a larger opening of the square root curve corresponds to a higher value of j ). where misunderstandings can easily occur, so special care is called for: It does not show max The velocity–acceleration plane has one particular “pitfall” where misunderstandings can the distance ∆s, and this distance heavily depends on where in the velocity–acceleration easily occur, so special care is called for: It does not show the distance ∆s, and this distance plane a curve is placed. The length of the curve has nothing to do with the distance ∆s. heavily depends on where in the velocity–acceleration plane a curve is placed. The length The blue curve in Figure 2b depicts the motion function of Figure 1b (with positive ∆s) in of the curve has nothing to do with the distance ∆s. The blue curve in Figure2b depicts the velocity–acceleration plane. The green curve has the same initial and end conditions the motion function of Figure1b (with positive ∆s) in the velocity–acceleration plane. The but a negativegreen curve value has for the∆s. same initial and end conditions but a negative value for ∆s.
(a) (b)
Figure 2.Figure Velocity–acceleration 2. Velocity–acceleration curve for curve the motion for the function motion function(a) in Figure (a) in 1a; Figure (b) in1a; Figure ( b) in 1b. Figure 1b.
3. The Subtask3. The Subtask GG: Zero GG: Acceleration Zero Acceleration Initially Initially and Finally and Finally In this section, we consider a motion with zero acceleration initially and finally. Let In this section, we consider a motion with zero acceleration initially and finally. Let vA 𝑣 resp. 𝑣 be the initial resp. final velocity. We first determine the time 𝑇(𝑣 ,𝑣 ) neces- resp. vE be the initial resp. final velocity. We first determine the time T(v A, vE) necessary sary to getto get from from the the initial initial to the to the final final state state by byapplying applying first first maximal maximal (minimal) (minimal) jerk jerk and and then then minimalminimal (maximal) (maximal) jerkjerk where where in between in between the jerk the might jerk might be zero be and zero the and acceleration the acceleration equal toequal ±𝑎 to. ±Examplesamax. Examples are shown are shownin Figure in 3 Figure in the3 velocity–accelerationin the velocity–acceleration plane. Type plane. Type |𝑣 −𝑣 | 1 depicts1 depictsthe situation the situation where where |v isE −sov smallA| is sothat small maximal/minimal that maximal/minimal acceleration acceleration is not reached,is not whereas reached, in whereastype 2, the in latter type is 2, the the case. latter When is the ±𝑎 case. is Whenjust reached,±amax weis justhave reached, 2 2 amax amax |𝑣 −𝑣 we| = have ,| vsoE −typevA |1 =occurs ,when so type |𝑣 1−𝑣 occurs | < when and|vE −typevA |2