infinite looping of robot trajectory; improved memory allocation