# Compute vector of attraction plus repulsion forces in a 2D force field mapping

I'm developing a force field mapping of a two-dimensional space to move a robot to a goal avoiding obstacles.

My problem is that I don't know how to move it using attraction force and repulsion forces. I think I will get a vector (with a magnitude and direction), because they are forces. How can I get this vector?

In other words, what is the formula to compute that vector?

For the sake of simplicity, let's stick to one-dimensional space and deal with massless points. Then, knowing the complete state of your robot in terms of position and velocity $$\left(x,\dot{x}\right)$$, together with the target $$x_d$$, the attractive acceleration $$\ddot{x}$$ is given by:
$$\ddot{x} = K \cdot \left( x_d-x \right) - D \cdot \dot{x},$$
where $$K$$ and $$D$$ are the stiffness and damping factors, respectively, responsible for generating the attractive force toward the target (stiffness) as well as a drag (damping) that suitably decelerates the robot avoiding oscillations around $$x_d$$.
Once you have $$\ddot{x}$$, you can integrate it twice in time to get the temporal evolution.
The extension to the 2D and 3D cases is pretty immediate, whereas to account for the repulsive force yielded by the obstacle $$x_o$$, you have to invert the sign of the term $$K\cdot\left(x_o-x\right)$$.