Why does joint PID tracking in a Simscape Multibody leg model degrade when Spatial Contact Force is enabled, while it works well without ground contact (XZ plane)?
- I provide reference joint trajectories for hip/knee/ankle from a gait dataset (10 concatenated gait cycles) using three timeseries signals:
- hip_ts, knee_ts, ankle_ts
- Each joint is controlled by a joint-level PID/PD block that outputs a torque
- The measured joint angles q are taken from the joint sensors and fed back to the controller (scopes show reference vs simulated for each joint).
- large tracking errors / oscillations appear
- the behavior looks unstable or heavily disturbed during stance/contact phases
- the same PID gains that work without contact no longer work
- Is this mainly due to the contact model parameters (stiffness, damping, friction) creating stiff dynamics that destabilize the joint PID?
- Could the issue be caused by unintended extra DOFs at the hip/base (e.g., the hip not fully constrained in the plane), so contact forces introduce out-of-plane motion or additional dynamics?
- Is it conceptually wrong to expect simple joint PID tracking to work well when contact forces are present, and should I instead use:
- impedance control at the joints,
- inverse dynamics / computed torque,
- or a constraint-based approach for stance?
- Screenshot of the Simulink/Simscape model (joint controllers + Spatial Contact Force block)
- Scope screenshots showing reference vs actual joint angles for hip/knee/ankle
- Contact block settings (stiffness/damping/friction) and solver settings if needed
Accepted Answer
More Answers (1)
0 votes
1 Comment
Thanks for the video. Based on the behavior, there are three main areas to investigate:
1. Solver Settings (Most Likely Cause)
If you are using a Fixed-Step Solver, this is likely the culprit. Contact is a discrete event. The Physics: At time step n-1, there is no contact. At time step n, the foot might have penetrated 2mm into the ground. The Result: This sudden penetration creates a massive force spike because the solver missed the exact moment of impact. The object tries to accelerate away instantly, but your PID controller fights it, causing oscillations. Recommendation: Switch to a Variable-Step Solver (like ode15s or ode23t). These solvers automatically reduce the time step to catch the exact moment of contact.
2. Friction & Horizontal Movement
The instability might be coming from horizontal "sticking" rather than just vertical impact. If the foot hits the ground with any forward velocity and friction is active, it creates a horizontal shock.
Test A: Set the contact Friction to 0. If the simulation becomes stable, the issue is the horizontal impact forces.
Test B: Mount the floor on a Planar Joint (allowing X/Y movement). This allows the floor to "slide away" upon impact, reducing the shock while letting you keep friction enabled to test traction.
3. Mass & Inertia Checks
Check the rigid body transforms and inertia parameters imported from your CAD geometry. Ensure the mass and inertia are not zero or unrealistically small. If inertia is too low, the calculated accelerations from contact forces will be huge, leading to instability.
4. Troubleshooting Strategy:
Isolate the Problem
You are tuning PID gains, contact stiffness, and solver settings while the robot is trying to walk. This is too difficult.
Try this process:
Stand Still First: Change your reference signals to keep the joints stationary.
Tune Contact: Tune parameters until the "standing" phase is stable. Start Walking: Only once static contact is stable, apply the gait trajectory.
Use an Operating Point: Look into using a Simscape Operating Point to start the simulation from a steady state (already balanced) rather than dropping it at t=0.
Categories
Find more on Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!