1. A method for determining a trajectory for a multi-motor control system moving a mass, wherein the trajectory includes positions of the mass as a function of time, comprising: determining a cost function representing a movement of the mass by the multi-motor control system from an initial point to a final point, wherein an optimization of the cost function is subject to non-convex constraints due to avoidance of a region of the obstacle located between the initial point and the final point; determining a union of convex regions connecting the initial point with the final point, each convex region does not intersect the region of the obstacle; determining a convex constraint for each convex region to produce a set of convex constraints; determining a set of switching times when the trajectory crosses boundaries of the convex regions; and optimizing the cost function by jointly updating the positions and the set of switching times to produce an optimal trajectory of the movement, wherein the optimizing is subject to the set of convex constraints, such that each convex constraint is applied independently for each corresponding convex region, wherein steps of the method are performed by a processor.