Main Content

Collision Box

Create box collision geometry

Since R2025a

  • Collision Box block

Libraries:
Robotics System Toolbox / Collision Detection

Description

The Collision Box block outputs a box collision geometry that is axis-aligned with its body-fixed frame and has the origin of the body-fixed frame at the center of the box.

Examples

expand all

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

expand all

Side length of box geometry along the x-axis, specified as a positive scalar. Units are in meters.

Side length of box geometry along the y-axis, specified as a positive scalar. Units are in meters.

Side length of box geometry along the z-axis, specified as a positive scalar. Units are in meters.

Pose of the collision geometry relative to the world frame, specified as a 4-by-4 homogeneous matrix.

Output

expand all

Collision geometry, returned as a bus.

To perform collision checking, connect this output to a Check Collision block as input.

Validity collision box dimensions, returned as an integer scalar where each digit represents the validity of a dimension:

  • First Digit — Validity of the x-axis length at the X port.

  • Second Digit — Validity of the y-axis length at the Y port.

  • Third Digit — Validity of the z-axis length at the Z 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 dimension value is not positive.

  • 0 — Specified dimension value is valid.

For example, if the exit flag is 230, then the x-length of the box is nonfinite, the y-length is not a real value, and the z-length is valid.

To validate dimensions at runtime instead, select the Enable Runtime Input Dimensions Error parameter.

Data Types: uint16

Parameters

expand all

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 box dimensions and return an error if X, Y, or Z is invalid.

If you clear this parameter, the block does not error during simulation, and instead uses the ExitFlag port to identify invalid box dimensions.

  • Interpreted execution — Simulate model using the MATLAB® interpreter. For more information, see Interpreted Execution vs. Code Generation (Simulink).

  • Code generation — Simulate model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change.

Tunable: No

More About

expand all

Extended Capabilities

expand all

Version History

Introduced in R2025a