Main Content


Add new static mesh to robot scenario

Since R2022a



    addMesh(scenario,type,Name=Value) adds a static mesh to the robot scenario by specifying the mesh type and specifies additional options using name-value arguments.


    collapse all

    Create a robot Scenario.

    scenario = robotScenario;

    Add a plane, box, cylinder, and sphere mesh to the scenario.

    addMesh(scenario,"Plane",Size=[15 15],Color=[0.7 0.7 0.7])
    addMesh(scenario,"Box",Position=[-3 -3 0.5],Color=[1 0.5 0])
    addMesh(scenario,"Cylinder",Position=[-2 4 0.5],Color=[0 0 1])
    addMesh(scenario,"Sphere",Position=[2 7 1],Color=[0 1 0])

    Add custom mesh to the scenario with vertices and faces.

    vertices = [0 0 0; 0 0 2; 0 2 0; 0 2 2; 2 0 0; 2 0 2; 2 2 0; 2 2 2];
    faces = [1 3 7; 1 7 5; 1 6 2; 1 5 6; 1 2 4; 1 4 3; ...
             3 4 8; 3 8 7; 5 8 6; 5 7 8; 2 8 4; 2 6 8];
    addMesh(scenario,"Custom",Vertices=vertices,Faces=faces,Position=[4 -4 1])

    Visualize the scenario.


    Input Arguments

    collapse all

    Robot scenario, specified as a robotScenario object.

    Type of mesh, specified as "Box", "Cylinder", "Plane", "Sphere", or "Custom".

    Data Types: char | string

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addMesh(scenario,"Box",Position=[-3 -3 0.5])

    Mesh color, specified as a RGB triplet.

    Data Types: single | double

    Reference frame of the geometry input, specified as an inertial frame name defined in the InertialFrames property of the robotScenario object. You can add new inertial frames to the scenario using the addInertialFrame object function.

    The scenario only accepts frames that have z-axis rotation with respect to the "ENU" frame.

    Data Types: char | string

    Occupied state of binary occupancy map, specified as true or false. Set the value as true if static mesh is considered as an obstacle in the scenario and it is incorporated in the binary occupancy map.

    Data Types: logical

    Position of static mesh in robot scenario, specified as a vector of the form [x y z] in meters.

    Data Types: single | double

    Size of static mesh, specified as a scalar or vector of geometry parameters, except for the custom mesh. Depending on the type input, the geometry parameters have different forms:

    type Input ArgumentGeometry ParametersDescription
    "Box"[xlength ylength zlength]

    Create a box with a specified side lengths in the x-, y-, and z-directions.

    Default: [1 1 1]

    "Cylinder"[radius length]

    Create a cylinder with a specified radius and length.

    Default: [1 1]

    "Plane"[xlength ylength]

    Create a plane with a specified side lengths in the x- and y-directions.

    Default: [1 1]


    Create a sphere with a specified radius.

    Default: 1

    Data Types: single | double

    Faces of the custom static mesh, specified as an N-by-3 matrix of positive integers. The three elements in each row are the indices of the three points in the vertices forming a triangle face. N is the number of faces.

    Data Types: single | double

    Vertices of the custom static mesh, specified as an N-by-3 matrix of real scalars. The first, second, and third element of each row represents the x-, y-, and z-position of each vertex, respectively. N is the number of vertices.

    Data Types: single | double

    Collision object to add to the scenario mesh, specified as one of these values:

    Transformation of the collision mesh relative to the scenario mesh, specified as a 4-by-4 homogeneous transformation matrix.

    Data Types: single | double

    Identifier for the scenario mesh, specified as a string scalar or character vector. The name must be unique within the scenario. If you do not specify this argument, the function assigns a unique name for the scenario mesh is assigned, by default.

    Data Types: char | string

    Version History

    Introduced in R2022a