An Online Data-Driven Emergency-Response Method for Autonomous Agents in Unforeseen Situations