Trajectory generation for smoothly grasping moving object