Embedding detailed robot energy optimization into high-level scheduling