¿Is it possible to use the function checkCollision (robotics toolbox) from simulink?

2 views (last 30 days)
I've simulated a robotic environment importing a URDF to simulink and getting the multibody representation of the robot. Now I need to check for self collisions, for that purpouse there's an implemented function in the robotics toolbox called checkCollision with two input arguments, the robot implemented as a rigidBodyTree structure and the joint configuration. This function has no implementation in simulink.
¿Is it possible to call this function from simulink?
So far the main issue that I'm facing is that the rigidBodyTree structure that the function takes as a input argument can't be imported to simulink through from workspace block nor from parameters to MatLab function blocks.

Accepted Answer

Karsh Tharyani
Karsh Tharyani on 12 Jan 2022
Edited: Karsh Tharyani on 12 Jan 2022
Hi Ignacio,
Thanks for your question. You can use a MATLAB Function Block which creates a rigidBodyTree inside of it and then you can call checkCollision inside the block.
As an illustration, see the MATLAB Function Block "checkSelfCollision" in the model and its code below
function y = checkSelfCollision(q)
persistent rbt
if(isempty(rbt))
rbt=importrobot("kinovaGen3.urdf","DataFormat","row");
end
y=checkCollision(rbt,q);
end
Note that you will have to specify the size of input argument "q" of the function block. The size should correspond to the size of the "rigidBodyTree's" joint configuration. In case of the above snippet, the size for the Kinova Gen 3 robot is [1,7] (1-by-7)
I hope this helps in answering your query.
Best,
Karsh

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!