Collision Mesh

Libraries:
Robotics System Toolbox /
Collision Detection
Description
The Collision Mesh block outputs a convex mesh collision geometry using a list of 3-D vertices relative to a pose specified in relation to the world frame.
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
Vertices of the mesh, specified as an N-by-3 matrix, where N is the number of vertices and must greater than or equal to 1. Each row of Vertices represents the coordinates of a point in 3-D space. Note that some of the points can be inside the constructed convex mesh.
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 mesh vertices, returned as one of these values:
4
— Vertices matrix contains values nonnumeric.3
— Vertices matrix contains values that are not real.2
— Vertices matrix contains nonfinite values.1
— Vertices matrix does not have three columns.0
— Vertices are valid.
To validate vertices 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 mesh vertices and return an error if Vertices is invalid.
If you clear this parameter, the block does not error during simulation, and instead uses the ExitFlag port to identify invalid mesh vertices.
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 Mesh 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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)