最后一步,检测到两个碰撞。可视化这些配置以进一步研究。
使用exampleHelperHighlightCollisionBodies函数来基于索引突出显示主体。
可以看到一个碰撞发生在球体和桌子上。
collidingIdx1 = find(inCollision,1);
collidingIdx2 = find(inCollision,1,"last");
% Identify the colliding rigid bodies.
collidingBodies1 = worldCollisionPairIdx{collidingIdx1}*[1 0]';
collidingBodies2 = worldCollisionPairIdx{collidingIdx2}*[1 0]';
% Visualize the environment.
ax = exampleHelperVisualizeCollisionEnvironment(worldCollisionArray);
% Add the robotconfigurations & highlight the colliding bodies.
show(robot,q(:,collidingIdx1),"Parent",ax,"PreservePlot",false);
exampleHelperHighlightCollisionBodies(robot,collidingBodies1 + 1,ax);
show(robot,q(:,collidingIdx2),"Parent"',ax);
exampleHelperHighlightCollisionBodies(robot,collidingBodies2 + 1,ax);