This paper describes the formulation of a position and motion planning problem in an optimization setting. Emphasis is placed on planning movements in a confined workspace where contacts must be avoided. The formulation includes the possibility of extra degrees of freedom and is demonstrated in detail on a simple robot problem. Robot positioning and trajectory planning are considered within a two dimensional workspace and a recursive quadratic programming procedure is used for the optimization. The results presented herein show satisfactory performance and considerable promise for extension to more complex configurations and three dimensions.