Optimal control of cold atoms for ultra-precise quantum sensors