General Trajectory Generation Code