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)?

22 views (last 30 days)
I am simulating a simplified lower-limb / prosthetic leg in Simscape Multibody with 3 revolute joints (hip, knee, ankle). The motion is intended to be planar in the sagittal plane (XZ).What I am doing
  • 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).
What works (no contact)
If I disable ground contact, the joint tracking is reasonably good for all joints (hip/knee/ankle). The simulated angles follow the reference signals with small error.
The problem (with contact enabled)
When I enable foot–ground contact using Spatial Contact Force (foot geometry vs ground plane), the tracking becomes much worse:
  • 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
What I suspect / questions
I am trying to understand what is causing this degradation when contact is enabled:
  1. Is this mainly due to the contact model parameters (stiffness, damping, friction) creating stiff dynamics that destabilize the joint PID?
  2. 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?
  3. 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?
What I can provide
  • 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
Question: What are the most common reasons why enabling Spatial Contact Force makes joint-level PID tracking degrade dramatically in Simscape Multibody, and what specific checks/changes would you recommend (contact parameters, solver, constraints/DOFs at hip/base, control structure)?

Answers (1)

Jan Janse van Rensburg
Jan Janse van Rensburg 3 minutes ago
The Core Problem: Over-Constraint
The fundamental issue is that your model is mechanically over-constrained.
You are likely fixing the Hip frame in space (making it immovable). When the foot hits the ground, you create a closed kinematic chain. Since the hip cannot move up, the PID controllers force the leg to try and penetrate the ground to satisfy the recorded joint angles.
This creates a conflict: The ground won't move, the hip won't move, but the angles must change. The result is massive force fighting and instability.
Solutions
To fix this, you need to introduce compliance (movement) into the system.
1. The Quick Fix (Compliant Ground)
  • Allow the Ground to move instead of the leg.
  • Place a Cartesian Joint between the World frame and the Ground.
  • Add high stiffness/damping (spring-damper) in the Z-direction of that joint.
  • Result: The ground "gives way" slightly when the foot pushes down, preventing the infinite force spike.
2. The Better Approach (Vertical Hip Motion)
  • Allow the Leg/Hip to move vertically.
  • Add a Prismatic Joint (Z-axis) between the World frame and the Hip.
  • Add a mass to the Hip (e.g., half the wearer's body mass) to represent the upper body inertia.
  • Result: When the foot pushes the ground, the hip is lifted up naturally, mimicking real walking physics.
3. The "Correct" Approach (Full Simulation)
  • Model the entire system as a virtual test dummy with 6-DOF at the pelvis.
  • This allows the body to translate and rotate freely in response to the leg forces, exactly like a human.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!