Coriolis Matrix of a 14 DOF bipedal robot won't compile its matlab function
채택된 답변
Hi @Giovanni Maria,
After spending several hours researching MATLAB documentation and robotics literature online, I believe I've identified the root cause of your CC_MORM export failure and can offer some practical solutions that don't require additional toolboxes.
Your issue isn't a coding error - it's computational complexity. For your 14-DOF system with quaternion constraints, the symbolic Coriolis computation involves 4,352 operations on complex trigonometric expressions, causing memory bottlenecks that prevent matlabFunction from completing the export. So, my recommendations would be:
Option 1 - Enable Optimization: Change your Coriolis export line to:
matlabFunction(CC, 'Vars', vars_pack, 'File', 'CC_MORM', 'Optimize', true);
You currently have 'Optimize', false which makes the expressions much larger.
Option 2 - Simplify Before Export: Add simplification before creating the function:
CC_simplified = simplify(CC, 'Steps', 100); matlabFunction(CC_simplified, 'Vars', vars_pack, 'File', 'CC_MORM', 'Optimize', true);
Option 3 - Memory Management: Add between your derivative calculations:
clear dM; pack;
Option 4 - Numerical Coriolis at Runtime: Keep your symbolic M and G (which already work), but compute Coriolis numerically in your Simulink function block for the full dynamic equation M(q)q_ddot + C(q,q_dot)q_dot + G(q) = tau.
Now, as a quick test, temporarily reduce your system to 8-10 DOF to verify the approach works, then implement one of the above optimizations for the full system.
Based on my research, this complexity issue is well-documented for multi-DOF systems. The symbolic expressions become exponentially complex, which is exactly what you're experiencing.
References from my research:
- MATLAB Symbolic Math Documentation: https://www.mathworks.com/help/symbolic/
- Robotics dynamics papers consistently recommend numerical methods for systems >10 DOF
댓글 수: 2
Hi @Giovanni Maria,
For a 14-DOF robot, calculating the Coriolis matrix symbolically is too heavy for your PC and will always be slow or fail.
The best approach is to:
1. Compute the Coriolis matrix numerically during runtime instead of generating a symbolic function. 2. Keep the mass and gravity matrices symbolic—they work fine. 3. Optionally, test on a smaller system first to make sure your method works.
More RAM might help, but numerical computation is the practical solution.
추가 답변 (0개)
참고 항목
카테고리
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!