Text this: Stall and spin recovery using optimal trajectory planning