A Quadratic Program (QP) Formulation is a constrained optimization problem characterized by a quadratic objective function and linear constraints. In legged robot locomotion, it is the computational engine for whole-body control (WBC) and inverse dynamics, solving for optimal joint torques and contact forces that satisfy physical laws like dynamics, friction cones, and actuation limits in real-time. This formulation transforms high-level locomotion tasks into a numerically tractable convex optimization problem.
Glossary
Quadratic Program (QP) Formulation

What is Quadratic Program (QP) Formulation?
A mathematical framework for solving constrained optimization problems with quadratic objectives, foundational to real-time robotic control.
The standard QP for robotics minimizes a cost like tracking error, often expressed as (1/2)x^T Q x + c^T x, subject to linear equality constraints (e.g., Newton-Euler equations) and inequality constraints (e.g., ground reaction force limits). Solvers exploit the problem's convex structure for millisecond-scale solutions, enabling reactive balance and push recovery. This approach is central to model predictive control (MPC) pipelines, where it is solved repeatedly in a receding horizon to generate dynamically feasible, stable motions.
Core Components of a Robotics QP
A Quadratic Program (QP) is the mathematical engine for real-time robot control. It solves for optimal actuator commands by minimizing a quadratic cost function subject to linear constraints on dynamics, safety, and physical limits.
Quadratic Cost Function
The objective function that the QP minimizes. It is mathematically expressed as (1/2) x^T Q x + c^T x, where x is the vector of optimization variables (e.g., joint accelerations, contact forces).
- Purpose: Encodes the primary control task, such as tracking a desired center-of-mass trajectory or minimizing joint torques.
- Matrix
Q: A positive semi-definite matrix that weights the importance of different terms in the cost. - Real Example: For a humanoid robot, the primary cost might be to minimize the error between the current and desired centroidal momentum, heavily weighted by
Q.
Linear Equality Constraints
Hard mathematical rules that the solution must satisfy exactly. Represented as A_eq x = b_eq.
- Core Use: Enforce the fundamental physics of the system, primarily the floating-base dynamics equations (
F = ma). This ensures any solution is dynamically consistent. - Other Uses: Enforcing contact constraints (e.g., a foot in contact must have zero velocity) or specific task constraints (e.g., keeping the torso upright).
- Critical Role: These constraints are non-negotiable; a QP solver will fail if it cannot find a solution that satisfies them.
Linear Inequality Constraints
Boundaries that define the feasible region of solutions, expressed as A_ineq x ≤ b_ineq.
- Actuator Limits: Enforce maximum joint torques, velocities, and accelerations based on motor specifications.
- Friction Cones: Ensure contact forces lie within a pyramid defined by the coefficient of friction, preventing foot slippage. This is a linear approximation of a non-linear constraint.
- Stability Margins: Constrain the Center of Pressure (CoP) to remain within the support polygon for balance.
- Self-Collision Avoidance: Often formulated as linear constraints on joint positions to keep links apart.
Optimization Variables (x)
The vector of unknowns the QP solves for at each control time step (typically every 1-10 ms).
- Typical Variables:
- Joint accelerations (or torques via inverse dynamics).
- Contact forces at each foot.
- Centroidal spatial forces (net force and moment on the robot).
- Dimensionality: For a complex humanoid with 30 joints and 2 feet in contact,
xmay have 50+ dimensions. The QP efficiently finds the optimal combination of these variables to satisfy all tasks and constraints.
Hierarchical Task Prioritization
A method to manage competing objectives when all cannot be fully satisfied. It is implemented via a sequence of QPs or a single weighted QP.
- Strict Priority (Sequential QP): Solve a QP for the highest-priority task (e.g., dynamic consistency), then solve a subsequent QP for the next task (e.g., foot tracking) in the null space of the first.
- Weighted Priority (Single QP): Assign different weights in the
Qmatrix of the cost function. Higher-priority tasks get larger weights, but all tasks are solved simultaneously, potentially with trade-offs. - Example: Balance is always highest priority, followed by swing foot trajectory, then torso orientation.
How QP Formulation Works for Robot Control
Quadratic Program (QP) formulation is the mathematical backbone for real-time, optimal control in legged and mobile robots, transforming high-level locomotion tasks into solvable numerical optimization.
A Quadratic Program (QP) formulation in robotics is a constrained optimization problem with a quadratic objective function and linear constraints, solved in real-time to compute optimal control commands. It is the core computational engine for Whole-Body Control (WBC) and inverse dynamics, enabling a robot to simultaneously execute multiple tasks—like maintaining balance and tracking a foot trajectory—while strictly respecting physical limits on joint torques, friction cones, and Zero-Moment Point (ZMP) stability. The quadratic cost typically penalizes tracking errors and control effort, while linear constraints encode the robot's floating base dynamics and contact conditions.
The solver computes optimal ground reaction forces (GRFs) and joint accelerations or torques at control rates (e.g., 1 kHz). This formulation is central to Model Predictive Control (MPC) for locomotion, where a QP is solved repeatedly over a receding horizon to plan stable motions. Its power lies in balancing competing objectives under hard constraints, providing the mathematical guarantee needed for dynamic, physically interactive tasks like push recovery and terrain adaptation on unstructured ground.
Primary Applications in Legged Locomotion
In legged robotics, Quadratic Program (QP) formulations are the computational engine for real-time, whole-body control. They solve for optimal joint torques and contact forces by minimizing a quadratic cost (e.g., tracking error) subject to linear physical constraints (e.g., friction cones, torque limits).
Whole-Body Control (WBC)
Whole-Body Control uses QP to coordinate all robot joints to execute multiple, often competing, tasks simultaneously. The QP's quadratic cost function prioritizes tasks (e.g., foot tracking is more important than torso orientation), while linear equality and inequality constraints enforce physical laws like dynamics and contact stability. This allows a humanoid to walk while moving its arms, all while respecting actuator limits.
Inverse Dynamics with Constraints
Standard inverse dynamics computes torques for a desired motion but can violate physical limits. A QP formulation solves this by finding the torques that best achieve the desired joint accelerations while strictly enforcing:
- Torque limits of each actuator.
- Friction cone constraints to prevent foot slipping (
|f_tangential| ≤ μ * f_normal). - Unilateral force constraints (feet can only push, not pull, on the ground). This yields physically feasible torques for stable locomotion on real hardware.
Centroidal Momentum Control
Controlling the robot's aggregate linear and angular momentum (centroidal momentum) is key for balance. A QP solves for the optimal ground reaction forces (GRFs) at the feet to regulate this momentum. The cost minimizes deviation from a desired momentum rate, while constraints ensure:
- The net GRF equals the required centroidal wrench.
- Each foot's force lies within its friction pyramid.
- The Center of Pressure (CoP) remains inside the support polygon. This is the core of many dynamic balancing algorithms.
Task-Space Force Control
For manipulation with legs or compliant interaction, QPs distribute forces across multiple contacts. Given a desired net wrench to apply to an object or the environment, the QP solves for the individual contact forces at each foot or hand. Constraints ensure:
- The sum of forces equals the desired net force/moment.
- Each contact force satisfies friction and unilateral constraints.
- Forces stay within the actuator force-capacity limits. This is essential for robots performing cooperative lifting or pushing against surfaces.
Hierarchical Optimization (Lexicographic)
When tasks have strict priorities (e.g., balance over arm motion), a single QP with weighted costs is insufficient. Hierarchical QP (or lexicographic optimization) solves a sequence of QPs. The first QP optimizes the highest-priority task (e.g., maintaining ZMP stability). The second QP optimizes the next task (e.g., swing foot trajectory) subject to the constraint that the solution does not degrade the first task's optimal value. This guarantees critical constraints are never violated for less important objectives.
Real-Time Solver Integration
For legged locomotion, QPs must be solved at control rates (500-1000 Hz). This requires specialized real-time QP solvers like OSQP, qpOASES, or HPIPM. These solvers exploit the problem's structure:
- The Hessian matrix (from the quadratic cost) is often constant, allowing for pre-computation.
- Warm-starting uses the previous solution to accelerate convergence.
- Active-set or interior-point methods are tailored for the dense, small-to-medium-sized QPs typical in locomotion. Integration with the robot's real-time operating system is critical for deterministic loop timing.
Frequently Asked Questions
Quadratic Program (QP) formulation is a cornerstone mathematical tool for real-time robotic control. These questions address its core mechanics, applications in legged locomotion, and practical implementation details.
A Quadratic Program (QP) is a mathematical optimization problem characterized by a quadratic objective function and linear constraints. In robotics, particularly for legged and mobile systems, QPs are solved in real-time (often at 1 kHz) to compute optimal control commands. The quadratic cost function allows the formulation to naturally express trade-offs between competing objectives—like tracking a desired foot trajectory while minimizing joint torques—and the linear constraints rigorously encode physical limits, such as actuator torque limits, friction cone constraints to prevent slipping, and kinematic reachability. This combination makes QP formulation the computational engine for advanced control paradigms like Whole-Body Control (WBC) and certain Model Predictive Control (MPC) implementations, enabling robots to dynamically balance and move while respecting their physical reality.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Quadratic Program (QP) Formulation is a core mathematical tool for real-time robot control. These related concepts define the dynamic models, stability criteria, and control frameworks that QPs are designed to solve.
Whole-Body Control (WBC)
A hierarchical control framework for legged robots that coordinates all degrees of freedom to execute multiple tasks simultaneously. QP formulations are the standard numerical method for solving WBC problems in real-time.
- Primary Tasks: Maintaining balance (via Center of Pressure), tracking desired foot trajectories.
- Secondary Tasks: Posture control, minimizing joint torques, gaze direction.
- QP Role: The framework casts task priorities and physical constraints (like torque limits and friction cones) into a single Quadratic Program, which is solved at each control cycle (typically 1 kHz).
Centroidal Dynamics
The dynamics describing the relationship between the net external wrenches (forces and moments) acting on a robot and the motion of its Center of Mass (CoM) and its centroidal angular momentum. It is a critical abstraction for whole-body motion planning.
- Key Equation: The rate of change of the centroidal angular momentum equals the net external moment about the CoM.
- QP Integration: In locomotion QPs, centroidal dynamics provides the equations of motion that relate desired CoM accelerations and angular momentum rates to the required Ground Reaction Forces (GRFs) at the feet.
Model Predictive Control (MPC)
An advanced control method that uses an internal dynamic model to predict future system behavior over a finite time horizon and solves an optimization problem at each time step to determine optimal control inputs.
- Connection to QP: For linear or linearized dynamics with quadratic cost functions (common in legged locomotion), the MPC problem reduces to solving a Sequential Quadratic Program (SQP) or a series of QPs.
- Application: Used for high-level planning of CoM trajectories and footstep placements, while a faster WBC QP handles instantaneous torque control.
Inverse Dynamics
The computation of the joint torques or forces required to produce a desired acceleration for a robot, given its kinematic structure, mass properties, and current state of motion.
- Traditional vs. QP-based: Classical inverse dynamics computes a unique solution for a fully actuated system. For underactuated or constrained systems (like floating-base robots), it becomes an optimization problem.
- QP Formulation: The desired motion is expressed as a cost function (e.g., track desired joint accelerations), while physical constraints (torque limits, contact forces) form linear inequalities. The solver finds the optimal torques that satisfy all constraints.
Ground Reaction Force (GRF) & Friction Cone
The Ground Reaction Force (GRF) is the force vector exerted by the ground on a robot's foot. The friction cone is a linear constraint that ensures the foot does not slip.
- Friction Cone Constraint: Enforces that the tangential components of the GRF are bounded by the normal component:
sqrt(fx² + fy²) ≤ μ * fz, whereμis the coefficient of friction. This is a second-order cone constraint. - QP Linearization: For real-time QPs, the nonlinear friction cone is often approximated as a polyhedral cone (a pyramid) using multiple linear inequalities, turning it into a set of linear constraints compatible with standard QP solvers.
Reduced-Order Model (ROM)
A simplified dynamic representation, such as the Linear Inverted Pendulum Model (LIPM), that captures the essential dynamics for locomotion planning while ignoring the full robot's complexity.
- Purpose: Provides a tractable model for high-level MPC. The LIPM, for example, assumes constant CoM height and linearized dynamics.
- QP Bridge: The optimal CoM trajectory planned using the ROM becomes a reference for the whole-body QP. The full-body QP then computes the joint-level commands that best achieve the ROM's planned motion while satisfying all the physical constraints the ROM ignored.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us