A real-time optimal control approach to autonomous drifting