Second-order cones

The ice-cream cone behind every "stay within this distance" constraint, from robot steps to safety margins.

What you'll learn
  • Describe the second-order cone and why it is convex
  • Recognise a norm constraint as a slice of the cone
  • Write a robot step limit as an SOC constraint

The second-order cone in three dimensions is the set of points \((x, y, t)\) with

\[\sqrt{x^2 + y^2} \;\le\; t\]

The height \(t\) must be at least the distance from the vertical axis. At height \(t\), that allows a disc of radius \(t\); as \(t\) grows, the discs grow with it, and the stack of discs is an upright cone — the “ice-cream cone” your example_2d.py describes. In general dimension it is \({(\mathbf{x}, t) : |\mathbf{x}|_2 \le t}\).

It is convex: the norm satisfies the triangle inequality, so the average of two points inside the cone stays inside.

A constraint is a slice

The useful observation is that a familiar constraint is just a horizontal slice of this cone. Limiting how far a robot may move in one step,

\[\|\mathbf{p}_{\text{new}} - \mathbf{p}_{\text{old}}\|_2 \;\le\; d_{\max}\]

says the step \(\Delta\mathbf{p}\) must lie in the slice of the cone at height \(t = d_{\max}\): a disc of radius \(d_{\max}\) around the current position.

The cone t ≥ ‖(x, y)‖ with a slice at height d_max (orange). Its shadow on the ground (green) is the set of allowed steps; the arrow is a candidate step, green when it fits and orange when it does not. Drag d_max to raise the slice.

The script samples that disc and plots it as the feasible region:

# random points in the unit disc (rejection sampling), scaled to d_max
points = points * d_max + old_pos
The feasible region of a 2D distance constraint: a filled disc of radius d_max around the current position.
From example_2d.py: every point the robot may reach in one step.

Why it is worth a name

Constraints of the form \(|A\mathbf{x} + \mathbf{b}|_2 \le \mathbf{c}^{\mathsf{T}}\mathbf{x} + d\) define a second-order cone program (SOCP). They cover distance and speed limits, robust versions of linear constraints (stay feasible for every perturbation in a ball), and friction cones in robot grasping. A quadratic program is a special case, and SOCPs remain fast to solve — so modelling with them costs little and expresses a great deal.

Try it yourself. In CVXPY, plan three robot steps from \((0, 0)\) towards \((5, 2)\) with each step limited by cp.norm(p[k+1] - p[k], 2) <= 1, minimising the final distance to the goal. Which constraints are active at the solution? Then replace the 2-norm with the 1-norm and explain why the steps change direction.

View source on GitHub →