# Computing attractive and repulsive forces from gradient of Artificial Potential Functions for path-planning

I'm trying to design a controller for a path-planning robot using Artificial Potnetial Functions [Prof. Howie Choset, Page 6 and 9, $$\nabla D(q)$$] and had a question about calculating the gradients of the potential functions to generate the force.

From what I understand, the attractive and repulsive force is calculated from the gradient of the attractive and repulsive potentials, i.e. $$\nabla f_{a}$$ and $$\nabla f_{r}$$.

$$$$f_{r} = \begin{cases} \eta * (1/d(q, q_{o}) - 1/\rho_{o}))^2, && d(q, q_{o}) \leq \rho_{o} \\ 0, && d(q, q_{o}) > \rho_{o} \end{cases} \tag{1}$$$$

$$$$f_{a} = \epsilon * d(q, q_{g})^2 \tag{2}$$$$

$$q$$, $$q_{o}$$ and $$q_{g}$$ are the coordinates of location of the agent, nearest obstacle and the goal respectively. $$\rho_{o}$$ is the repulsive radius of each obstacle. $$d$$ is the Euclidean distance.

This gradient operation on each of the potentials in (1), (2), yields an $$x$$ and a $$y$$ component, which are the $$x$$ and the $$y$$ components of the gradient vector at that point. We then combine all the horizontal components and the vertical components to calculate the angle, $$\theta$$, of the resultant force $$F_{r}$$ with the horizontal.

Is this the right approach or am I misinterpretating the $$\nabla$$ operations? The $$X$$ and the $$Y$$ components of the gradient at each point have to be computed seperately and then combined or am I missing something here?

Any and all help is appreciated!