Cyber-physical systems pose unique deliberation challenges, where complex strategies must be autonomously derived and executed in the physical world, relying on continuous state representations and subject to safety and security constraints. Robots are a typical example of cyber-physical systems where high-level decisions must be reconciled with motion-level decisions in order to provide guarantees on the validity and efficiency of the plan.In this work we propose techniques to refine a high-level plan into a continuous state trajectory. The refinement is done by translating a high-level plan into a nonlinear optimization problem with constraints that can encode the intrinsic limitations and dynamics of the system as well as the rules for its continuous control. The refinement process either succeeds or yields an explanation that we exploit to refine the search space of a domain-independent task planner. We evaluate our approach on existing PDDL+ benchmarks and on a more realistic and challenging rover navigation problem.