A new approach to generating smooth piecewise local trajectories for mobile robots is proposed in this paper. Given the configurations (position and direction) of two points, we search for the trajectory that minimizes the integral of acceleration (tangential and normal). The resulting trajectory should not only be smooth but also safe in order to be applicable in real-life situations. Therefore, we investigate two different obstacle-avoidance constraints that satisfy the minimization problem. Unfortunately, in this case the problem becomes more complex and not suitable for real time implementations. Therefore, we introduce two simple solutions, based on the idea of polynomial fitting, to generate safe trajectories once a collision is detected with the original smooth trajectory. Simulation results of the different algorithms are presented.