addCollision not compatible with Matlab Coder when using *.STL File

4 visualizzazioni (ultimi 30 giorni)
Hello, i am trying to compile a code that uses addCollision Function.
The syntax:
Tool_name = 'Tool Effector';
Tool = rigidBody(Tool_name);
addCollision(Tool, 'Mesh', "C:\WorkingFolder\Tool.STL");
When using this function from MATLAB, i get no errors. When trying to compile in Coder , i get this:
??? Cell contents reference from a non-cell array object.
Code generation failed: View Error Report
so i edited CollisionGeometryFactory, instead of:
geometryFile = parameters{1};%If it is a string
i put:
geometryFile = parameters;%If it is a string
Okay, not the error is somewhere else:
??? Function 'which' not supported for code generation.
More information
Error in ==>> CollisionGeometryFactory Line: 96 Column: 40
Code generation failed: View Error Report
So i took that out as well.
But, then i get:
??? Function 'fileparts' not supported for code generation.
More information
Error in ==>> readCADFile Line: 15 Column: 1
Code generation failed: View Error Report
There i decided to stop.
It states that addCollision is compaitble with C\C++ Coder generation. and i could'nt find a comment about an exception when importing a collison from .STL
What am i missing ?
Thank you

Risposta accettata

Ran Shaham
Ran Shaham il 19 Gen 2022
Okay, so i found a workaround for now.
I built the rigidBodyTree in regular MATLAB, then i used:
robot.writeAsFunction('BuildRobot')
Then i called this code, and then everything works fine.
This is a temporary solution.
If I wanted to have a function that can have an *.STL as input and build the rigidBodyTree online, this would'nt work.

Più risposte (1)

Karsh Tharyani
Karsh Tharyani il 25 Gen 2022
Modificato: Karsh Tharyani il 25 Gen 2022
Hi Ran,
Thanks for your question, and I apologize you are facing this issue.
It is expected that adding STL mesh files for collision geometries to the "rigidBody" via "addCollision" is not supported for code generation. Your suggested workaround should help in resolving your issue, and you are right in that you can't add STL meshes as collision geometries during runtime.
I have conveyed your suggested enhancement to the development team at MathWorks.
Please do not hesitate to reach out to our Technical Support team to share your use case or if you have come across other issues.
Best,
Karsh

Community Treasure Hunt

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

Start Hunting!

Translated by