The need for rapid and reliable robot deployment is on the rise. Imitation learning (IL) has become popular for producing motion planning policies from a set of demonstrations. However, many methods in IL are not guaranteed to produce stable policies that can be used for motion planning.The generated policy may not converge to the robot target, reducing reliability, and may collide with its environment, reducing the safety of the system. Also, demonstration data is tedious to collect either through kinesthetic teaching or expert performing the task, both involving human labour. Stable estimator of dynamic systems (SEDS) produces stable policies by constraining the Lyapunov stability criteria during learning, but the Lyapunov candidate function has to be manually selected, which can result in unsolvable scenarios. In this work, we propose a novel method for learning a Lyapunov function and a policy using a single neural network model from automatically generating demonstration data in simulation. The method can be equipped with an obstacle avoidance module for convex object pairs to guarantee no collisions. We demonstrated our method is capable of finding policies in several simulation environments and transfers to real-world scenarios.