Manuscript Offprint
arXiv:2610.19295Learning Keypoint Constraints from Visual Demonstrations for Safe Motion Planning
Zheng Qiu , Zhouyu Zhang , Ninghan Zhong, and Glen Chou
Abstract—We present Keypoint Constraint Learning (KCL), a framework for learning task-relevant motion constraints from visual demonstrations and for planning safely with the extracted constraints. To make constraint learning tractable from RGB-D observations, we represent demonstrations using sparse 3D object-centric keypoints and semantic mask centroids extracted through segmentation, visual feature clustering, and point tracking. In this reduced geometric space, we learn keypoint dynamics and infer distance- and orientation-based constraints that make the expert trajectories feasible and approximately locally optimal by enforcing KKT optimality conditions in the reduced state space. We then plan with the learned constraints under uncertainty, using robustness margins derived from accumulated prediction error, and provide a theoretical analysis of how keypoint perception error and learned dynamics error affect the recovered constraints. We evaluate KCL on visual demonstrations from navigation to rigid/deformable manipulation, showing that it recovers multi-stage geometric constraints and outperforms baselines in downstream safe planning.
I. INTRODUCTION
Robotic behaviors depend on objectives and safety constraints that are often difficult for end users to specify. Constrained inverse optimal control (CIOC) methods can learn constraints and objectives from locally optimal human demonstrations [1], enabling safe downstream planning and control. Despite success in navigation and obstacle avoidance, most CIOC methods require labeled state-action demonstrations and analytical dynamics. This limitation is particularly important when accurate state estimates or representations are unavailable, as in deformable object manipulation. Video demonstrations offer a practical alternative with rich visual data and without heavy instrumentation, but raw images are high-dimensional and difficult to scale for control. Moreover, CIOC requires generalizable constraints and objectives that are difficult to define in pixel space. This creates a gap between vision and CIOC, motivating a visual representation that is structured enough for constraint learning.
To close this gap, we use keypoints as an intermediate representation between images and CIOC. Keypoints provide a low-dimensional object-centric scene description that preserves constraint-relevant environment geometry, unlike unstructured latent representations [2]. Their physical interpretability simplifies nominal keypoint-space objectives, such as minimizing displacement, which regularize CIOC while allowing constraints to be inferred solely from safe expert demonstrations. We propose KCL, a framework for Keypoint Constraint Learning from visual demonstrations. KCL extracts and tracks keypoints and semantic masks from paired RGB-D image-control demonstrations, and lifts them to the 3D world frame via depth maps. We represent the state using keypoints and mask centroids, learn dynamics in this visual space, and infer constraints from these trajectories. Assuming demonstrations noisily optimize a task objective while satisfying constraints, we enforce the Karush-Kuhn-Tucker (KKT) conditions to recover consistent constraints. We analyze learning error from imperfect keypoints and plan robustly using margins derived from accumulated prediction error.
Our contributions are: (i) a keypoint–mask representation for visual constraint learning; (ii) KKT-based inference of geometric constraints with learned dynamics and sensitivity bounds; (iii) a robust feedback planner; and (iv) simulation and hardware validation on navigation and multi-stage rigid/deformable manipulation, outperforming baselines in safety and success.
Stage 1: Avoid
Expert
Stage 2: Rotate

Stage 1: Avoid | learned boundary: t = 0-48
Stage 3: Insert
No learned inequality
Stage 2: Rotate | learned boundary: t = 49-62
Stage 3: Insert | learned boundary: t = 63-129
Plan

No learned inequality
(b)
Fig. 1. (a) Keypoint constraints learned from a video of a human reorienting and inserting a hammer, a multi-stage task where low-level distance/orientation constraints between objects are learned together with the task segmentation (Stages 1-3). (b) KCL plans a safe trajectory conforming with the constraints.
constraints from language and vision [6]–[8]. In contrast, we infer constraints from visual demonstrations via inverse optimality, without a retrieval database, language specification, or VLM-proposed test-time constraints, reducing hallucination and prompt errors while grounding constraints in expert behavior. VLM-free alternatives infer geometric equality constraints from demonstration variance [9], but require manual skill and keypoint annotation [10], or learn keypoint-space costs for goal reaching [11] without considering constraints. Our method instead learns interpretable keypoint-mask inequality constraints for safety and task requirements without VLMs or manual keypoint annotations. Constraint Learning. We build on CIOC, which infers inequality constraints from demonstrations using KKT optimality conditions [12]–[16]. CIOC is data-efficient because it exploits local optimality [13], but assumes known differentiable dynamics, predefined state representations, and full state-control observations [1], [13], [15]. Other geometric constraint-learning methods require fiducial markers or focus on equality constraints [17], [18]. Thus, existing CIOC methods are difficult to apply to visual settings without compact state representations, such as for deformable objects. Inverse constrained RL (ICRL) is an approach for inferring constraints from demonstrations in constrained MDPs [19]. Unlike CIOC, it usually assumes simulator access rather than closed-form dynamics and can handle unknown dynamics [20]. However, existing ICRL methods still assume known, fully-observed states. We instead learn from vision and provide bounds on satisfying learned constraints under imperfect keypoint detection and dynamics.
III. PRELIMINARIES AND PROBLEM STATEMENT
Keypoints. Keypoints [2] are sparse geometric features representing meaningful scene locations. They reduce raw pixels to task-relevant spatial information, such as object locations, contact regions, and relative distances. We also use semantic object masks as coarse object-level descriptors. Let be an RGB-D observation. From each frame , we extract keypoints , where each denotes a world-frame 3D position, and given masks extracted from , we denote their world-frame 3D centroids as . We represent the keypoints and centroids as stacked vectors
The stacked vector forms a reduced-order geometric state capturing object motion and structure, useful when analytical states are unavailable but visual tracks can capture task-relevant features.
KKT Constraint Learning. Consider a discrete-time trajectory , where is the state and the control input. We assume each expert demonstration is an approximately locally optimal solution of a “forward” constrained optimal control problem:
J is the demonstrator's cost, are known equality constraints (e.g., dynamics, start/goal), and are known inequality constraints, e.g., joint limits. We denote the unknown constraint family to be learned as , parameterized by . If a demonstration is locally optimal for (2), then under standard constraint qualifications [21] there exist Lagrange multipliers , , and such that the KKT conditions (3), denoted KKT( ; , , , ), hold:
Given demonstrations , the learner solves the “inverse” problem by finding constraints and multipliers that make all demonstrations satisfy the first-order necessary conditions for local optimality via (3) [13]:
Problem Statement. We are given demonstrations , where is the RGB-D image at time and is the control input. We assume the demonstrations are (potentially noisily) locally-optimal solutions of a constrained optimal control problem in the reduced keypoint-mask state space extracted from the images. For demonstration , the task objective is , with unknown weights . The unknown task constraints belong to a differentiable family . Within each task stage, the parameter vector is shared across time; for multi-stage tasks, each stage has its own parameter vector, and the stage boundaries may also be inferred. Our goal is to 1) infer and the stage-wise constraint parameters such that the demonstrations in are feasible and locally optimal under , and 2) plan safely using the learned parameters.
IV. METHODOLOGY
Our method first extracts keypoints and semantic masks from demonstrations (Sec. IV-A). Next, we learn geometric constraints over keypoints and centroids via the KKT conditions (Sec. IV-B). Finally, we plan robustly with the learned keypoint dynamics and constraints (Sec. IV-C).
A. Visual Demonstrations to Keypoint–Mask Trajectories
Given , we convert each raw demonstration into a low-dimensional trajectory for constraint inference. At time , the geometric state is the stacked vector defined in Sec. III. In simulation, masks and initial keypoints are directly available; in the real world, they are not. For real-world demonstrations, we use SAM [22] to extract initial masks , , from . These masks restrict keypoints to foreground regions and define semantic pixel-level centroids . Within each mask, we use DINov2 features [23] to select keypoints. We cluster the mask-restricted dense DINOv2 features with k-means and, for each cluster, select the mask pixel whose feature is closest to the cluster center. The selected pixels form the initial image-space keypoints . We then track keypoints over time with TAPNext++ [24], which estimates pixel trajectories and visibility. Depth and camera calibration lift tracked image keypoints to world-frame 3D coordinates via back-projection, and similarly compute 3D mask centroids. For the qth demonstration, this yields a reduced state-control trajectory for keypoint constraint learning:
(5)
B. Keypoint Constraint Learning
Given the keypoint–mask trajectories extracted from visual demonstrations, we formulate constraint learning as an inverse optimization problem in the learned visual state space. Following (5), for the q-th demonstration, the corresponding visual state-control trajectory is denoted by .
Learning keypoint dynamics. The KKT inverse problem requires equality constraints describing feasible state transitions. Since analytic dynamics may be unavailable, especially for deformable objects, we learn keypoint-space dynamics from demonstrations. A neural network is used to learn the state-transition map , . with a control-dependent component and a control-independent component , where is a learned gate. This factorization enables capturing both passive visual-state evolution and control-driven motion. The dynamics are trained via one-step prediction over demonstration data :
is treated as an equality constraint in the forward and inverse optimization problems. Its Jacobians with respect to the visual state and control, and , are computed by automatic differentiation and used in the stationarity equations of the KKT system (12c). Keypoint constraints. We set candidate constraint parameterizations as geometric relations on .
Distance Constraints: We consider the pairwise keypoint-mask distance constraint. For distance candidate i, corresponding to keypoint and mask centroid , we define
where is the learned squared distance margin, shared across time within the current task stage. This family is used to represent obstacle avoidance, object separation, and task-relevant spatial relations.
Orientation Constraints: We also consider keypoint-pair orientation constraints. For orientation candidate j, corresponding to a keypoint pair and a fixed world-frame unit axis , define and . We then impose
where is the learned axis-alignment threshold, shared across time within the current task stage. Let denote all unknown candidate constraints stacked over time, with parameters collecting the distance and orientation thresholds. We also include known control limit constraints, represented component-wise with known as
Keypoint forward problem. We assume that each demonstration is approximately locally optimal for a constrained optimal control problem in the learned visual state space:
Here, and encode the task-specified start and goal conditions. We use a weighted keypoint-displacement objective in (10), although other task costs can be used. The objective need not fully explain expert intent; it provides a nominal optimality model for inferring constraints. Because keypoints are geometric, penalizing their displacement favors short, low-motion trajectories typical of expert demonstrations.
KKT-based inverse problem. Following KKT-based constraint learning (Sec. III) [13], we search for constraint parameters and multipliers that make the demonstrations approximately satisfy the first-order optimality conditions of (10). For each demonstration , define the Lagrangian of the forward problem as
(11)
where stacks the learned dynamics constraints; the demonstrated boundary values are treated as fixed data and are not relaxed. The KKT conditions are
where we relax the dynamics equality constraints (12a) to account for learned model error. Here bounds the equality-constraint mismatch. The inverse KKT problem thus mirrors (4). Because keypoint tracking error, model error in , and suboptimal demonstrations can make the exact KKT conditions infeasible, we solve a relaxed inverse problem that preserves primal and dual feasibility and minimizes stationarity residuals. Let and denote the admissible constraint- and cost-parameter sets, respectively, and let weight the dynamics-equality slack:
s.t. (12a), (12b), , , .
(13)
Complementarity can be enforced exactly using binary variables and Big-M constraints [13] by framing (13) as a mixed-integer program. The recovered parameters define the learned keypoint constraints, and the associated multipliers indicate which keypoint constraints are active along the demonstrations. For multi-stage tasks, we introduce stage-dependent candidate constraints and parameters. Stage assignments may be specified or jointly inferred with the constraint parameters, as in Sec. V-C. Different geometric relations can therefore explain different task phases. Rather than enumerating subsets of the many candidate distance and orientation relations, KCL jointly infers their parameters and activity through the KKT conditions. It then prunes candidates that are always inactive or insensitive to boundary loosening, retaining explanatory constraints while avoiding unnecessary planning restrictions; details are in [25, App. B]. Sensitivity of KCL. As the learning problem (13) is impacted by keypoint perception and dynamics errors, we derive bounds on the resulting error in the learned distance and orientation thresholds:
Theorem 1 (Learned distance/orientation error bound): Consider the inverse problem (13) on ideal reduced trajectories and perceived approximations , following (5). Assume the constraint parameters are shared across time within the stage under consideration and is known. Suppose the perceived keypoints and centroids satisfy and for all , and define . Let and denote the learned distance-margin and orientation-threshold parameters in (7) and (8), respectively. Assume all orientation-defining keypoint pairs satisfy , and define . Let , , and denote the recovered parameters using, respectively: exact perception and exact dynamics Jacobians; perturbed perception and exact Jacobians at the perceived trajectory; and perturbed perception with learned Jacobians. Assume these three problems share the same reduced active set and that each active geometric parameter remains pinned by the same feature, i.e., , , , and .
Let denote the exact keypoint-space dynamics map, and define , , , and . Suppose the learned Jacobians satisfy for all . Let , with , denote the reduced active-set inverse-KKT system. For the data with perturbed perception and exact Jacobians, define as all data with the same perceived trajectory as and Jacobian perturbations satisfying . Assume that, for every , the reduced KKT system has a locally unique solution with the same active set, that , and that there exist such that and . Finally, let . Then
(14)
A proof is provided in [25, App. A].
C. Planning with Keypoint Dynamics and Constraints
Given the learned dynamics and constraint parameters , we plan new trajectories by solving the forward control problem (10) from a new start condition to a desired goal . Parameterizing the plan as a sequence of reduced states and controls , let be cost weights and let denote the terminal goal cost, e.g., for relevant keypoints. Using IPOPT, we solve to local optimality the following:
(15)
The learned geometric constraints are enforced as hard inequalities, so the nominal model trajectory satisfies the inferred task requirements. We next account for deviations caused by learned-model error during execution.
Since the learned dynamics are imperfect, small one-step prediction errors can accumulate into constraint violations during execution. We therefore robustify (15) using a system-level synthesis (SLS) [26] tube around the nominal keypoint trajectory. Let denote the nominal plan. Linearizing the learned keypoint dynamics around this plan gives the tracking-error dynamics , where , , and where represents bounded keypoint-dynamics error, estimated from held-out one-step prediction residuals following [27]. Let denote the stacked disturbance sequence. SLS parameterizes the closed-loop responses from disturbances to keypoint and control deviations as and , where satisfy the finite-horizon system-level dynamics constraints induced by . For each learned distance constraint indexed by (7), let denote the corresponding keypoint–centroid pair. Define the stacked disturbance set . From and the disturbance sets , we compute the worst-case tube radius (16) for this relative displacement,
TABLE I
FULL NUMERICAL SUMMARY OF KEYPOINT CONSTRAINT LEARNING AND PLANNING RESULTS. “DEMO PTS.” ARE TRAJECTORY POINTS USED FOR INVERSE-KKT CONSTRAINT LEARNING. “VAL NUM.” ARE THE NUMBER OF PLANNING VALIDATION TRIALS. “CLEARANCE ERROR” IS THE ABSOLUTE ERROR IN THE RECOVERED DISTANCE-CLEARANCE RADIUS; FOR TASKS ALSO WITH ORIENTATION CONSTRAINTS, THIS REPORTS THE DISTANCE-CLEARANCE ERROR. “CONST. SAFE RATE” IS SATISFACTION RATE OF THE DEMONSTRATION-INFERRED CONSTRAINT DURING PLANNING, “OBS. SAFE RATE” IS SATISFACTION OF THE GROUND-TRUTH OBSTACLE-SAFETY CHECK, AND “GOAL REACH” IS TERMINAL TASK COMPLETION. VALUES REPORTED AS MEAN STANDARD DEVIATION ARE COMPUTED ACROSS EVALUATION BATCHES.
| Experiment | Setting | Method | Demo pts. | Val num. | Dyn. eval loss | KCL runtime (s) | Final stat. | Clearance err. (m) | Const. Safe rate | obs. safe rate | Goal reach |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Dubins-car obstacle avoidance | |||||||||||
| Dubins | Simulation | KCL | 1640 | 1000 | 0.0028 | 2.3 | 2.09 | 0.011 | |||
| Dubins | Simulation | K-VIL | 1640 | 1000 | N/A | N/A | N/A | N/A | |||
| Dubins | Simulation | MBIRL | 1640 | 1000 | 0.0752 | N/A | N/A | N/A | |||
| Dubins | Simulation | ReKep | 1640 | 1000 | N/A | N/A | N/A | N/A | |||
| Dubins | Real | KCL | 815 | 5 | 0.0038259 | 4.1 | 0.2429 | 0.021 | |||
| KUKA arm manipulation | |||||||||||
| KUKA | Simulation | KCL | 465 | 1000 | 0.002135 | 3.7 | 0.42491 | 0.03 | |||
| KUKA | Simulation | K-VIL | 465 | 1000 | N/A | N/A | N/A | N/A | |||
| KUKA | Simulation | MBIRL | 465 | 1000 | 0.018986 | N/A | N/A | N/A | |||
| KUKA | Simulation | ReKep | 465 | 1000 | N/A | N/A | N/A | N/A | |||
| KUKA | Real | KCL | 1004 | 5 | 0.11283 | 4.9 | 0.89369 | 0.045 | |||
| Rope obstacle avoidance | |||||||||||
| Rope obstacle | Simulation | KCL | 600 | 100 | 0.035998 | 2.5 | 0.51843 | 0.032 | |||
| Rope obstacle | Simulation | MBIRL | 600 | 100 | 0.001144 | N/A | N/A | N/A | |||
| Rope obstacle | Simulation | ReKep | 600 | 100 | N/A | N/A | N/A | N/A | |||
| Rope obstacle | Real | KCL | 1240 | 6 | 0.00932 | 2.5 | 1.533 | 0.029 | |||
| Multi-stage | |||||||||||
| Rope knot tying | Simulation | KCL | 70 | N/A | 0.0047 | 2.3 | 0.0097869 | N/A | N/A | N/A | N/A |
| Cup picking and pouring | Real | KCL | 375 | 5 | 0.002504 | 3.5 | 0.53715 | 0.0201 | |||
| Hammer placing | Real | KCL | 390 | 5 | 0.015228 | 5.4 | 0.58586 | 0.0042 | |||
which can be evaluated in closed-form for SLS [27]:
We then replace the distance constraint in (15) with the tightened robust constraint
Thus, the nominal planned keypoint–centroid distance must exceed the learned clearance by the SLS-predicted tracking-tube radius, serving as a conservative constraint satisfaction margin due to dynamics error. Orientation constraints can be similarly robustified. Thm. 1 is integrated with the SLS tube for robust control in Sec. V-C.
V. EXPERIMENTS
To show that keypoint-mask trajectories can support constraint inference and downstream safe planning, we evaluate KCL on Dubins-car obstacle avoidance, 7-DOF KUKA arm manipulation, deformable rope manipulation and two multi-stage human demonstration tasks in simulation and hardware. We report inverse-learning metrics (KKT stationarity residual, learned-vs-ground-truth constraint error when available, and one-step dynamics loss) and planning metrics (learned-constraint satisfaction, obstacle safety, and goal reaching). We compare KCL against three baselines on the Dubins-car, KUKA and the rope tasks. K-VIL [9] runs a keypoint-based movement imitation pipeline. ReKep [5] uses a VLM to generate relational keypoint constraint templates for planning. MBIRL [11] learns a keypoint-space objective with unconstrained inverse RL and plans with learned dynamics, but infers no hard inequality constraints, testing whether soft objectives alone reproduce safe behavior. All baselines use identical demonstration splits, keypoint trajectories, and evaluation task conditions. Unless otherwise stated, we hold fixed and known; exceptions are for the rope and the Dubins objective-misspecification ablation, where cost parameters are jointly learned with the constraints. For rope manipulation, we do not report K-VIL because it targets rigid-body navigation/manipulation and does not support deformable-object constraint parameterizations. The numerical results for all experiments and baselines are shown in Table I. More results, including a comparison with [13], learning non-convex constraints with KCL, and more figures are in [25, App. C].
A. Dubins-Car Visual Obstacle Avoidance
We evaluate KCL on an obstacle-avoidance task (Fig. 2) in PyBullet simulation and on a real TurtleBot, using vehicle keypoints and obstacle-mask centroid . The learned constraint enforces ground-plane clearance: , where is the learned squared distance margin. KCL achieves perfect constraint satisfaction, obstacle safety, and goal reaching in both settings (Table I, Fig. 2). All baselines also reach the goal, but they do not reliably satisfy the demonstration-inferred clearance: K-VIL, ReKep, and MBIRL achieve , , and learned-constraint satisfaction, with corresponding obstacle-safe rates of , , and . Constraint learning takes 2.3 s in simulation and 4.1 s on hardware. To test robustness to objective mis-specification, we replace the fixed displacement cost with an unknown cost mixture , jointly optimizing the weights and constraint parameters. With squared keypoint displacement (the default in (10)), goal error , and path length as candidates, solving (13) yields , , and , with constraint error 0.012. Thus, KCL can recover the constraints and identify squared keypoint displacement as the dominant objective without assuming known weights.
B. KUKA Manipulation
We next evaluate KCL on a KUKA manipulation task (Fig. 3), where the demonstrator transports a cup to a target

Fig. 2. Dubins-car task: (a) Simulated demo and (b) plan (green trajectory is plan from KCL). (c) Rollouts of plans computed via baselines and KCL (only KCL achieves 100% satisfaction of both the demonstration-inferred clearance and the ground-truth obstacle-safety check; see Tab. I). (d) Real demo and (e) planning (red circle is constraint learned by KCL).

Fig. 3. KUKA manipulation: Simulated (a) demo and (b) plan. Hardware (c) demo and (d) plan. In (b), (d), learned constraint (red circle) is overlaid with the true obstacle. In (b), the green trajectory is the planned motion of the bottom mug keypoint, which satisfies the learned obstacle constraint. The mug also satisfies the learned tilting threshold over the full trajectory.
while avoiding an obstacle and keeping the cup within a 30° tilt bound, extending KCL to 3D motion and orientation constraints. Obstacle avoidance uses distance constraints (7) with learned margin ; cup orientation uses alignment constraint (8) on a cup keypoint pair along world-frame vertical axis , with learned threshold . KCL achieves perfect constraint satisfaction, obstacle safety, and goal reaching in simulation and hardware (Table I, Fig. 3), while K-VIL, ReKep, and MBIRL achieve only 63.5%, 64.9%, and 0.3% constraint satisfaction and 97.1%, 97.7%, and 2.1% obstacle safety, respectively. Constraint learning takes 3.7 s in simulation and 4.9 s on hardware.
C. Deformable Object Manipulation
We evaluate KCL on deformable-object tasks. We consider rope obstacle avoidance in MuJoCo and real-world KUKA demonstrations, and rope knot tying in Drake/Filament with a multi-stage constraint representation [28].
Rope Obstacle. In the rope obstacle-avoidance task (Fig. 4), two arms move rope endpoints past a fixed obstacle; since straight-line pulling would snag the rope, successful demonstrations form a wider V-shape, requiring the learned constraints to act on intermediate keypoints rather than endpoints alone. Per-keypoint clearance constraints

Fig. 4. Rope obstacle avoidance: Simulated (a) demo and (b) plan computed by KCL. Hardware (c) demo and (d) plan computed by KCL. In (b), (d), learned constraint (light red circle) is overlaid with the ground-truth obstacle.
let (13) identify which rope segments actively avoid the obstacle. We also learn the cost parameters : with and ground-truth uniform weights , KCL recovers for all . Because inverse-optimal cost weights are identifiable only up to a common positive scale, normalizing the recovered vector yields the ground-truth uniform weighting. Planning with KCL achieves obstacle-safe goal reaching for simulated and real-world trajectories (Table I, Fig. 4), reproducing the outward-pulling behavior. Learning takes 2.5 s.
To show how Thm. 1 informs downstream robust planning, we apply its uncertainty-margin construction to the rope task. We added bounded observation perturbations of mm to the rope keypoints and obstacle-mask centroid and re-ran KCL on the perturbed demonstration. The recovered squared clearance changed from for the unperturbed data to after perturbation. For this single retained distance constraint, the perception component of Thm. 1 gives . We also include the learned-dynamics term in Thm. 1, . Because the exact rope dynamics Jacobians and local inverse-KKT sensitivity constants are unavailable, we use illustrative design values , , and to demonstrate the construction, where represents a local learned-dynamics Jacobian error budget. With these design values, this gives and hence the total illustrative Thm. 1 margin . We therefore inflate the learned constraint according to , increasing the required clearance from to .
Theorem 1 inflates the recovered constraint to account for keypoint/mask-centroid perception error and learned-dynamics Jacobian error. Let denote the retained rope clearance constraint and define using (16). Separately, this SLS tube, computed from dynamics prediction error, captures accumulated rollout uncertainty during planning. The robust constraint is . Thus, this experiment illustrates how the planner can combine margins for perception error, constraint-recovery dynamics error, and downstream rollout uncertainty.
Rope Knot Tying. We evaluate KCL on rope knot tying in Drake/Filament simulation [28] (Fig. 6). The task contains distinct phases—loop formation, endpoint threading, and tightening—with changing constraint structure, making
Stage 1: Approach
Expert
Stage 2: Pour

Stage 3: Depart
Stage 1: Approach | learned boundary: t = 0-41
Stage 2: Pour | learned boundary: t = 42-99
Stage 3: Depart | learned boundary: t = 100-124
Plan
Fig. 5. (a) Keypoint constraints learned from a video of a human lifting, pouring, and placing a mug, where low-level constraints between objects are learned together with the task segmentation (Stages 1-3). We also have occlusions in the demonstration. (b) KCL plans a safe trajectory using the constraints.
a single constraint insufficient. KCL instead jointly recovers latent geometric constraints, latent semantic phase boundaries, and KKT-consistent explanations of expert behavior, without assuming phase boundaries are known a priori. The rope is represented by five keypoints: left endpoint , right endpoint , and three interior loop-forming keypoints , , , with loop centroid and demonstrated final position . We partition the demonstration into three stages with stage-specific constraints. Stage 1 (insertion, ) has no learned inequality. Stage 2 (loop proximity, ) constrains the right endpoint to remain within squared distance of the loop centroid: . Stage 3 (final pull, ) constrains the right endpoint to remain near via threshold . The learned thresholds admit direct geometric interpretations as radii: and .
Crucially, stage boundaries , are co-solved with constraint parameters , in the MILP using binary phase indicators and Big-M encoding, rather than specified a priori. Figure 6 shows that solving (13) recovers these quantities near the ground truth, jointly identifying what constraints define knot-tying and when they are active while satisfying local KKT optimality. Constraint learning takes 2.3 s. KCL can also select among candidate stage sequences rather than assuming a fixed sequence or number of stages. We consider three hypotheses: loop-then-final (ground truth), z-cross-then-final, and final-only. Using one-hot binary variables to encode these alternatives, KCL jointly selects the sequence, stage boundaries, and constraints. It recovers the correct loop-then-final sequence, with stationarity residual versus and for the distractors.
D. Multi-stage Human Manipulation
Additionally, we conduct two multi-stage manipulation experiments using human demonstrations, showing that KCL can learn constraints without robot-generated data (Fig. 1, 5). Since control inputs are not directly available from the human videos, we model the demonstrated motion with a 3D single-integrator and reconstruct the equivalent input sequence. The first pouring experiment has three stages: 1) move the cup above the container; 2) pour into the container; and 3) place the cup on the opposite side. The cup and container are represented by keypoints , and , ,
(A) Learned phase segmentation

(B) Constraint distances over time
(C)
Fig. 6. Knot tying: KCL jointly recovers (a) stage boundaries , (black dashed) and (b) constraint thresholds m (orange solid), m (orange dotted) by solving a single MILP, matching the ground-truth decomposition without manual phase annotation. (c) Multi-stage decomposition of demonstration via learned constraints.
with centroids and . Define as the angle between nonzero vectors and . In Stages 1 and 3, the cup is constrained to remain approximately upright: , . In Stage 2, the cup must remain close to the container in the desk-parallel xy-plane: . An obstacle-avoidance constraint, is also enforced for all three stages. The hammer experiment (Fig. 1) has three stages: 1) move the hammer around an obstacle; 2) rotate its handle toward the shelf; and 3) place it on the shelf. The hammer, obstacle, and shelf are each represented by two keypoints and one centroid. In Stage 1, we impose an obstacle-avoidance constraint: . Stage 2 does not impose an additional learned constraint. Let denote the first time index of Stage 3. In Stage 3, the hammer should maintain the desired orientation while remaining sufficiently close to the shelf: , and . As for knot-tying, stage boundaries are co-solved with the constraint parameters in the MILP. The learned constraints are then used to plan and execute the tasks with a KUKA arm. Across five trials per task with randomized initial poses, all plans satisfy the learned constraints and reach each stage goal. Results are reported in Table I, with demonstrations and plan timelapses in Figs. 1 and 5.
E. Robustness Experiments
Keypoint Dropout Test: A challenge for keypoint-based methods is imperfect tracking: individual keypoints may be lost, and camera occlusion may temporarily hide relevant objects. We test KCL by randomly dropping 50% of observations in the real-world Dubins-car demonstration (Fig. 2d) and occluding a continuous interval in the pouring demonstration (Fig. 5). After reconstructing missing keypoints via PCHIP interpolation [29], the componentwise learned-clearance errors relative to complete trajectories are (0.0000, 0.0093) m and (0.0000, 0.0004) m, respectively, demonstrating robustness to random and continuous dropout.
Keypoint Noise Test: To evaluate robustness to other perception errors, we perform constraint recovery on the Dubins car under increasing Gaussian keypoint noise over 10 random seeds. Here, denotes the per-coordinate noise standard deviation, and the reported RMSE is the error in the recovered clearance distance. As shown in Tab. II, recovery error shows graceful degradation rather than abrupt sensitivity to small perception errors. We also observed no active constraint flipping due to the noise. Solve Time Scaling: KCL uses mixed-integer programming, whose worst-case computational cost can grow exponentially with the number of integer variables. To assess its practical scalability, we measure solve times as the numbers of keypoints (N) and centroids (M) increase. As shown in Table III, mean solve times remain at or below 2.05 s across all tested configurations, includ- ing those with . These results indicate that KCL is scalable over the evaluated range.
TABLE II
CONSTRAINT RECOVERY
NOISE ROBUSTNESS.
| # Trials | Clearance RMSE (m) | |
|---|---|---|
| 0.00 | 10 | |
| 0.01 | 10 | |
| 0.05 | 10 | |
| 0.10 | 10 | |
| 0.15 | 10 | |
| 0.20 | 10 |
TABLE III
SOLVE TIMES (10 TRIALS).
| Task | N | M | Solve time(s) |
|---|---|---|---|
| Nav. | 10 | 5 | 0.56±.01 |
| Nav. | 20 | 10 | 0.75±.00 |
| Nav. | 50 | 50 | 2.05±.05 |
| Rigid | 8 | 4 | 0.07±.00 |
| Rigid | 16 | 8 | 0.11±.00 |
| Rigid | 50 | 50 | 0.37±.04 |
| Rope | 5 | 2 | 0.03±.01 |
| Rope | 10 | 4 | 0.04±.00 |
| Rope | 50 | 50 | 1.23±.01 |
| Knot | 5 | 1 | 0.10±.00 |
| Knot | 10 | 1 | 0.21±.00 |
| Knot | 15 | 1 | 0.25±.00 |
VI. CONCLUSION
We present KCL, a framework for learning task-relevant constraints from visual demonstrations for safe planning. KCL extracts keypoints and mask centroids from RGB-D demonstrations, learns keypoint-space dynamics, and infers geometric constraints via approximate KKT optimality in the reduced visual state space. The learned constraints are interpretable, directly enforceable during planning, and robustified using margins from dynamics error. Across navigation, rigid manipulation, and deformable manipulation tasks, KCL recovers meaningful constraints and produces safe goal-reaching plans in simulation and hardware. These results show that sparse visual keypoints can make constrained inverse optimal control practical for visuomotor control.
REFERENCES
[1] G. Chou, H. Wang, and D. Berenson, “Gaussian Process Constraint Learning for Scalable Chance-Constrained Motion Planning From Demonstrations,” IEEE RA-L, vol. 7, no. 2, 2022.
[2] L. Manuelli, W. Gao, P. Florence, and R. Tedrake, “kpam: Keypoint affordances for category-level robotic manipulation,” in ISRR, 2019.
[3] T. D. Kulkarni, A. Gupta, C. Ionescu, S. Borgeaud, M. Reynolds, A. Zisserman, and V. Mnih, “Unsupervised learning of object keypoints for perception and control,” NeurIPS, 2019.
[4] T. Lips, V.-L. De Gusseme, and F. Wyffels, “Learning keypoints for robotic cloth manipulation using synthetic data,” RA-L, 2024.
[5] W. Huang, C. Wang, Y. Li, R. Zhang, and L. Fei-Fei, “Rekep: Spatio-temporal reasoning of relational keypoint constraints for robotic manipulation,” arXiv preprint arXiv:2409.01652, 2024.
[6] N. Kumar, W. Shen, F. Ramos, D. Fox, T. Lozano-Pérez, L. P. Kaelbling, and C. R. Garrett, “Open-world task and motion planning via vision-language model generated constraints,” IEEE RA-L, 2026.
[7] M. Pan, J. Zhang, T. Wu, Y. Zhao, W. Gao, and H. Dong, “Omnimanip: Towards general robotic manipulation via object-centric interaction primitives as spatial constraints,” in CVPR, 2025.
[8] J. Lin, Q. Yang, Y. Li, K. Dong, and H. Liu, “Keypoint-aware rag for robotic manipulation: In-context constraint learning via large-scale retrieval,” in IROS, 2025.
[9] J. Gao, Z. Tao, N. Jaquier, and T. Asfour, “K-vil: Keypoints-based visual imitation learning,” IEEE T-RO, 2023.
[10] K. Lin, V. Ragunath, A. McAlinden, A. Prasad, J. Wu, Y. Zhu, and J. Bohg, “Constraint-preserving data generation for visuomotor policy learning,” arXiv preprint arXiv:2508.03944, 2025.
[11] N. Das, S. Bechtle, T. Davchev, D. Jayaraman, A. Rai, and F. Meier, "Model based inverse reinforcement learning from visual demonstration," in Conference on Robot Learning (CoRL), 2020.
[12] P. Englert, N. Vien, and M. Toussaint, “Inverse KKT: Learning Cost Functions of Manipulation Tasks from Demonstrations,” IJRR, 2017.
[13] G. Chou, N. Ozay, and D. Berenson, “Learning Constraints From Locally-Optimal Demonstrations Under Cost Function Uncertainty,” IEEE Robotics and Automation Letters (RA-L), vol. 5, no. 2, 2020.
[14] ——, “Learning Parametric Constraints in High Dimensions from Demonstrations,” in CoRL, 2019.
[15] ——, “Uncertainty-Aware Constraint Learning for Adaptive Safe Motion Planning from Demonstrations,” in CoRL, 2020.
[16] G. Chou, D. Berenson, and N. Ozay, “Learning Constraints from Demonstrations,” WAFR, 2018.
[17] C. Pérez-D'Arpino and J. A. Shah, "C-LEARN: Learning Geometric Constraints from Demonstrations for Multi-Step Manipulation in Shared Autonomy," in ICRA, 2017.
[18] Y. Liu, F. Zha, L. Sun, J. Li, M. Li, and X. Wang, “Learning articulated constraints from a one-shot demonstration for robot manipulation planning,” IEEE Access, vol. 7, pp. 172584–172596, 2019.
[19] S. Malik, U. Anwar, A. Aghasi, and A. Ahmed, “Inverse Constrained Reinforcement Learning,” in ICML, 2021.
[20] J. Jang, M. Song, and D. Park, “Inverse Constraint Learning and Generalization by Transferable Reward Decomposition,” RA-L, 2023.
[21] S. Boyd and L. Vandenberghe, Convex optimization, 2004.
[22] A. Kirillov, E. Mintun, N. Ravi, H. Mao, C. Rolland, L. Gustafson, T. Xiao et al., “Segment anything,” in ICCV, 2023.
[23] M. Oquab, T. Darcet, T. Moutakanni, H. Vo, M. Szafraniec, V. Khalidov, P. Fernandez, D. Haziza et al., “Dinov2: Learning robust visual features without supervision,” arXiv preprint arXiv:2304.07193, 2023.
[24] S. Jung, A. Zholus, M. Sundermeyer, C. Doersch, R. Goroshin, D. J. Tan, S. Chandar, R. Triebel, and F. Tombari, “Tapnext++: What’s next for tracking any point (tap)?” arXiv preprint arXiv:2604.10582, 2026.
[25] “Learning keypoint constraints from visual demonstrations for safe motion planning,” https://tinyurl.com/3uun6whk, 2026.
[26] J. Anderson, J. C. Doyle, S. H. Low, and N. Matni, “System level synthesis,” Annual Reviews in Control, vol. 47, pp. 364–393, 2019.
[27] A. Srinivasan, A. Leeman, and G. Chou, “Safety beyond the training data: Robust out-of-distribution mpc via conformalized system level synthesis,” arXiv preprint arXiv:2602.12047, 2026.
[28] R. Tedrake and the Drake Development Team, “Drake: Model-based design and verification for robotics,” 2019.
[29] G. Birkhoff, M. H. Schultz, and R. S. Varga, “Piecewise hermite interpolation in one and two variables with applications to partial differential equations,” Numer. math, vol. 11, no. 3, pp. 232–256, 1968.
APPENDIX
APPENDIX I
PROOFS
For convenience, we restate Theorem 1 before the proof. Theorem 1 (restated).
Consider the inverse problem (13) on ideal reduced trajectories and perceived approximations , following (5). Assume the constraint parameters are shared across time within the stage under consideration and is known. Suppose the perceived keypoints and centroids satisfy and for all , and define . Let and denote the learned distance-margin and orientation-threshold parameters in (7) and (8), respectively. Assume all orientation-defining keypoint pairs satisfy , and define .
Let , , and denote the recovered parameters using, respectively: exact perception and exact dynamics Jacobians; perturbed perception and exact Jacobians at the perceived trajectory; and perturbed perception with learned Jacobians. Assume these three problems share the same reduced active set and that each active geometric parameter remains pinned by the same feature, i.e., , , , and .
Let denote the exact keypoint-space dynamics map, and define , , , and . Suppose the learned Jacobians satisfy for all . Let , with , denote the reduced active-set inverse-KKT system. For the data with perturbed perception and exact Jacobians, define as all data with the same perceived trajectory as and Jacobian perturbations satisfying . Assume that, for every , the reduced KKT system has a locally unique solution with the same active set, that , and that there exist such that and . Finally, let . Then
Proof: We first bound the perception-induced error in the active distance features. For any active keypoint–centroid pair, let and . By the reverse triangle inequality,
Therefore
Since each distance parameter is pinned by the same active feature before and after perception perturbation,
Thus
Next, consider an active orientation feature. Let and . Then . Along the segment , , we have . For
a direct calculation gives
Hence, by the mean value theorem,
Since each orientation threshold is pinned by the same active feature,
It remains to bound the additional effect of using learned dynamics Jacobians. For the learned-Jacobian data , define
By the assumed local KKT sensitivity,
The dynamics contribution to stationarity contains blocks and . Replacing with therefore perturbs the stacked stationarity residual by at most
where the last inequality follows from . Thus
The claimed bounds follow by the triangle inequality:
and
APPENDIX II CONSTRAINT PRUNING
The inverse problem (13) is formulated over distance candidates , and orientation candidates , which can be numerous when and are large. After solving, most candidates are inactive: their Lagrange multipliers are zero and the complementary-slackness binaries and [13] remain zero across all demonstrations and timesteps . To simplify downstream planning, we retain a distance candidate (or orientation candidate ) only if (respectively, ) for at least one , indicating that the constraint is tight along at least one demonstrated trajectory.
A binary being active in the MILP solution does not by itself certify that the corresponding constraint is physically meaningful — it may arise from numerical degeneracy or be trivially satisfied everywhere. We therefore apply a sensitivity check to each retained candidate. For a candidate with learned parameter , we re-solve the relaxed MILP (13) after perturbing that parameter by a small in the constraint-loosening direction. For the distance and orientation parameterizations in (7)–(8), this corresponds to imposing or , respectively. We record the resulting change in stationarity residual . A large increase ( ) indicates that the candidate is required to explain the demonstration's local optimality (see [13]); if , it contributes negligibly and is discarded. The most representative candidates that pass both the activity and sensitivity checks are retained for downstream planning.
APPENDIX III ADDITIONAL RESULTS
Ground-truth CIOC baseline. To provide a hard-constraint CIOC upper bound while retaining the visual representation used by KCL, we rendered an optimal Dubins-car demonstration and extracted keypoints using the same visual keypoint extraction pipeline. We retain the exact analytic Dubins dynamics and assume that the tracked robot keypoints are rigidly attached to the

Fig. 7. Ground-truth CIOC demonstration.
vehicle. The relaxed CIOC solve recovers a clearance of m from the ground-truth m, corresponding to an absolute error of m (2.66%). The total relaxed stationarity residual is . This result shows that a hard-constrained CIOC formulation with exact dynamics still recovers the constraint accurately when operating on visually extracted keypoints.
Nonconvex Constraints. While built for distance/orientation constraints, KCL can learn nonconvex safe or unsafe sets, e.g., we learn a red non-convex unsafe set to approximate the union of two true circle obstacles. Given one locally-optimal demo avoiding the circles under Dubins dynamics, KCL learns the parameters m with false-

Fig. 8. Peanut constraint with Dubins car dynamics.
positive and false-negative rates of 1.11% and 0.20%, respectively, relative to the true constraint evaluated over . Similarly, if the true constraint

Fig. 9. Manipulation baseline comparison. Planning results. For navigation and manipulation planning, blue trajectories satisfy the demonstration-inferred clearance constraint, yellow trajectories avoid the ground-truth obstacle but violate the demonstration-inferred clearance, and dashed orange trajectories collide with the ground-truth obstacle. (a) Navigation baseline comparison. (b) Manipulation baseline comparison.

Fig. 10. Rope planning with the learned keypoint constraint. Three trajectories denote rope keypoint trajectories; the light-blue tube is the SLS safety tube around the constrained keypoint.
were g and its parameterization unknown to the learner, KCL could instead learn it approximately as a union of two circular distance constraints.
A. Baselines and Planning
The baseline comparison and rope-planning visualization are shown in Figs. 9 and 10, respectively. The curves in the navigation and manipulation panels show the centroid trajectory of the manipulated object for visualization clarity. Therefore, some trajectories that appear visually separated from the obstacle can still be unsafe: one or more object keypoints may enter the obstacle box or the demonstration constraint even when the centroid remains outside. In the rope planning real panel, the light-blue tube around the constrained rope keypoint is the SLS safety tube, which bounds the possible tracking deviation induced by accumulated keypoint-dynamics error. The gray wireframe sphere is the tightened constraint, obtained by enlarging the nominal clearance radius by the SLS tube radius. Hence, satisfying the tightened constraint means that the nominal plan leaves enough margin so that the disturbed closed-loop trajectory remains outside the original demonstration-followed constraint under the calibrated dynamics-error bound.