ERK'2019, Portorož, 70-73 70 Optimal velocity profile planning considering velocity, acceleration and jerk constraints Martina Loknar, Gregor Klanˇ car, Saˇ so Blaˇ ziˇ c Faculty of Electrical Engineering, Trˇ zaˇ ska cesta 25, SI-1000 Ljubljana, Slovenia E-mail: martina.loknar@fe.uni-lj.si Abstract The aim of this study is to determine time-minimal veloc- ity profile for a wheeled mobile robot whose movement complies with velocity, acceleration and jerk constraints and is restricted to an arbitrary predefined path. The pro- posed two-step algorithm first enables the determination of the velocity profile that respects the speed and accel- eration constraints and in the second step additionally applies the limitation of the jerk. 1 Introduction Optimal control theory describes the application of forces to a system for the purpose of maximizing some measure of performance or minimizing a cost function [1]. It is an extension of the calculus of variations and this math- ematical optimization method is largely due to the work of [2]. Using Pontryagin’s maximum principle, in [3] the authors demonstrated that all time-optimal motions of the mobile platform with two independently driven wheels occur for controls that are at each instant on the upper or lower limit. Mechanical systems, including biological systems, have maximum allowances related to various dynamic variables, above which the components of the system may begin to fail. Excess of jerk thresholds is associated with mechanical wear, tool life repercussion and adverse ef- fect on the actuator performance, degradation of machine junctions, and in biological systems tear of ligaments and muscles or breakage of bones [4], [5]. Minimizing jerk is therefore beneficial in reducing stress and wear of the mechanical components, extending machine or tool life, reducing position tracking errors, minimizing the excita- tion of vibrations in general, enabling better quality fin- ishes in machining tasks and ensuring that the motor is able to provide the requested current fast enough. Me- chanical and robotics engineers have recognized the ben- efits of jerk minimization and therefore prefer to design jerk-limited profiles [6]. Authors in [7] investigated time optimal two-stage path planing under kinematic and dynamic constraints and obtained the shortest path and a time optimal velocity profile. A path planning technique to minimise the time of reaching the end point in desired direction and with de- sired velocity is presented in [8]. In [9] the authors sug- gested a methodology to generate minimum time optimal velocity profiles for a vehicle with prescribed accelera- tion limits along a specified path. Similarly, a method for minimum-time velocity planning with velocity, ac- celeration and jerk constraints was proposed, based on a sequence of linear programming feasibility checks, de- pending on motion constraints and generic boundary con- ditions [10]. This paper outlines a new approach of determining time-minimal optimal velocity profile for a wheeled mo- bile robot on a predefined path. We believe that we have found an innovative solution that is easy to implement and computationally undemanding with coherent course of calculation that relies heavily on analytical expressions of given physical quantities. The first step of the algo- rithm ensures that the resulting velocity profile complies with speed and acceleration constraints. The additional jerk constraints are considered in the second step of the algorithm, where the acceleration discontinuities are elim- inated by smoothing the velocity profile from the first step. 2 Problem formulation Let the motion of a particle along a three times continu- ously differentiable plane curveC be described as a func- tion of timet2 [0;t f ] by the position vector r(t) mea- sured from a given fixed origin. Velocity v(t), acceler- ation a(t) and jerk j(t) vectors can be expressed in the tangential-normal form as: v(t) =v(t) ^ T (1a) a(t) =a T (t) ^ T+a R (t) ^ N (1b) j(t) =j T (t) ^ T+j R (t) ^ N; (1c) where ^ T and ^ N are the unit tangent vector and the unit normal vector, respectively: ^ T(t) = v(t) kv(t)k ; ^ N(t) = _ ^ T(t) k _ ^ T(t)k : (2) Given a feasible path from initial to final point, the opti- mization problem is to find the velocity profilev(t) that reaches the end of the path in minimum time in a way that none of the velocity, acceleration or jerk constraints from 71 Eqs. (3a;3b;3c) are violated: 0 k v(t)k v MAX ; 8t2 [0;t f ]; (3a) a 2 T (t) a 2 T MAX + a 2 R (t) a 2 R MAX 1; 8t2 [0;t f ]; (3b) j 2 T (t) j 2 T MAX + j 2 R (t) j 2 R MAX 1; 8t2 [0;t f ]: (3c) We defined the acceleration and jerk constraints in a sim- ilar way as [8]. 3 Optimal velocity profile algorithm The predefined pathC in the two-dimensional space is given as s p (u) = [x p (u);y p (u)] T with parameter u2 [u 0 ;u f ]. The parametrized velocity is: v p (u) = ds p (u) du = x 0 p (u);y 0 p (u) T (4) with the magnitude: v p (u) =kv p (u)k= q (x 0 p (u)) 2 +(y 0 p (u)) 2 : (5) The orientation equals the four-quadrant inverse tangent of the quotient of Cartesian components of the transla- tional velocity: p (u) = atan2(y 0 p (u);x 0 p (u)); (6) from which follows the expression for the magnitude of parametrized angular velocity: ! p (u) = d p (u) du = x 0 p (u) y 00 p (u) x 00 p (u) y 0 p (u) x 02 p (u)+y 02 p (u) : (7) The curvature p (u) is: p (u) = d p (u) dl = d p (u) du du dl = = x 0 p (u) y 00 p (u) y 0 p (u) x 00 p (u) (x 0 p (u) 2 +y 0 p (u) 2 ) 3=2 ; (8) wherel is the arc length parameter of a curve. 3.1 Step 1: Complying with velocity and accelera- tion constraints In order to apply actual velocity and acceleration restric- tions, the two operating physical quantities ought to be expressed as functions of time. The robot’s movement on a path can be described by monotonously increasing parameteru of the curve or by timet; the former measuring the position on a trajectory and the latter the time at which a certain position on a path is reached. We present the dependence ofu ont by scheduleu(t) and as a result the parametrized functions v p , ! p , p defined in Eq. (5, 7, 8) become composite functionsv p (u(t)),! p (u(t)) and p (u(t)). Applying the chain rule allows us to calculate the magnitudesv(t) and !(t): v(t) = ds p (u(t)) du du dt =v p (u(t)) _ u(t); (9a) !(t) = d p (u(t)) du du dt =! p (u(t)) _ u(t): (9b) Expressing the velocity and angular velocity solely as functions of time reveals that the time dependant veloci- ties differ from the corresponding parametrized ones by a factor of _ u(t). Obtaining the desired velocity profile thus requires calculating the schedule u = u(t) and its time derivative _ u(t). The curvature, unlike the velocity or an- gular velocity, does not depend on the parametrization of the curve: (t) = p (u(t)): (10) Acceleration vector is the derivative of velocity vector from Eq. (1a): a(t) = dv(t) dt = _ v(t) ^ T+v(t) _ ^ T: (11) The time derivatives of unit tangential and unit normal vector can be expressed from the Frenet–Serret formulas: _ ^ T(t) = (t) v(t) ^ N(t); (12a) _ ^ N(t) = (t) v(t) ^ T: (12b) Using the equality from Eq. (12a) we find that: a(t) = _ v(t) ^ T(t)+ (t) v 2 (t) ^ N(t): (13) The expressions for the normal and tangential compo- nents with respect to time follow from Eqs. (1a, 9a, 13): a T (t) =v 0 p (u(t)) _ u(t)+v p (u(t)) u(t); (14a) a R (t) = p (u(t)) v 2 p (u(t)) _ u 2 (t): (14b) The proposed method of incorporating speed and accel- eration constraints in the calculation of velocity profile, indirectly determined by schedulesu(t) and _ u(t), begins with the identification ofN points on the curve, the so- called turning points, where the curvature reaches the lo- cal maximum. The value of parameteru in thei th turn- ing point (i =f1;:::;Ng) is denoted asu TPi . The speed in these points reaches local minimum, the tangential ac- celerationa T (t) is therefore zero and radial acceleration a R (t) is maximal. From Eq. (14b) it follows: _ u TPi = r a R MAX v 2 p (u TPi ) p (u TPi ) : (15) It is also possible to implement the initial and final speed requirements by treating the initial and final point of the trajectory similarly as the turning points and using Eq. (9a). For values of _ u we get: _ u TP0 = vj t=0 v p (u TP0 ) ; _ u TP N+1 = vj t=t f v p (u TP N+1 ) ; (16) where the initial and the final point are denoted asTP 0 andTP N+1 , respectively. To get the complete velocity profile v(t) of the mo- bile robot, the values of u and _ u have to be determined also in between the turning points. Our realization of the proposed method for this calculation stems from knowing the fixed values ofu TPi and _ u TPi fori2f0;1;:::;N + 72 1g and the analytical formula for u as a function ofu and _ u that follows from Eqs. (14a, 14b, 3b, 5): u(t) = aT MAX s 1 x 02 p +y 02 p (x 02 p +y 02 p ) 2 p a 2 R MAX _ u 4 (t) x 0 p x 00 p +y 0 p y 00 p x 02 p +y 02 p _ u 2 (t); (17) where all the quantities with the indexp depend directly onu. The basic idea of the algorithm that returns sched- ulesu(t) and _ u(t) is to find the solution to the initial value problem by applying a numerical method of solving ordi- nary differential equations; or more specifically: to inte- grate backward and forward in time around each turning point where the initial conditionsu TPi and _ u TPi are set in order to determine the discrete values of t, u and _ u. According to Euler’s method (the simplest explicit itera- tive method) the valuesu k+1 and _ u k+1 in the(k+1)-th step of the calculation are: _ u k+1 = _ u k u k T s ; (18a) u k+1 =u k _ u k T s ; (18b) where T s is the sampling time and u k , _ u k , u k the val- ues calculated in thek-th step and perform as the current initial values and/or slopes with negative or positive sign (backward/forward integration). The sought-after sched- ule _ u(u(t)) is defined by the minimum of the separate profiles around the turning points as shown in Figure (1). Figure 1: Resulting _ u(u(t)) profile (bold line) on a path sp(u) = (cos(u);sin(2u));u2 [0;2 ] is determined by the separate profiles _ u(u(t)) around theTPi (thin lines). 3.2 Step 2: Complying with jerk constraints The resulting velocity profile of the first step of the cal- culation is infeasible for an actual implementation on a robot due to the sudden changes of acceleration. To ap- ply jerk constraints to the existing velocity profile the ex- pression from Eq. (1c) can be written more specifically by differentiating acceleration vector in Eq. (13) using Eqs. (12a, 12b): j(t) = da(t) dt = v(t) v 3 (t) 2 (t) ^ T(t) + 1 v(t) d dt v 3 (t) (t) ^ N(t): (19) From Eqs. (9a, 19) we get the following expressions for the tangential component of the jerk: j T (t) =v 00 p (u(t)) _ u 3 (t)+3v 0 p _ u(t) u(t) v 3 p (u(t)) _ u 3 (t) 2 p (u(t)) +v p (u(t)) ... u(t); (20) and its radial component: j R (t) = 3v 0 p (u(t)) v p (u(t)) _ u 3 (t) p (u(t))+ +3v 2 p (u(t)) p (u(t)) _ u(t) u(t)+ +v 2 p (u(t)) _ u 3 (t) 0 p (u(t)): (21) The third time derivative of parameter u(t) with imple- mented jerk constraints follows from Eq. (20): ... u = 1 v p j T (t) v 00 p _ u 3 3v 0 p _ uu+v 3 p _ u 3 2 p : (22) Using Eq. (22) and Eq. (3c) to determine the value of j T (t), the aim of the second step of calculation is to smooth the intervals in the original velocity profile that contain points with abrupt changes of acceleration. Simi- larly as in the Eq. (18a, 18b), forward Euler integration is applied, yet with an additional calculation in the(k+1)- th step: u k+1 = u k + ... u k T s : (23) To determine the adequate initial value of Euler method, let us first introduceu CP ‘ and its corresponding time deriva- tive _ u CP ‘ , ‘2f1;:::;Mg, as the value of u and _ u in the critical points on the curve, where the acceleration is discontinuous. Two guesses for the initial value ofu for each critical point CP ‘ , u L ‘ and u H ‘ , are then selected according to the following restriction: u CP ‘ 1