Contact dynamics is a crucial aspect of robotics and physics simulations, especially when dealing with the sudden change of dynamic variables during contact events. This section delves into the methods to handle such dynamics.
There are primarily two methods to address contact dynamics:
-
Hybrid Formulation 🔄:
- Procedure:
- Integrate the system.
- Check the guard function.
- Apply jump mapping when contact occurs.
- Continue integration.
- Advantages 🌟:
- Easy to implement using standard algorithms.
- Just requires adding additional constraints or optimization variables during contact.
- Highly successful in locomotion scenarios.
- Disadvantages 🚫:
- Requires a pre-specified contact mode sequence, i.e., which part of the robot is in contact at each time step.
- Can be problematic in contact-rich scenarios.
- Procedure:
-
Time-Stepping Method / Contact-Implicit Formulation ⏰:
- Procedure: Formulate contact as constraints and solve a constrained optimization problem at each timestep.
- Advantages 🌟:
- No need for a pre-specified contact sequence.
- Disadvantages 🚫:
- The optimization process becomes significantly more challenging.
Let's understand these methods better with an example:
-
Time-Stepping Method:
- Question: Where is the ground damping ratio?
- Formulation: $$ \begin{align*} \phi(q) & = [0 ; 1] [q_x ; q_y]^T ; \text{(mapping position to distance to the ground)} \ m\left(\frac{v_{k+1}-v_k}{h}\right) & =-mg+J^T\lambda_k \ p_{k+1} & = p_k+hv_{k+1} ; \text{(backward Euler)} \ \phi(q_{k+1}) & > 0 ; \to ; p[1] > 0 \ \lambda_k & \geq 0 ; \text{(contact force)} \ \phi(q_{k+1})\lambda_k & = 0 ; \text{(force only when hitting the ground)} \end{align*} $$
- Converted QP Problem:
- Question: Why is this a QP problem? (Is it due to KKT conditions?) $$ \begin{align*} \min_{V_{k+1}} \ &0.5mV_{k+1}^TV_{k+1}+mV_{k+1}^T(hg-V_k) \ s.t.\ \ \ &J(p_k+hV_{k+1})=0 \end{align*} $$
- Limitations:
- Exact impact time isn't determined.
- Contact forces are explicitly computed.
- Doesn't generalize to higher-order integration (e.g., RK-4), necessitating smaller steps.
- Complementary conditions (boundary constraints) aren't smooth.
- Widely used in platforms like PyBullet, DART, Gazebo, etc.
-
Hybrid Method:
- Formulation: $$ \begin{align*} \text{Smooth vector field: } & [\dot{q} ; \dot{v}]^T = [v ; -g ]^T \ \text{Guard function: } & \phi(x) \ge 0 \ \text{Jump map: } & x' = g(x) = [q_x ; q_y ; v_x ; 0] ^T \end{align*} $$
- Algorithm:
while t < t_final: if phi(x) ≥ 0: x_dot = f(x) else if phi = 0: # Sometimes backtracking is needed to find the exact time x’ = g(x) end
- Advantages:
- Determines the exact impact time.
- Can utilize high-accuracy integrators.
- Disadvantages:
- Doesn't calculate the contact force.
- Widely used in tools like TrajOpt/MPC.
- Insight: If we know the impact time in advance, we can optimize each non-constrained trajectory separately.
Both methods, despite their pros and cons, are widely used in the field of robotics and control systems.
The state vector, ( x ), represents various parameters of the legged system:
The control vector, ( u ), is used to influence the state of the system:
The jump map, ( x' ), describes the transition of the system:
By pre-specifying the contact time step, we can optimize the trajectory accordingly:
To ensure the stability and safety of the legged system, it's essential to consider the frictional forces during trajectory optimization.
The frictional force, ( b ), is constrained by the normal force, ( n ), and the coefficient of friction, ( \mu ):
Where:
- ( n ) is the normal force and ( n \in \mathbb{R}_+ )
- ( b ) is the friction force and ( b \in \mathbb{R}^2 )
Since the base of the friction cone is non-differentiable, we often linearize the constraints, leading to the concept of a friction pyramid:
With the additional constraints: $$ d \geq 0 $$
And: $$ b = [I \ -I]d $$
- If slipping is desired, an additional mode should be introduced.
- The friction pyramid is a coarse approximation and might not capture all the nuances of real-world frictional interactions.