Main Content


Visualize capsule approximation of rigid body tree

Since R2022b


    show(capapprox) shows the collision capsule approximation capsapprox, superimposed on the original collision geometries of the corresponding rigid body tree in the home configuration of the rigid body tree.


    show(capapprox,config) shows the collision capsule approximation superimposed on the original collision geometries of the corresponding rigid body tree with the specified joint configuration config.

    show(capapprox,Parent=ax) specifies the parent axes handle ax to plot capsule-approximated rigid body tree.

    ax = show(capapprox,___) returns the axes handle ax containing the capsule-approximated rigid body tree plot.


    collapse all

    Load a robot into the workspace and visualize it.

    robotIRB = loadrobot("abbIrb120");

    Create a capsule approximation of the robot, and visualize the capsule-approximated robot model.

    capsIRB = capsuleApproximation(robotIRB);

    Use the getCapsules function to see if the end effector, "tool0", has any collision capsules. Because tool0 is just a frame, it has no collision mesh to approximate as a collision capsule.

    capsulesTool = getCapsules(capsIRB,"tool0")
    capsulesTool =
      1x0 empty cell array

    Add a capsule to tool0, at a position 0.15 meters along the x-axis, with a radius of 0.15 and a length of 0.

    addCapsule(capsIRB,"tool0",[0.15 0],trvec2tform([0.15 0 0]))

    Again check tool0 for a collision capsule, and verify the properties of the detected capsule.

    capsulesTool = getCapsules(capsIRB,"tool0")
    capsulesTool = 1x1 cell array
        {1x1 collisionCapsule}
    ans = 
      collisionCapsule with properties:
        Radius: 0.1500
        Length: 0
          Pose: [4x4 double]

    Remove the capsule from the base link. Then, reduce the collision capsule size of tool0, and move it -0.05 meters from the previous position along the x-axis.

    updatePose(capsIRB,"tool0",trvec2tform([-0.05 0 0]),1)
    updateGeometry(capsIRB,"tool0",[.1 0.01],1)

    Input Arguments

    collapse all

    Capsule approximation of a rigid body tree, specified as a capsuleApproximation object.

    Rigid body tree robot model configuration, specified as an n-element row vector, in radians. n is the number of movable joints in the rigid body tree model.

    Example: [pi 0 pi/2 0 0] is a configuration for a rigid body tree with five movable joints.

    Parent axes graphic handle, specified as an Axes object.

    Output Arguments

    collapse all

    Axes graphic handle, returned as an Axes object.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2022b

    See Also