Collision Capsule

Libraries:
Robotics System Toolbox /
Collision Detection
Description
The Collision Capsule block outputs a capsule primitive collision geometry defined by a radius and length, with the central line segment of the capsule aligning with its z-axis. The origin of the body-fixed frame is located at the midpoint of the central line segment.
Examples
Open the Simulink® model. This model contains all five of the collision geometry blocks in the Collision Detection library and checks for collision between any two of the collision geometries. Note that the Collision Mesh block uses vertices from the exampleMeshVertices
MAT file. The model loads the exampleMeshVertices
MAT file when you open the model by using the PreLoadFcn
callback.
model = "CollisionCheckingBetweenGeometries.slx";
open_system(model)
Simulate the model.
out = sim("CollisionCheckingBetweenGeometries.slx")
out = Simulink.SimulationOutput: collStatus: [1x1 timeseries] geom1Idx: [1x1 timeseries] geom2Idx: [1x1 timeseries] logsout: [1x1 Simulink.SimulationData.Dataset] sepDist: [1x1 timeseries] tout: [101x1 double] witnessPts: [1x1 timeseries] SimulationMetadata: [1x1 Simulink.SimulationMetadata] ErrorMessage: [0x0 char]
Get data from the simulation output.
collCheckingPairs = [out.geom1Idx.Data out.geom2Idx.Data]; collStatuses = out.collStatus.Data; sepDistances = out.sepDist.Data; witnessPoints = out.witnessPts.Data;
Ports
Input
Radius of the spherical ends of the capsule, specified as a positive scalar. Units are in meters.
Length of the central line segment of the capsule, specified as a nonnegative scalar. Units are in meters.
Note
This is not the length from end-to-end of the capsule. The total length of the
capsule is Length + 2*Radius
.
Pose of the collision geometry relative to the world frame, specified as a 4-by-4 homogeneous matrix.
Output
Collision geometry, returned as a bus.
To perform collision checking, connect this output to a Check Collision block as input.
Validity of collision capsule dimensions, returned as an integer scalar where each digit represents the validity of a dimension:
First Digit — Validity of the radius at Radius port.
Second Digit — Validity of the length at Length port.
Each of these digits can be one of these values:
4
— Specified dimension value is not numeric.3
— Specified dimension value is not a real number.2
— Specified dimension value is nonfinite.1
— Specified radius is not positive, or the specified length is negative.0
— Specified dimension value is valid.
For example, if the exit flag is 10
, then the radius
of the capsule is invalid because it is not positive.
To validate dimensions at runtime instead, select the Enable Runtime Input Dimensions Error parameter.
Data Types: uint16
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Select this parameter to enable runtime validation of the collision capsule dimensions and return an error if either Radius or Length is invalid.
If you clear this parameter, the block does not error during simulation, and instead uses the ExitFlag port to identify invalid capsule dimensions.
Code generation
— Simulate model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The block reuses the C code for subsequent simulations, as long as the model does not change.Interpreted execution
— Simulate model using the MATLAB® interpreter. For more information, see Interpreted Execution vs. Code Generation (Simulink).
More About
To configure the maximum number of vertices in a collision geometry block, click
Configure Collision Geometry Bus in the block mask to open the
Configure Collision Geometry Bus dialog box, and set the Maximum number of
vertices in collision geometry parameter. The default number of vertices is
10000
.
Extended Capabilities
Collision Capsule block supports code generation with dynamic memory allocation disabled. For more information about disabling dynamic memory allocation, see Dynamic memory allocation in MATLAB functions (Simulink).
Version History
Introduced in R2025a
See Also
Objects
Blocks
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)