Contact-implicit Trajectory optimization using Anitescu's contact model
Pang
Collaborating with Naveen
- Task: planning/control of moving a heavy object with a bi-manual torque-limited robot.
- The trajectory should involve lots of contact mode changes.
- Proposed solution: contact-implicit trajectory optimization.
Trajectory optimization as bi-level optimization.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8217284/pasted-from-clipboard.png)
- With quasistatic model:
Dynamics
Integration
- General form (taken from Benoit's paper):
Dynamics
Integration
Joint limits, etc.
lower variables
upper variables
lower problem
Mix and match...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8217284/pasted-from-clipboard.png)
Dynamics
Integration
Joint limits, etc.
-
[Posa14]
- include the KKT conditions of the lower problem as constraints in the upper problem.
-
[Landry19b]
- treat the lower problem as a function,
- compute its gradient at optimality using KKT conditions + implicit function theorem.
- [Landry19a]
- convert the lower problem into a constraint-free one using augmented Lagrangian,
- treat the constraint-free problem as a function,
- compute its gradient using AutoDiff.
- [Me over the last couple of weeks]
- convert the lower problem into a constraint-free one using log barrier,
- include the KKT conditions of the constraint-free problem as constraints in the upper problem.
lower variables
upper variables
lower problem
- [Landry19a] Landry, Benoit, Zachary Manchester, and Marco Pavone. "A differentiable augmented lagrangian method for bilevel nonlinear optimization." arXiv preprint arXiv:1902.03319(2019).
- [Landry19b] Landry, Benoit, et al. "Bilevel Optimization for Planning through Contact: A Semidirect Method." arXiv preprint arXiv:1906.04292 (2019).
- [Posa14] Posa, Michael, Cecilia Cantu, and Russ Tedrake. "A direct method for trajectory optimization of rigid bodies through contact." The International Journal of Robotics Research 33.1 (2014): 69-81.
Solve with SNOPT.
To answer the questions from last time...
- [Landry19a] has numerical examples on collision-free motion planning.
- [Landry19b] has examples on locomotion (hopper + quadrupeds).
- Scott Kuindersma and Zachary Manchester also have a series of papers on using augmented Lagrangian to solve DDP with constraints.
- All numerical examples are collision-free motion planning (no contacts).
- Marco Hutter has papers on iLQR with contact, which usually involve some sort of barrier function to make the dynamics constraint-free.
- Surprisingly, there's not much on (trajectory optimization + manipulation) in recent literature.
-
Hongkai didn't get much success applying Michael's contact-implicit trajectory optimization to manipulation.
- Specifically, the optimizer needs lots of tuning (e.g. constraining objects to be close to some support surface) to converge to reasonable solutions.
- Maybe this more global perspective provided by humans can be automated with Tobia's method?
-
Hongkai didn't get much success applying Michael's contact-implicit trajectory optimization to manipulation.
- So the only way to find out if the newer approaches are good for manipulation is to try them?
Even more moving pieces...
- Our new model does not have to be completely quasistatic.
- The current formulation can accommodate 2nd order dynamics of un-actuated objects.
- Solves the problem of infeasibility when objects are "dropped".
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8217674/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8217817/pasted-from-clipboard.png)
QP
KKT
Outline
- Objective: contact-rich planning using our new quasistatic model.
contact index.
extreme ray index.
- Proposed solution: formulate the planning problem as trajectory optimization.
- A simple numerical example.
- Nonlinear solvers need to be carefully initialized to achieve convergence.
Output feedback using dense tactile sensors...
A simpler experiment with tactile sensors.
- 2 fingers manipulating a sphere in 2D.
- fingers consist of spheres too.
- Put 4 depth cameras in the sphere.
- so that depth images can be directly mapped to contact forces in body frame.
- Concatenate average penetration from all cameras along the perimeter of the sphere, and call the resulting vector a "feature".
- Simulate the system forward from random initial configurations to random final configurations, collect a bunch (10000) feature vectors.
- Cluster the features, with the hope that the Vonoroi regions of the cluster centers could serve as an alternative to contact modes. (inspired by loop closure in SLAM, where SIFT/other features are clustered to generate "visual words").
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8192029/pasted-from-clipboard.png)
Goal...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8192032/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8192050/pasted-from-clipboard.png)
1
2
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8192055/pasted-from-clipboard.png)
3
Rough idea...
- Treating the Voronoi regions as nodes in a graph...
- Each Voronoi region corresponds to a cone in the sphere's wrench space.
- A force program on the sphere should correspond to a path through the nodes.
- Offline, we could try to connect random pairs of nodes using trajectory optimization.
- The graph needs to be augmented with additional data structures that store object/robot configurations, or other information that facilitates planning.
- Online, the graph can be used for output-based feedback control and planning.
Common form of multi-body systems with Anitescu's contact constrains.
- Rigid body dynamics with contacts using Anitescu's formulation has the following form:
Second order (from Russ's textbook):
Quasistatic.
quadratic, convex.
contact index.
extreme ray index.
Expressing optimality conditions as equality constraints.
Quasistatic: force balance.
- We can put the constraints into the objective using the log barrier function:
- This transforms the original problem into the unconstrained minimization of a convex function. So the necessary and sufficient condition for optimality is that (1) the gradient equals 0, (2) the original problem is strictly feasible:
log barrier weight.
- Derivative of the log barrier can be interpreted as contact forces.
2nd order: Newton's 2nd law.
Contact forces
includes torque generated by \(u\).
Trajectory optimization.
- General form:
- Quasistatic:
- To solve, start with a small \(w\) and increase it (e.g. by a factor of 10) until a desired tolerance is reached.
- seems optional if starting from a strictly feasible trajectory.
- doesn't help with convergence if the solver is not properly initialized (UnkownError).
includes torque generated by \(u\).
Mechanical interpretation of log barrier.
Quasistatic.
2nd order.
Contact impulse:
- direction is orthogonal to \( \phi_i + h J_{ij} v' = 0 \),
- magnitude is inversely proportional to the distance to \( \phi_i + h J_{ij} v' = 0 \).
- As \(w\) is increased, the "force at a distance" effect is reduced.
- After the final iteration, magnitude of contact impulses can be calculated from \[\beta_{ij}^* = \frac{1}{w} \frac{h}{\phi_i + h J_{ij} v'^*}.\]
Michael's contact-implicit trajectory optimization paper uses a similar "force at a distance" idea to ease numerical difficulties.
Instead of \[0 \leq \phi_i \perp \lambda_{n_i} \geq 0, \]
Michael had \[\phi_i \geq 0, \lambda_{n_i} \geq 0, \phi_i \lambda_{n_i} \leq \epsilon.\]
which puts on contact forces an upper bound inversely proportional to the signed distance.
\(\epsilon\) is also reduced over several solves.
- It seems that the log barrier is doing something similar to what Michael did, but with less decision variables and less constraints? (Although SNOPT might have already seen through that)?
- This is also the only way I can think of to do planning with the quasistatic model.
- Do you think it's worth trying on more complex systems and see how well it scales up?
Contact impulses
Example: initial condition optimization of a point mass in 2D
LCP (Posa)
- A point mass starts at (x, y) = (-3, 2).
- The ground is defined by y = 0. Gravity points downwards. Friction between the point and the floor.
- We'd like to minimize the norm of the initial velocity of the point so it lands close to (0, 0).
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168178/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168179/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168181/pasted-from-clipboard.png)
New formulation
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168185/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168187/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168188/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168838/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168839/pasted-from-clipboard.png)
Peak values are different, but area under the curve (impulses) are almost equal.
Old slides
Discussions
- I was wrong about SNOPT/IPOPT not solving the problem.
- Can add constraints to maintain feasibility: \(\phi_i(q_l) + J_{ij} v_{l+1} \geq \epsilon\) (seems optional if the next condition is met).
- Need to start from a STRICTLY feasible trajectory!
- This trajectory CANNOT be generated using a forward simulation that uses active set method. Active constraint -> division by 0.
- Forward simulation needs to be done using interior point method with a "round" log barrier function (currently written by me).
- I think all the goodness of our quasistatic model, including (1) less variables, (2) using larger time steps and (3) less stiff equations, still holds in trajectory optimization. Now that we know how to solve it with MathematicalProgram, testing it on larger systems shouldn't take too much time. We could try comparing with Michael Posa's examples?
- I think the new formulation also has the following features (not 100% sure if they are advantageous):
- The contact forces are no longer decision variables. They can be recovered from the optimal solution.
- Slack variables for sliding, typical in LCP formulations, are also gone.
- There are no complementarity constraints.
- Has the nice mechanical interpretation of a constraints acting as force fields exerting forces proportional to the inverse distance to the constraints. (Similar to Michael's \(\phi f_n = \epsilon \) trick?)
- This formulation works with our new quasistatic dynamics too.
- More exciting directions. SOS?
- Internship/ part-time work at TRI with Naveen?
- If time permits...
- Better design for QuasistaticSystem. Where should SceneGraph go (outside QuasistaticSystem)?
- Tools for writing down derivatives of functions (in addition to pydrake.autodiffutils.AutoDiffXd)?
- Orcado? (Based on my impression from our last meeting, they seem to get all the help they need from StackOverflow::Drake?)
- Spring registration.
How I got the idea.
- Geilinger, Moritz, et al. "ADD: analytically differentiable dynamics for multi-body systems with frictional contact." ACM Transactions on Graphics (TOG) 39.6 (2020): 1-15.
- Zimmermann, Simon, Roi Poranne, and Stelian Coros. "Optimal control via second order sensitivity analysis." arXiv preprint arXiv:1905.08534 (2019).
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168065/pasted-from-clipboard.png)
- Penalty-based contact model.
- Dynamics can be expressed as equality constraints.
- Solved using the "adjoint method".
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168069/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168075/pasted-from-clipboard.png)
Comparison
- Both methods start from the same initial conditions. Otherwise they could end up at different local minima.
- In our formulation, naively typing in the constraints and objective and ask SNOPT/IPOPT for a solution will crash the solver (division by 0?). Right now solved with gradient descent. (Plot of gradient)
- Forward simulation needs to be done using interior point method with a "round" log barrier function (currently written by me). Otherwise active constraints will cause division by 0.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1354033/images/8168195/pasted-from-clipboard.png)
traj_opt_with_anitescu_contact_model
By Pang
traj_opt_with_anitescu_contact_model
- 29