1. Introduction
Industry 4.0 is a term used to describe and encapsulate a set of technological changes in manufacturing that have been characterising and transforming the industry in the last several years [
1,
2,
3]. Robotics and automation play a key role in this framework, with the motion optimisation and control of robotic manipulators under kinematic and dynamic constraints being one of the typical challenges.
Trajectory planning is a classic problem in robotics and is usually defined as finding the timing of the motion law along a given geometric path while satisfying certain requirements and minimising certain objectives. The typical objectives include execution time [
4,
5,
6,
7], vibrations [
8,
9] and energy consumption [
10,
11]. A general overview is given in [
12]. All such approaches assume a pre-defined path, which is at least given in terms of so-called ‘via-points’, on top of which trajectory optimisation is performed.
The focus of this work is on the execution time of manipulators while accounting for both kinematic and dynamic constraints. An optimal control approach is employed while leaving the path among the optimisation variables. The optimisation problem is thus defined as finding the path, the timing of motion and related control inputs that are necessary to move the end-effector from the initial configuration to the final configuration in the minimum time while satisfying the kinematic and dynamic constraints.
Among the earliest attempts to solve the minimum-time problem for manipulators is [
4]. After an unsuccessful attempt to tackle the problem directly with an optimal control approach, the solution was obtained by choosing the acceleration that made the velocity along the specified path as large as possible at every point without violating the constraints. A very similar approach was devised in [
5]. In practice, the optimum is either the maximum acceleration or maximum deceleration, with the change between the two strategies taking place at switching points. One of the key issues is thus finding such points. In addition, for a given path, there is a maximum velocity curve (arising from the limited admissible torques), which complicates the problem. In [
6], similar ideas are exploited, again based on the fact that, once the path is given, the problem becomes one-dimensional. In [
7], a dynamics-based kinematic approach is proposed to compute the minimum-time trajectory. The method calculates the robot dynamics only at certain points, thus allowing online implementation, and was tested with 40 industrial manipulators. A mixed-integer optimal control problem was formulated in [
13] to deal with multi-point manufacturing tasks, with a cubic polynomial between points. In such a scenario, it is necessary to plan the optimal strategy to traverse all the desired points in an orderly way while minimising the manoeuvre time.
It is interesting to note that the approach based on the switching points closely resembles the so-called ‘apex-finding’ method used to estimate the lap time of road vehicles [
14,
15] on a pre-defined path, where the switching points are named apex/critical points. The solution can also be obtained directly with an optimal control approach, which allows, among the other things, the control of abrupt changes at the switching points. However, a more general approach that does not require pre-defining the path, which thus becomes a result of optimisation, is also possible [
15,
16].
Similarly, in the robotic field, optimisation can also be carried out without pre-defining the path. An early example of such an application is discussed in [
17], where the minimisation of the energy required to transfer the payload of a Cartesian manipulator while avoiding obstacles is considered. An optimal control approach was employed with barrier functions introduced into the cost function to prevent collisions. In [
18], the minimum-time problem was solved by using an optimiser to vary the path, which was then used to feed the algorithm in [
4], which computed the related execution time based on the maximum acceleration/maximum deceleration strategy. The computation of the optimal switching points was also the focus of [
19], again under the assumption of a bang–bang control system, with application to a two-link manipulator with two control inputs. However, the optimal solution is not always purely bang–bang [
20,
21,
22]. The rest-to-rest time-optimal manoeuvres of rigid two-link robotic manipulators was tackled in [
23] using Pontryagin’s principle. The resulting two-point-boundary-value problem was solved using a combination of the forward–backward and shooting methods (i.e., indirect approach to the solution of the optimal control problem). In [
24], the rest-to-rest time-optimal manoeuvre with no pre-defined trajectory and obstacle avoidance was considered. An optimal control problem was formulated and discretised on a fixed mesh to obtain a nonlinear programming problem (i.e., a direct approach was used). The method was applied to three-axis and six-axis manipulators.
Most of the minimum-time approaches proposed lead to discontinuous actuator torques. A limitation on the rate of change in torque was considered in [
25], where the time-optimal point-to-point control of robot manipulators was solved as an optimal control problem. An indirect approach was employed. An iterative method for computing the optimal time based on decreasing the final time of the minimum-energy problem was proposed. An optimal control formulation, with the rate of change in motor torque as the input, was also employed in [
26]. The related boundary value problem was discretised with equally spaced mesh points in the time domain. Penalty functions were employed to enforce constraints on the states and inputs. However, the cost function was not the time, but a convex combination of energy and power.
The perusal of the literature suggests that, in the most widespread approaches, path and motion planning are separate, with motion planning usually obtained with smooth functions, e.g., polynomial splines, through the via-points generated from the path planning. In this work, the problem of minimum-time trajectory planning without a pre-defined path is formulated as a nonlinear optimal control problem (OCP), where path and motion planning are solved simultaneously. In contrast to most of the approaches proposed in the literature, the optimal path is not given, since it is a result of optimisation. Therefore, via-points need not be defined. Additionally, the structure of the optimal control is not pre-defined, which is not the case for approaches that assume, e.g., maximum-acceleration/maximum-deceleration strategies. The effects of limitations on either the jerk of actuators or the rate of change in the control torque are also investigated in order to avoid the discontinuities (and related problems) that characterise many approaches. The dynamics of the system are included in the optimisation and affect the optimal path obtained. A direct solution approach is employed; i.e., the nonlinear OCP is transcribed to a nonlinear programming problem (NLP). A pseudo-spectral method is used: the discretisation is obtained with a collocation scheme, where the collocation points are the roots of Legendre polynomials and the solution is approximated with Lagrange polynomials. The approach has proven successful for solutions to large and nonlinear OCPs in the field of vehicle dynamics [
15,
27,
28]. A mesh refinement scheme is employed, where both the mesh size and the order of the polynomial are varied during the iterations [
29,
30]. Automatic differentiation is used to compute the required derivatives [
31].
This work is organised as follows. The OCP formulation is given in
Section 2. The robotic manipulator model is illustrated in
Section 3. The method is demonstrated in the case of kinematic constraints in
Section 4, where minimum-time and minimum-path solutions, with and without obstacles, are discussed and compared.
The possibility of including a limitation on the joint jerk is shown in
Section 4.3. The method proposed is also compared with the well-known Probabilistic Roadmap Method (PRM) [
32,
33] in
Section 4.4. Dynamic constraints are introduced in
Section 5, and trajectory planning is carried out again both with and without obstacles. In
Section 5.3, the effect of limiting the rate of change in the joint torque to remove control discontinuities is addressed. The possibility of avoiding collisions with multiple obstacles is investigated in
Section 5.4. In
Section 5.5, optimisation is repeated while including a number of via-points: the path remains a result of optimisation (i.e., it is not pre-defined) but is enforced to satisfy the selected via-points. In
Section 5.6, a redundant manipulator is considered in order to show the ‘scalability’ of the approach to more complex robots. Finally, in
Section 6, some remarks on the numerics associated with the practical solutions of the optimisation problems discussed in the work are reported.
2. Optimal Control Problem Formulation
The dynamical system is described by a set of ordinary differential equations (ODEs):
where
is the state,
is the input,
t is the independent variable (for example, time),
and
are the related limits, and the dot denotes derivatives with respect to the independent variable. In the so-called Bolza form, the cost function, or performance index, is
where
and
ℓ are the Mayer and Lagrange costs, respectively. The objective of the OCP is to minimise the cost function
J while simultaneously satisfying the dynamic Equation (
1) and the path constraints
Finally, the boundary constraints are given by
while the bounds on the controls are
In the case of the robotic manipulator considered in this work, the cost function (
2) consists of either the manoeuvre time or the travelled distance, while the path constraints (
3) are both used to limit the maximum velocity, acceleration and torque of joints and to prevent collisions with obstacles. The solution of the problem consists of the path, the timing of motion and related control inputs.
The resulting continuous OCP is ‘transcribed’ to a nonlinear programming problem (NLP) through discretisation: a direct solution method is thus employed [
15,
28,
34,
35]. A collocation approach is used that produces an approximation of the solution in the form of polynomial functions. The problem equations are satisfied at collocation points. Among the different approaches available, in this work, the collocation points are obtained from the roots of Legendre polynomials, while Lagrange polynomials are used for approximations through collocation points. Hence, a Legendre–Gauss (LG) scheme is obtained. Among the different LG variants, the Legendre–Gauss–Radau (LGR) is used in this work. The solutions at all steps are obtained simultaneously by solving a set of algebraic equations. The transcription is carried out using GPOPS-II [
36]. The resulting NLP is solved using the optimiser IPOPT [
37].
A key aspect of efficiently generating accurate solutions to the OCP using collocation methods is the placement of both the mesh segment boundaries and the collocation points. In general, for each mesh interval of length
h, there are
p collocation points. Traditional fixed-order collocation methods determine the location of the mesh boundaries while keeping the degree
p of the approximating polynomial fixed: these are called
h-type methods. In contrast,
p-type methods use a fixed mesh in combination with variable-order approximating polynomials. When both
h and
p are varied, the algorithm is of the
type. As a general rule, if the error across a particular segment is large and uniformly distributed, the polynomial order should be increased. If a significant error occurs at an isolated point within a segment, the segment should be subdivided. In this work, the
algorithm in [
36] is used.
NLP solvers usually require derivatives of the cost function and constraints with respect to both the state and control variables. There are at least four possible approaches: computing derivatives analytically; computing derivatives numerically using finite-difference approaches; using complex-step differentiation [
38,
39,
40]; and using algorithmic or automatic differentiation (AD). In order to compute function derivatives to machine precision without the need to derive them symbolically, the AD approach in [
31] is used in this work.
4. Planning with Kinematic Constraints
The planning problem needs to account for a number of constraints. Joint motors are typically limited in their maximum velocities. The associated constraints are given by
where
rad/s and
rad/s are the values chosen in this work (estimated from [
25]). Similarly, acceleration constraints can be included:
The initial and final positions of the joints provide the following boundary conditions:
The initial and final positions can alternatively be given in terms of Cartesian coordinates. However, the corresponding joint positions (
19) can be readily obtained from Cartesian coordinates through inverse kinematics using (
6). The advantage of defining the initial and final positions directly with (
19) is also that the preferred manipulator configuration
is selected among the multiple configurations that provide the same end-effector position
. The initial and final velocities are zero (
); i.e., rest-to-rest manoeuvres are considered. In the example of the application discussed in this work, the boundary conditions are
,
= 1 rad and
= −0.5 rad (see
Figure 2b).
The speed coefficient
is a typical index used to characterise the motion of joints:
where
is the amplitude of motion, and
T is the motion time. In several applications, a symmetric trapezoidal law is assumed for the velocities of joints, which also gives
where
is the acceleration/deceleration time. The combination of (
20) and (
21) provides the expression of the maximum acceleration:
A typical value for the speed coefficient is
[
41], which can be introduced in (
22) to provide 18 and 128 rad/s
for the maximum accelerations of joint 1 and joint 2, respectively. The limit is assumed to be the minimum between the two, i.e.,
= 18 rad/s
. It is worth stressing that the trapezoidal law is not enforced in the subsequent optimisation, although it is used to determine reasonable values for the maximum acceleration of joints allowed.
4.1. Minimum Time vs. Minimum Distance
The OCP is solved with
and
in (
2), with time
t as the independent variable. Of course, one can equivalently use
and
. The controls are the accelerations
, while the states are
. The dynamic Equation (
1) consist of integrator chains, which are used to compute the positions
from their accelerations
:
The path constraints (
3) consist of (
17), and the boundary conditions (
4) consist of (
19), while the bounds on inputs (
5) consist of (
18).
There are multiple minimum-time solutions to the problem. The numerical optimum obtained depends on the guess solution provided to the solver. The classic solution is a straight path in the joint space (i.e.,
vs.
diagram) between the initial and final points; see the solid line in
Figure 3a. This is a well-known solution that provides typical trapezoidal diagrams (
Figure 2a) of the joint velocities as a function of the manoeuvre time. The slope of the trapezoid of the fastest joint (
in this case) is related to the acceleration constraint, while the height is related to the velocity constraint. Of course, in Cartesian coordinates, the path is not straight (
Figure 2b). The manoeuvre time is
s with the dataset employed. The minimum-distance manoeuvre is thus a minimum-time manoeuvre, as long as the fastest joint (
in this case) is actuated at its limits.
However, there are an infinite number of other minimum-time manoeuvres that are not minimum-distance in the joint space. Indeed, the bottleneck is the fastest joint, which is
in this case. Therefore, the other joint,
in this case, can be moved in different ways, as long as the integral of its velocity vs. time curve provides the rotation required to reach the final configuration exactly when the bottleneck joint comes to rest. As an example,
Figure 4 shows a possible solution, which consists of initially actuating both joints at the limits of constraints (i.e., maximum acceleration) and then slowing down to rest joint
, while joint
completes the manoeuvre, always at the limits of its constraints (see
Figure 4a). The path in the joint space is no longer linear; see the dashed line in
Figure 3a. The path in Cartesian coordinates is shown in
Figure 4b and differs from that in
Figure 2b, although the manoeuvre time is identical. From a practical point of view, different numerical solutions of the OCP are related to the different guesses provided. Of course, all the numerical solutions will include the trapezoidal diagram of joint
, while the diagram of joint
varies.
Clearly, the solution in
Figure 2 can also be obtained from an OCP whose cost consists of the distance in the
vs.
joint space. In such a case, the independent variable of the OCP becomes the travelled distance
s (in the joint space), with the cost function being
and
in (
2). The dynamical Equation (
1) begin
which are again related to integrator chains (with the prime—derivatives with respect to distance
s—replacing the dot—derivatives with respect to time
t). As regards the path constraints (
3), in addition to those in (
17), the following equation is added:
to enforce the unit magnitude of the tangent vector in the joint space, i.e., to enforce that the prime is a derivative with respect to the travelled distance
s in the joint space. The numerical solution again consists of the straight line between the initial and final points. However, the manoeuvre time is not computed, since pure path planning is performed. The timing of joint motion can be computed with one of the several methods proposed in the literature once the path is provided [
12].
As a final remark, the minimum-time OCP solution can be forced to select the minimum distance (in the joint space) by adding the travelled distance to the cost function, i.e.,
where
w is a weight factor on the travelled distance term. When
, the original problem is obtained.
4.2. Minimum Time with Obstacle
In the case of an obstacle, the OCP can again be solved with the formulation illustrated in
Section 4.1. In order to avoid multiple minimum-time solutions, cost function (
32) is employed, thus forcing the solver to obtain the minimum-distance solution among the different minimum-time solutions. The only difference with respect to the OCP in
Section 4.1 is in the path constraints, which need to be inflated to prevent collision with the obstacle.
In this work, the obstacle is assumed to have a circular shape in the Cartesian space for illustration purposes. However, more complex shapes can be modelled by using multiple circular obstacles (see
Section 5.4) or by employing more advanced collision techniques [
42]. The constraints to avoid collisions are enforced on a discrete number of points along link 2 for illustration purposes. Of course, the constraints can potentially be enforced on link 1 as well. The additional path constraints associated with the obstacle are given by
where
N is the number of points that are monitored to prevent collision,
and
are from (
6), and
,
and
R are the centre coordinates and radius of the circular obstacle. In the example of the application presented in this work, the obstacle is centred at
= 0.45 m,
= 0.25 m with the radius
r = 0.1 m (see the solid circle in
Figure 5b).
The number of points
N significantly affects the solution.
Figure 5 shows the minimum-time solution when only the end-effector is monitored (
). Clearly, link 2 collides with the obstacle during motion, while the end-effector passes on the right side of the obstacle. The solution obtained in this case (
Figure 5) is identical to the one obtained without the obstacle (
Figure 2), again with a straight path in the joint space; see the solid line with crosses in
Figure 3a. However, this solution is acceptable if the two-link manipulator is a SCARA robot and the height of the obstacle is lower than the height of link 2. On the contrary, when
points are monitored, the solution becomes the one depicted in
Figure 6, with link 2 passing on the left side of the obstacle without a collision and the manoeuvre time increasing to
= 1.180 s. The path in the joint space is no longer straight; see the dotted line in
Figure 3a.
4.3. Minimum Time with Jerk Controls
The minimum-time solutions shown in
Section 4.1 and
Section 4.2 have discontinuities in acceleration whenever there are sudden changes in velocity, e.g., at the beginning, at the end and at the edges of the velocity profiles. Such discontinuities may lead to a number of issues in practical application but can be avoided by limiting the jerks [
12]. In the OCP framework proposed, a practical solution is to control the jerks, i.e., the time derivative of acceleration, instead of the acceleration.
The dynamic equation of the OCP is inflated by including integrator chains to compute the accelerations
from the jerks
and becomes
together with (
23)–(
26). The state variables are
, while the cost function remains (
32). The constraints on the velocity and acceleration are still (
17) and (
18), while the following bounds on the jerks are enforced:
where
= 500 rad/s
and
= 200 rad/s
are the values chosen in this work. The boundary conditions again include the initial and final positions (
19) and velocities, together with zero initial and final accelerations (
); i.e., rest-to-rest manoeuvres are considered.
The minimum-time solution when including an obstacle with
points monitored to prevent collision is shown in
Figure 7. The solution is quite similar to the one obtained when controlling the joint acceleration directly (
Figure 6), with differences at the beginning, at the end and at the edges of the velocity profiles, where the jerks are now limited. The manoeuvre time increases to 1.286 s, which is slower than in the case of controlling the acceleration directly.
4.4. Comparison of OCP and PRM Results
In this section, the proposed OCP trajectory-planning method is compared with the PRM [
32,
33], which is one of the most well-known methods employed for path planning in the presence of obstacles [
43]. The objective is to highlight the main differences between the approaches and optimisation results. Once the path is obtained with the PRM, polynomials can be used for motion planning. Therefore, in this case, path and motion planning are separate, in contrast to the proposed OCP approach, where the optimisation of path and motion is carried out simultaneously. The PRM is a sampling-based method that employs an algorithm to connect two points in the joint space while avoiding obstacles using randomly generated via-points within the configuration space, with the aim of minimising a defined cost. Following the approach in [
43], the Dijkstra algorithm is employed in this work [
32,
44] to connect the points.
The configuration space is restricted within
and
to reduce the dispersion of the randomly generated points. As in [
43], the cost employed is the manoeuvre time from point
h to point
k, computed using
where
and
are the joint positions of points
h and
k, respectively. The values used for the speed coefficient and maximum joint velocities are again
= 1.5,
= 3 rad/s and
= 8 rad/s. The method basically consists of generating
n random via-points within the configuration space, excluding the via-points inside the obstacle as well as the connections colliding with the obstacle, and running the Dijkstra algorithm with the defined cost to find sub-optimal movement between the initial and final positions. Finally, motion planning is carried out in this work using splines to connect the initial and final positions through the via-points while satisfying the velocity and acceleration limits in (
17) and (
18). Using splines through via-points is a standard approach [
32,
45,
46]. In this work, for each joint, a fourth-order polynomial is used between the initial point and the first via-point, and a fourth-order polynomial is used between the last via-point and the final point, while third-order polynomials are used between the via-points. The curve resulting from such a spline, sometimes referred to as the ‘4-3-4 spline’, is
, with zero initial and final velocities and accelerations, while jerks have discontinuities. The structure of the solution is thus consistent with the jerk-controlled OCP solution.
The PRM is compared with the solution obtained with the OCP in the case of an obstacle with
points monitored to prevent collision. The PRM is not deterministic; i.e., different results are obtained depending on the random points generated. Of course, changing the number of (random) points
n generated also changes the solution. Therefore, in this work, the method was run with 100 different sets of randomly generated points. In addition, the number of points generated was varied between 50 and 500 with a step of 50. As a consequence, 1000 optimisations were run. The manoeuvre times obtained range between approximately 1.4 s and 4.0 s, with a mean of 2.0 s and median of 1.9 s.
Figure 8 shows the PRM minimum-time solution (among the solutions found), which was obtained from a set with
randomly generated points. The Dijkstra algorithm selected four via-points (see the green crosses in
Figure 8b). The manoeuvre time is 1.418 s, which is slower than that obtained with the OCP approach with jerk controls (
Figure 7), although the general shapes of the velocity profiles are similar. This is not surprising, with the solution found by the PRM being sub-optimal.
6. Remarks
All the optimisations performed in this work start with a mesh consisting of 50 equally spaced intervals with 4 collocation points for each mesh interval. When obstacles are included, special attention is paid to providing the solver with an almost feasible guess solution, i.e., that which (almost) does not collide with the obstacles. The proposed method converges to an optimal solution, although (like most optimisation approaches) there is no guarantee that the solution found is locally optimal or globally optimal. Multiple guess solutions have been employed to confirm the optimality of the solutions reported in this work.
Problem scaling can significantly affect the convergence of the optimisation algorithm. Indeed, convergence criteria are often based on the notation of ‘small’ and ‘large’. A typical approach is to scale the problem variables from their physical representation to dimensionless quantities, which have desirable properties from the numerical perspective. In this work, all problem variables are scaled according to a reference mass , a reference length and a reference angular acceleration for planning with kinematic constraints or according to a reference torque for planning with dynamic constraints. Hence, the scaling of time is and for optimisation with kinematic and dynamic constraints, respectively.
The solution is typically found after 2–5 mesh refinements, with a mesh tolerance in GPOPS-II of and an error for the IPOPT solver of . The computational cost of the planning problems can be assessed considering the number of equations and the CPU time. In the case of planning with kinematic constraints, the OCPs consist of around 1000–1600 equations with CPU times ranging within 1–2 s (on a standard PC with Intel i7 and 16 GB RAM), depending on the obstacle and the number of points that are monitored to prevent collision. In the case of planning with dynamic constraints, the number of equations to solve is 1000–5000, with CPU times rising to 2–30 s. Of course, large CPU times are associated with problems involving multiple obstacles, via-point constraints and/or more complex robots. The number of points N monitored to prevent collision obviously affects the solution time. As an example, with , the solution times are typically 50% larger than in the case with .