Time optimal control of mechatronic systems through embedded optimization door