Robots in a human environment need to be compliant. This compliance requires that a preplanned movement can be adapted to an obstacle that may be moving or appearing unexpectedly. Here, we present a general framework for movement generation and mid-flight adaptation to obstacles. For robust motion generation, Ijspeert et al developed the framework of dynamic movement primitives [1], [2], [3], [4], which represent a demonstrated movement with a set of differential equations. These equations allow adding a perturbing force without sacrificing stability of the desired movement. We extend this framework such that arbitrary movements in end-effector space can be represented - which was not possible before. Furthermore, we include obstacle avoidance by adding to the equations of motion a repellent force - a gradient of a potential field centered around the obstacle. In addition, this article compares different potential fields and shows how to avoid obstacle-link collisions within this framework. We demonstrate the abilities of our approach in simulations and with an anthropomorphic robot arm.