Dynamic Movement Primitives: Volumetric Obstacle Avoidance Using Dynamic Potential Functions

Obstacle avoidance for DMPs is still a challenging problem. In our previous work, we proposed a framework for obstacle avoidance based on superquadric potential functions to represent volumes. In this work, we extend our previous work to include the velocity of the trajectory in the definition of the potential. Our formulations guarantee smoother behavior with respect to state-of-the-art point-like methods. Moreover, our new formulation allows to obtain a smoother behavior in proximity of the obstacle than when using a static (i.e. velocity independent) potential. We validate our framework for obstacle avoidance in a simulated multi-robot scenario and with different real robots: a pick-and-place task for an industrial manipulator and a surgical robot to show scalability; and navigation with a mobile robot in dynamic environment.


Introduction
Robots are now used in complex scenarios, ranging from industrial and manufacturing processes to aerospace and health care. As their involvement in common human tasks increases, adaptability and reliability at the motion planning level is often required, and imitation of human behavior often helps in this direction. Standard motion planning techniques, such as splines, potentials and others [15,25,16,24], work well when an objective function has to be optimized (e.g. minimize the time of execution of the trajectory, or the energy consumption). A Learning from Demonstration (LfD) approach, is usually preferable if one needs to learn human gestures. In LfD, a human operator shows an example trajectory or task execution, and parameters are learned for replication in different situations and environment. In last fifteen years, various LfD approaches (as Gaussian Mixture Models [13], Extreme Learning Machines [7,3], and others [1]) have been developed in order to replicate human gestures. These LfD techniques may require a huge amount of demonstrations to be properly trained, which can represent a bottleneck when many different motion primitives have to be learned (e.g., for productive and cost reasons in industry). In this paper we focus on the obstacle avoidance problem within the Dynamic Movement Primitives (DMPs) framework [10,29,18,6]. DMPs permit to learn a trajectory from just one demonstration. They encode the trajectory in a system of second-order linear Ordinary Differential Equation (ODE), where a forcing term is learned as a linear combination of predefined time-dependent functions. They are successfully used in many robotic scenarios, such as cloth manufacturing [12], reproduction of human walk for exoskeletons [8], and collaborative bimanual tasks [4]. Obstacle avoidance for DMPs has been successfully treated for point-like obstacles (e.g. [18] and [6]. On the other hand, volumetric obstacle avoidance has been treated in our previous work [5] using potential functions. Other approaches (e.g. [17,22,23,30]) require multiple demonstrations with different types and sizes of the obstacles. In this work we improve our previous framework [5]. In particular, we introduce a new potential function. This new potential is velocity-dependent, and this allows to achieve smoother obstacle avoidance behaviors compared to static (i.e. dependent only on position) potentials. Moreover, we will show that our approach results in trajectories that deviate less from the desired behavior than other frameworks. We validate our approach in a simulated multi-robot coordination scenario, where three mobile robots have to reach pre-defined targets while avoiding each other and obstacles in the scene. We also show the generality of our frameworks as applied to different real robotic scenarios. In detail, we test a pick-and-place task with an encumbrant industrial manipulator, combining DMP-level obstacle avoidance with collision-free inverse kinematic computation. We then show that the scalability of DMPs is preserved with our framework, replicating the pick-and-place task on a smaller setup with a bi-manual surgical robot. Finally, we show the reactivity of our approach with a mobile robot in a dynamic scene with moving obstacles to be detected by a RGB-D camera. In Section 2 we recall the theory of DMPs, focusing, in Section 2.1, on the existing methods to treat obstacle avoidance. Then, in Section 3 we present our new dynamic potential function. In Section 4 we show our results: in Section 4.1 we compare our new method to the state of the art, showing that our novel method results in a trajectory that is both smoother and it remains to the learned one; in Section 4.2 we compare our previous static potential for volumes with the new dynamic one, in a scenario with multiple mobile robots and prior scene awareness; in Section 4.3 we compare our frameworks (static and dynamic) with the aforementioned robots.
Our code, freely available at https://github.com/mginesi/dmp vol obst includes a Python 3.5 implementation of DMPs and our proposed approach to volumetric obstacle avoidance.

Dynamic Movement Primitives
Dynamic Movement Primitives is a framework for trajectory learning. It is based upon an Ordinary Differential Equation (ODE) of spring-mass-damper type with a forcing term. This framework has numerous advantages that make it well suited for robotic applications. First, any trajectory can be learned and subsequently executed while changing starting and goal positions. Second, the executed trajectory will always converge to the goal, maintaining a similar shape to the learned trajectory. Third, the learned trajectory can be executed at different speed simply by changing a single parameter. Finally, DMPs have been proven to be flexible enough to being extended in multiple ways: for instance, the formulation can be modified to deal periodic movements [11,31], to learn sensory experience [21,20], and to work in unit quaternion space (in order to model orientations) [32,28]. Another extension, that is the topic treated in this paper, is the inclusion of obstacle avoidance in the DMP framework [18,6,5].
In this Section, we recall the DMP formulation given in [18,6,19] upon which our work is based. Such formulation is an improvement of the original formulation by [10,11,29,9]. Subsequently, in Section 2.1 we will present the state of the art of obstacle avoidance methods for DMPs, highlighting their strengths and weaknesses.
Dynamic Movement Primitives consist of the following system of Ordinary Differential Equations: Vectors x, v ∈ R d are, respectively, the position and velocity of the system; and x 0 , g ∈ R d are, respectively, the starting and goal positions. Matrices K, D ∈ R d×d + are, respectively, the elastic and damping terms of the system. Both are diagonal matrices, K = diag(K 1 , K 2 , . . . , K d ), D = diag(D 1 , D 2 , . . . , D d ), and satisfy the critical dumping relation D i = 2 √ K i , so that the un-perturbed system, i.e. when f ≡ 0, converges as fast as possible to the unique equilibrium (x, v) = (g, 0). Scalar τ ∈ R + is a temporal scaling factor which can be used to make the execution of the trajectory faster or slower. Function f : R → R d is the forcing (also called perturbation) term. Scalar s ∈ (0, 1] is a re-parametrization of time t ∈ [0, T ] governed by the so called canonical system where α ∈ R + and the initial state is s(0) = 1.
The forcing term f (s) = [f 1 (s), f 2 (s), . . . , f d (s)] is written in term of basis functions. Each component fp(s), p = 1, 2, . . . , d has then the form where p ω i ∈ R is called weigth, and ψ i (s) is a Gaussian Radial Basis (GRB) function defined as with centers c i defined as and widths defined as During the learning phase, a desired trajectory x(t) and its velocity v(t) are recorded. Then, from (1a), the desired forcing term f (s(t)) is computed (after fixing matrices K and D). Finally, the weights p ω i , i = 0, 1, . . . , N , p = 1, 2, . . . , d that best approximate the desired forcing term f using formulation (3) are computed. During the execution phase, starting and goal positions x 0 , g are set, and the forcing term f is computed using (3) with the weights computed before. Solving the dynamical system (1) will give a trajectory of similar shape to the learned one, that start from x 0 and converges to g. In Figure 1 an example of the spatial generalization property of the DMP framework is shown.

Methods for Obstacle Avoidance
In the literature, there exist two main ways to implement obstacle avoidance in the DMP framework. The first approach is the so-called Stylistic DMPs [17] in which a probability distribution q( p ω i |ζ) of the weights, conditioned to a style parameter ζ is learned, instead of the set of weights { p ω i }. The style parameter can be, for instance, the size of an obstacle. The second approach, instead, consists in adding a repulsive term ϕ(x, v) ∈ R d , that 'pushes' the trajectory away from the obstacle, to (1a), that then reads In full generality, the repulsive term ϕ depends on both position x and velocity v of the system, but we will see that for some methods, it depends only on the position. This second approach can be further subdivided into two sub-categories. The first includes all those approaches that require an additional learning phase, in which executions both with and without obstacle are recorded, to model ϕ. For instance, in [23] and [30] a Neural Network is used to model the perturbation term. In [22] an analytical formulation is presented, but, the number of free parameters that has to be tuned requires an additional learning process. The second sub-category, in which our approach fits, comprehends all approaches in which there is no need for any additional learning phase. This is a great advantage, since the DMP can be used in virtually any situation, while the learning approaches may fail in situations too dissimilar to the ones shown during the learning phase. The proposed method enters the 'designed by hand' approaches, therefore we will recall here, and compare our approach to later, only the methods that do not require any additional learning phase.
A potential field approach for point obstacles is proposed in [14] where an obstacle creates a potential field U (x) at the system position x. The perturbation term ϕ(x, v) in this case depends only on the position (and not on the velocity) and is the negative gradient of the potential: with the potential defined as where η ∈ R + is a constant gain, p 0 ∈ R + is the influence radius of the obstacle, and p(x) ∈ R + is the distance between the obstacle and the system's position. It was pointed out in [18] that the perturbation term (8) obtained using (9) as potential may result in non-smooth obstacle behaviors since it does not depend on the velocity v of the system. Thus, the following 'dynamic' (i.e. velocity dependent) potential is proposed where λ, β ∈ R + are constant gains, and θ, depicted in Figure 2a, is the angle taken between the current velocity v and the system's position x relative to the position o of the obstacle: where ·, · denotes the standard scalar product in R d , and p(x) still denotes the distance between x and the obstacle. For potentials depending on both position x and velocity v of the system, the perturbation term is defined as the negative gradient with respect to the position: (14).  (11) and (14) respectively. We remark that the two main differences. Firstly, in the steering angle (on the right) the velocity vector takes into consideration also the velocity of the obstacle. Secondly, the two angles are complementary, assuming same x − o, v, andȯ = 0, since in this case the cosines are opposite: cos θ = − cos ϑ.
The following perturbation term was proposed in [6]: where γ, β ∈ R + are constant gains. The steering angle ϑ (depicted in Figure 2b) is defined as where o andȯ are position and velocity of the point obstacle. Matrix R is defined as the rotation matrix of angle π/2 with respect to the axis generated by (o − x) × v, where × denotes the cross product in R 3 . This formulation presents an important advantage and two important shortcomings with respect to the previous two approaches. The advantage is that this formulation guarantees convergence to the goal position if the obstacles are still. On the other hand, using potential functions (9) and (10), there may be cases in which the system remains 'trapped' in a local minima. However, as defined in [6], the matrix R makes sense only in R 3 (and R 2 ). Thus this approach can be used only when DMPs are used in ambient space, and not joint space. Moreover, formulation (13) does not depend on the distance from the obstacle, and the same 'importance' is given to close and far obstacles: this may result in oscillatory behaviors, as pointed out in [5].
The presented methods work only on point obstacles. Volumetric obstacles can be modeled using point clouds or by choosing a 'critical point' on the surface of the obstacle itself. However, both these strategies may generate odd behaviors: using a point cloud may result in high computational time, and it is in general hard to decide a priori how dense the point cloud should be; and the use of a critical point (e.g. the closer one) can result in non-smooth behaviors since this point is constantly changing. For this reason, we proposed, in [5], a novel method to implement volumetric obstacle avoidance, based on the theory of superquadric potential functions [33]. In this approach, the following static potential function is defined where A, η ∈ R + are gain parameters. Functional C : R d → R is an isopotential function that vanishes on the surface of the obstacle. In R 3 we defined it as that vanishes on the surface of a generalized ellipsoid. By tuning parameters m, n and functions f 1 , f 2 , f 3 it is possible to model obstacles of any shape (their boundary will be the zero-level set of (16)). We remark that any function C satisfying: I1. The boundary of the obstacle is the zero-level set of the isopotential; I2. The value of C increases when the distance from the obstacle increases; can be used as isopotential in place of (16) when defining (15). This means that this approach can be theoretically used also in joint space. The perturbation term in this approach is defined as in (8):

New Potential Function
In this work, we propose a dynamic potential function for volumetric (non-pointwise) obstacles, thus merging the frameworks (10) and (15). Similarly to [18], we aim at designing a potential that satisfies the following three properties: P1. The magnitude of the potential decreases with the distance of the system from the obstacle; P2. The magnitude of the potential increases with the velocity of the system v and is zero when the system is not moving; P3. The magnitude of the potential decreases with the angle between current velocity direction v/ v , and the direction towards the obstacle; and, if the system is moving away from the obstacle, the potential should vanish.
To this end, mimiking (10), we define the dynamic potential function where λ, β ∈ R + are constant gains, and function C(x) is any ispotential satisfying Properties I1. and I2. given in Section 2.1. The angle θ is taken between the system's velocity v and the direction between system's position x and the closer point of the obstacle. Thanks to Property I2., we have that the gradient ∇xC(x) of the isopotential C(x), is always perpendicular to the obstacle surface. Thus, at least for convex obstacles, the angle θ can be computed using while it is not well defined for non-convex obstacles. An intuition for these two observations are given in Figure 3.
Example of non-convex obstacle in which θ is not well defined: the purple dotted line shows the points in which ∇xC(x) does not exists.  Figure 3a shows how the angle θ is defined when the gradient ∇xC(x) of the isopotential exists. Figure 3b, instead, shows an example on how non-convex obstacles result in non differentiable isopotentials, and thus it is not possible to define the angle θ.
Remark 1 For non convex obstacles, some workarounds can be used. First, if neither the starting position nor the goal are in the 'holes' of the obstacle, that is they are not in the convex hull of the obstacle, then the convex hull itself can be used as obstacle. Second, one can think at relaxing the concept of gradient to allow sub-differentials. In such case, the sub-gradient exists but it is not unique. Thirdl a non-convex obstacle can be split in multiple convex components, and each component would generate its own potential.
The potential defined in (17) clearly satisfies Properties P1.-P3.. Indeed, the potential is a decreasing function of both C(x) and θ, thus it satisfies P1. and P3.. Moreover, it is an increasing function of v , and thus it satisfies also P2..    (17) for an ellipse in R 2 . The velocity vector v is set to v = [1,1] . The gains are set to λ = 2, β = 2, and η = 1. The ellipse has center in [ 1 /2, 1] , horizontal axis 2, and vertical axis 1. In both figures, the potential has been cropped at value 1 for display purposes: it goes to infinity on half of the boundary of the obstacle (on the other half, the system goes away from the obstacle, so the potential is zero).
As an example, we show in Figure 4 the potential (17) for an elliptic obstacle in R 2 , whose isopotential is where the center of the ellipse is x = [ x 1 , x 2 ] and the horizontal and vertical axes are, respectively, 1 and 2 . The perturbation term is defined as in (12) and is computed as follows: The term ∇x(cos θ) can be computed as For instance, let us consider the case in which the isopotential C(x) is an ellipsoid in R 3 with center x = [ x 1 , x 2 , x 3 ] , and axes ( 1 , 2 , 3 ), In this case, the gradient is The quantities ∇x ∇xC(x), v and ∇x ∇xC(x) in (19) read, respectively, Yes No potential (17)  We emphasize that the proposed approach encompass most of the desired properties of obstacle avoidance frameworks for DMPs since it is: dynamic, well defined in R n , volumetric, and distance dependent. On the other hand, with this approach it is not guaranteed the convergence to the goal since local minima may arise. However, as we already pointed out in [5], it is unlikely to encounter a local minimum, and if it happens, a perturbation term pushing the trajectory out of it can be easily added to the DMP formulation. In Table 1 a summary of the properties of both the approaches presented in Section 2.1 and the proposed approach is given. From this, it is possible to observe that the proposed method is the one satisfying the greatest number of desirable properties.
Remark. Formulations (11) and (18) do not take into account the velocity of the obstacle. However, it is straightforward to extend the definition to this case by simply substituting v with v −ȯ, whereȯ denotes the velocity of the obstacle.

Synthetic Experiments
In this Section, we test and compare the behaviors of the approaches recalled in Section 2.1 and our novel approach, presented in Section 3, performing the same test we performed in [5]. In the first test, we show the behaviors of all the methods in the presence of a single obstacle (an ellipse). For the point obstacle methods, the obstacle is modeled using a point cloud on the boundary of the obstacle itself. We then add a second obstacle (a circle) to the previous scenario.
In the first test, we generate the following trajectory in the plane: (x 1 (t), x 2 (t)) = (t cos(π t), t sin(π t)), t ∈ [0, 1]. Then, we learn a DMP with elastic and damping constants, respectively, K = K Id 2 and D = D Id 2 , where Id 2 denotes the 2 × 2 identity matrix, and K and D have values K = 1050 and D = 2 √ K ≈ 65. In this test, the obstacle is an ellipse centered in (−0.5, 0.7) with semi-axis 0.3 and 0.2. For the tests done using point-wise obstacle avoidance methods (9), (10), and (13), the boundary of the obstacle is discretized using fifty equally distributed points. The hyper-parameters for all the methods are given in Table 2. The resulting trajectories are shown in Figure 5. From this first test, we compute, at each time t how much the trajectory deviate from the learned behavior in order to avoid the obstacle. This "error" is computed as where xtrue(t) is the learned trajectory, and x(t) is the adapted behavior. In Figure 6a it is possible to observe that the proposed method results in the trajectory that deviate less from the learned one. To discuss the smoothness of the different behaviors, we compute, at each time t, the norm ẍ(t) of the accelerationẍ(t) of the adapted trajectory. As shown in Figure 6b, we see that the proposed method results in the less oscillatory behavior of ẍ(t) . This last aspect makes the proposed method the most stable one when controlling the position of a robot.
In summary, the proposed dynamic potential (17) gives both the smoother behavior and the trajectory that remains closer to the learned one between al the methods we presented in Section 2.1, thus making it the most suitable in real applications.
As second synthetic experiment, we maintain the same conditions of the experiment before (desired curve, as well as DMP and obstacles' hyper-parameters), and we add a second obstacle. This new obstacle is a circle centered in (0.15, 0.4) and with radius 0.1. For the point-wise obstacle avoidance methods, the circumference     is discretized with fifty equally distributed nodes. Figure 7 shows the adaptation of the DMP to the presence of the obstacles, Figure 8a shows the distance between desired trajectory and DMP, and Figure 8b shows the 2-norm of the acceleration of the DMP as function of time. Also in this test, it is possible to observe that the proposed method still gives the trajectory that less deviate from the learned one, while maintaining the less oscillatory behavior at acceleration level.

Experiments with robots in simulation
In this Section, we describe experiments performed with Kuka YouBot models in a simulated environment. These experiments are useful to validate the results highlighted in the previous section with an application of our framework to a more realistic use case. The simulation scene is shown in Figure 9. It includes three YouBots which can move in a rectangular region defined by four walls (treated as obstacles), with fixed cubes as obstacles on the way. Each robot must reach a specific target position, defined by a platform with the same color as the robot. We   assume that the geometry and the positions of the obstacles in the scene is known in advance. The scene is built in the popular CoppeliaSim simulation environment from Coppelia Robotics [27], which allows to simulate the dynamics of the robots and to control them through ROS topics as in real applications. Each Youbot is controlled in position by a DMP with x, v ∈ R 2 ; we do not control the orientation of the robots along their normal axis, since we are interested in the obstacle avoidance problem for Cartesian DMPs. In order to guarantee the synchronization between the robots, we construct a 6-dimensional DMP, concatenating the components x, v,v ∈ R 2 of position, velocity and acceleration of each YouBot in a single array. In this way, the robots share the same canonical system. The obstacle-free trajectory of each robot towards its target is a straight line. In this way, it is clear from the scene that the robots would collide during their motion. Since the objects in the scene are known a priori, one could argue that the collision between the robots could be avoided computing the trajectories in advance, and coordinating the motion of the robots (e.g. tuning the speed of each of them appropriately). Multi-robot motion coordination has been extensively studied, and it is out of the scope of this paper. We refer the reader to [34] for a recent survey. In our experiments, we have decided to simulate a more realistic multi-robot task, in which the robots do not know the trajectory of each other in advance. Hence, we model each YouBot as a dynamic potential using our formulation as in (17), so that it influences the forcing terms of the other robots. In this way, we show how our framework for obstacle avoidance is suitable for reactive motion planning. At each time step, we build an ellipsoid around each YouBot, setting m = n = 1 in (16). We control the center point of the YouBots, therefore the semi-axes of the ellipsoid are set as the full dimension of the robot (width × length) to avoid collisions. The parameters for the dynamic potential function are set as λ = 60, η = 0.2, β = 2 after empirical evaluation. When computing the forcing term for each robot, we compute the velocity term in (12) as the relative velocity between the robots. We test two different straight line trajectories, one with null forcing term and the other with constant speed, to verify   the independency of our framework with respect to the specific trajectory to be executed. The constant speed trajectory is first generated synthetically; then, the weights are learned as explained in Section 2. The DMP parameters are set as as K = 3050, α = 4, D = √ K for both sets of weights. The trajectories are computed at 1 ms step of integration. We model the walls and the fixed obstacles as generalized ellipsoids (enlarged of the dimension of the YouBots), setting n = m = 2 in (16) to better approximate the sharp edges. We compare the performance of our previous static obstacle formulation (15) with our novel one, modeling the fixed obstacles with both methods. The results are shown in Figure 10.
Figures 10a-10b are obtained setting A = 60, η = 2 in (15). Figures 10c-10d are obtained setting λ = 60, β = 2, η = 2 in (17). Parameters are set after empirical evaluation. We notice that the dynamic potential formulation results in smoother trajectories as the robots move close to the cubes in the scene. This is due to the dependency of the forcing term on the velocity. In fact, the forcing term in (12) deviates the trajectory earlier depending on the module of the velocity when the robot moves in the direction of the obstacle, and not only on the position of the obstacle as in the static gradient formulation (8). We also notice that the shape of the trajectory does not change significantly with different potential models for the    obstacles. Hence, we conclude that it is convenient to model even fixed obstacles with dynamic potential functions.

Experiments on Real Setups
We now show the results of the tests performed on different robots. At first, we tested our obstacle avoidance framework on an industrial manipulator Panda from Franka Emika, studying a standard pick-and-place task with pegs and rings. Then, we replicated the same task on a smaller setup with a surgical robot da Vinci from Intuitive Surgical, showing that our framework is able to scale with the dimension of the setup. Finally, a scenario with a YouBot in a partially unstructured envi- ronment is tested, showing how our framework can be easily integrated with scene reconstruction techniques through vision sensors.

Experiments with Panda robot
The setup for the Panda robot is shown in Figure 11a. The robot must pick the green ring and place it on the green peg. On the way to the peg, the robot has to avoid the red peg, i.e. neither the end effector nor the grasped ring have to hit the peg. The task can be described by a simple state machine with four actions / states: move to ring, grasp, move to peg and release gripper. The moving actions are kinematically described with two DMPs in Cartesian space with null weights, i.e. straight line trajectories, with K = 3050, α = 4, D = √ 2K. The trajectories describe the motion of the center of the gripper of the robot. Notice from Figure  11a that the encumbrance of the end effector is significant, and controlling only the center of the gripper does not guarantee safe collision avoidance. As explained in our previous work [5], there are two solutions to this issue. One is to enlarge the radial dimension of the pegs according to the size of the end effector. The second solution is to exploit the kinematic redundancy of the 7-DOF manipulator and compute an obstacle-free joint configuration for each point in the DMP. We have  chosen the latter approach to limit the size of the obstacles and, hence, maximize the reachable workspace for the robot. We control the robot through its standard MoveIt / ROS interface, setting TRAC-IK [2] as inverse kinematics solver. TRAC-IK is a state-of-the-art library for this purpose, and it has been chosen because it allows to define optimal metrics to compute the joint configuration from a given pose. We set the solver to compute an inverse kinematics solution which maximizes the manipulability of the robot, defined as det(JJ T ) [5]. Though we do not control the orientation of the end effector with our DMP formulation, we constrain the orientation to be within 5 • (along each axis) from the initial orientation for each Cartesian waypoint (shown in Figure 11a). Then, we gradually relax this tolerance if no inverse kinematcs solution is found. We also constrain two consecutive joint configurations to differ no more than 45 • on each joint, so that we are able to avoid abrupt movements during the execution. The scene (location of the peg base, the pegs and the ring) is assumed to be known in advance. Hence, obstacles (the base and the pegs) are represented as superquadric potential function shaped as cylinders (assuming the z−axis as the normal to the base, exponents in (16) are set as m = n = 1, p = 2). Figure 11 shows the main steps in the task execution. In Figure 12 we show the trajectories for the two actions. Notice that the radial dimension of the pegs is enlarged when moving to the peg. In fact, we need to avoid that the grasped ring hits the obstacles. Hence, the radius of the base of the pegs is augmented of the diameter of the ring. Obstacles are modelled with our dynamic potential formulation when moving to the ring, setting λ = 10, η = 2, β = 2 in (17). When moving to the peg, we compare our approach with the static potential formulation in (15), setting A = 10, η = 2 (Figures 12b-12c). We notice that the dynamic potential determines a glitch of the trajectory along the z−axis in correspondence of the peg, while this phenomenon does not occur with the static potential. This is due to the dependency of (12) on the velocity of the robot. Since there is a difference between the z−coordinates of the starting and goal position, the natural attraction of the dynamical system in (1) towards its goal sums to the repulsive potential of the obstacle induced by the relative position and velocity of the robot moving upwards. Our Online resource shows the full execution of the task with the static potential formulation. Fig. 13: The setup for the peg transfer task with the da Vinci surgical robot: PSM1 on the right and PSM2 on the left.

Experiments with the da Vinci surgical robot
We replicate the peg transfer task using the da Vinci surgical robot from Intuitive Surgical controlled through the da Vinci Research kit 1 and ROS, with the setup shown in Figure 13. The robot has two arms, named PSM1 and PSM2. Hence, we modify the state machine for the task. The PSM1 must move to the blue ring, grasp it, move the ring to the center of the base and exchange it with the PSM2. Then, the PSM2 carries the ring to the blue peg and the task ends. The scene description (locations of pegs, the ring and the base) is assumed as a prior. We have designed the initial location of the arms and the ring in such a way that the pegs act as obstacles for the robot. In order to make a comparison with the task with the Panda robot, the transfer action can be seen as a combination of a move to ring action for the PSM2 and a move to peg action for the PSM1, where the goal is actually the center of the base instead of a real peg. Hence, the actions executed by the surgical robot can be interpreted as a replication of the actions of the industrial manipulator, just scaled on a smaller size of the setup. For this reason, we represent the obstacles with the same superquadric potentials (i.e. the same parameters) as in the Panda task. The trajectories of the robot are again described by Cartesian DMPs with null weights, and we build a single 6-dimensional DMP in order to share the same canonical system for the arms. We first test our novel dynamic potential formulation to model the obstacles. However, the DMPs does not converge to the goal in the transfer and when moving to the peg. On the contrary, our static potential formulation converges smoothly, as shown in Figure  (  Trajectories are referred to the center of the grippers, and they are expressed in a fictitious coordinate frame common to the PSMs, obtained using our calibration procedure presented in [26].
14. Figure 15 shows the main steps of the task execution. The reader is referred to our Online resource for the full execution. Notice that we do not need to compute inverse kinematics solutions from the DMP waypoints as with the industrial manipulator. In fact, the arms of the surgical robot have 6 degrees of freedom, and we force the orientation of the grippers to stay constant during the task. Moreover, Figure 13 shows that the encumbrance of the grippers is minor, hence they safely avoid obstacles.

Experiments with real YouBot
We test our obstacle avoidance framework with a real YouBot. The robot must move forward in a corridor for 2 meters to a pre-defined target, with an obstacle on its way. Differently from simulations presented in Section 4.2, we only assume that the walls are known in advance and modeled as superquadric potentials. On the contrary, the obstacle on the path of the robot is unknown, and it can be added to and moved away from the scene during the execution. Hence, the YouBot is equipped with a Realsense D435 RGB-depth camera from Intel as shown in Figure  16, in order to record the point cloud of the scene in real time. At each time step   the point cloud is filtered along the world z-axis to remove the floor and on its own depth to remove points beyond the target. Then it is clustered into separate point clouds for each object in the scene and is registered with the previous point cloud in a common reference frame to update the scene 17. Finally an ellipsoid as in (16) is fitted with n = m = 1, enlarging axes of the dimensions of the robot (since the motion of the robot is 2-dimensional, we consider only the planar coordinates of the ellipsoid). Fitting a pure ellipsoid rather than a pseudo-ellipsoid (n = m = 2) guarantees a smoother perturbation to the trajectory of the robot and leverages the real-time computational complexity. The robot is controlled by a 2-dimensional  DMP with null weights, with the same parameters as in the simulated scenario. The camera and the YouBot controller communicate through a ROS network. We test two different scenarios. At first (Figure 19) we add a box as an obstacle on the way to the goal right after the YouBot has started moving We model the box both with the static (15) and the dynamic (17) potential formulations. The plots in Figures  18a-18b show that both formulations guarantee smooth trajectory adaptation, though the proportional parameter λ in the dynamic potential must be reduced (see Figure 18b). Slight oscillations can be observed with the static potential when approaching the obstacle, since this formulation does not take into account the speed of the robot. On the contrary, the dynamic potential ensures smoother    approach to the obstacle, but slight oscillations can be observed when moving far from the obstacle. In the second scenario, we add the box in the scene later in time, in order to further challenge the reactivity of the DMP framework. Then, we remove the obstacle before the robot has overcome it, so that the trajectory adapts to the original straight line again. Main steps in this scenario are shown in Figure 20. The plots in Figures 18c-18d compare the static and the potential formulation for the obstacle. We notice that the static formulation guarantees smooth convergence to the goal with few oscillations, even if the obstacle is added when the robot is closer to it. On the contrary, the dynamic formulation generates a backward oscillation when approaching the obstacle. Parameters for DMPs and the potentials are the same as in the simulation experiments described in Section 4.2, except for the proportional coefficients in (15)- (17) which are specified in the plots. Our Online resource shows the execution of the task in the first scenario with the dynamic potential, in the second scenario with the static potential.

Conclusions
In this paper we have presented a new dynamic potential formulation for obstacle avoidance with DMPs in the Cartesian space. This formulation extends our previous static potential one based on position, in that it takes into account the velocity of the system governed by the DMP and of the obstacle. We have designed synthetic experiments and tests with simulated and real robots to compare our frameworks with the state-of-the-art ones existing in literature about DMPs. Experiments with real robots are performed with an industrial manipulator, a surgical robot and a mobile robot, in order to show the generality of our framework. One advantage of our formulations is that they consider volumetric obstacles, instead of point-like obstacles as other state-of-the-art methods, guaranteeing a more stable behavior. Volumes are modeled with superquadric functions, which allow to describe shapes of real objects with arbitrary degree of approximation. The synthetic experiments show that our potential formulations guarantee smoother acceleration behavior and minimal deviation from the obstacle-free trajectory defined by the forcing term of the DMP. Moreover, the simulation experiments with three mobile robots show that our formulations can cope with multi-robot obstacle avoidance in real time, without any predefined coordination strategy between the robots. Our new dynamic potential formulation generates fewer oscillations in proximity of the obstacles with respect to the static potential one. In fact, the dynamic potential depends on the relative speed of the robot with respect to the obstacles, hence it deviates the trajectory earlier when the obstacle is approached. However, the experiments with real robots show that the dynamic potential can result in higher deviations from the original trajectory, depending on the forcing term of the DMP and the position of obstacles in the scene. On the contrary, the static potential performs better in all the experiments with the real robots, including the scenario with the mobile robot when an obstacle is added on its way during the execution. The experiments with the industrial manipulator and the surgical robot on a pick-and-place task show that our frameworks can scale to different dimensions of the setup. The major drawback of our formulations is that they do not guarantee convergence to the goal, which is a typical issue with potential-based formulations. Future research will focus on the extension of our frameworks to the quaternion space. In fact, while the superquadric description of the volumes allows to approximate the shapes of real objects and to save more of the available workspace, the obstacle-aware adaptation of the orientation of the robot is not implemented at the moment. Hence, the obstacles should be enlarged of the dimension of the end effector. This is particularly evident in the scenario with the industrial manipulator, which has an encumbrant end effector. We have partially solved this issue in our experiments, exploiting the kinematic redundancy of the robot and an efficient inverse kinematics solver to generate obstacle-free joint configurations from the Cartesian DMP waypoints. However, this yields to higher computational time and slower execution. We believe that representing the obstacles directly in the quaternion space at the DMP level would improve the performances.