addMesh
Add new static mesh to robot scenario
Description
addMesh(
adds a static mesh to the robot scenario by specifying the mesh type and specifies
additional options using name-value pair arguments.scenario
,type
,Name=Value
)
Examples
Add Meshes to Robot Scenario
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.
show3D(scenario);
Input Arguments
scenario
— Robot scenario
robotScenario
object
Robot scenario, specified as a robotScenario
object.
type
— Type of mesh
"Box"
| "Cylinder"
| "Plane"
| "Sphere"
| "Custom"
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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: addMesh(scenario,"Box",Position=[-3 -3 0.5])
Color
— Mesh color
[1 0 0]
(default) | RGB triplet
Mesh color, specified as a RGB triplet.
Data Types: single
| double
ReferenceFrame
— Reference frame of mesh geometry
"ENU"
(default) | name of defined inertial frame
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
IsBinaryOccupied
— Occupied state of binary occupancy map
false
(default) | true
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
— Position of static mesh in robot scenario
[0 0 0]
(default) | vector of form [x
y
z]
Position of static mesh in robot scenario, specified as a vector of the form
[x
y
z]
in meters.
Data Types: single
| double
Size
— Size of static mesh
scalar | vector
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 Argument | Geometry Parameters | Description |
---|---|---|
"Box" | [xlength
ylength
zlength] | Create a box with a specified side lengths in the x-, y-, and z-directions. Default: |
"Cylinder" | [radius
length] | Create a cylinder with a specified radius and length. Default: |
"Plane" | [xlength
ylength] | Create a plane with a specified side lengths in the x- and y-directions. Default: |
"Sphere" | radius | Create a sphere with a specified radius. Default:
|
Data Types: single
| double
Faces
— Faces of custom static mesh
N-by-3 matrix of positive integers
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
— Vertices of custom static mesh
N-by-3 matrix of real scalars
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
Version History
Introduced in R2022a
See Also
Objects
Functions
addInertialFrame
|advance
|binaryOccupancyMap
|restart
|setup
|show3D
|updateSensors
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)