Unexpected behaviour of checkCollision for robot collision detection
I am using the function checkCollision (R2020b version) to detect wheter a robot is in collision with itself. The basic code I use for this is:
robot = importrobot(robotPath,'MeshPath',collisionMeshPath);
isCollision = checkCollision(robot,jointAngles); % joint angles = [a1 a2 a3 a4 a5 a6]'
This function works great when the robot model does not have a tool attached. However, with a tool attached, the behaviour is not as expected anymore since it always returns true.
I need to shift the mesh of the tool away from the robot so far that no point of the robot sticks into the bottom of the tool even though there is a cut out. I have now removed the entire bottom part covering the tool and still get this problem. You can clearly see that the robot arm is far away from touching the tool but still the output is always true. In the image below, I added 18mm of vertical offset and still get the error. Once I add 19mm, no part of the robot stick into the tool and the error goes away. I want to use the function with no or very small z-offset in order to do a realistic collision detection.
Is this just the normal behaviour of this function or am I doing something wrong here? Is there maybe a workaround?
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
It will help to view the robot’s collision geometry data instead of the visual data as they might be different. To do so,
show(robot, config, "Visuals", "off", "Collisions", "on");
You can also view the end-effector body’s collision data by inspecting the Collisions property of the rigidBody
The next good step will be to find out which bodies are in collision. This can be done by viewing the separation distances between the bodies.
[isColliding, sepDist] = checkCollision(robot, config, "Exhaustive", "on");
In order to find out which bodies are colliding, you can view the entries in the sepDist matrix which are NaNs
[b1, b2] = find(isnan(sepDist));
robot.BodyNames{b1}
robot.BodyNames{b2}
Note that the rows and columns correspond to the body indices.
SEE COMPLETE ANSWER CLICK THE LINK