show3D
Syntax
Description
[
visualizes latest states of the platforms and sensors in the UAV scenario
ax
,plottedFrames
] = show3D(scene
)scene
along with all static meshes. The function also returns the
axes on which the scene is plotted and the frames on which each object is plotted.
[
visualizes the UAV scenario at the specified ax
,plottedFrames
] = show3D(scene
,time
)time
.
[
specifies additional options using Name-Value pairs. Enclose each ax
,plottedFrames
] = show3D(___,Name,Value
)Name
in quotes.
Examples
Create and Simulate UAV Scenario
Create a UAV scenario and set its local origin.
scene = uavScenario("UpdateRate",200,"StopTime",2,"ReferenceLocation",[46, 42, 0]);
Add an inertial frame called MAP
to the scenario.
scene.addInertialFrame("ENU","MAP",trvec2tform([1 0 0]));
Add one ground mesh and two cylindrical obstacle meshes to the scenario.
scene.addMesh("Polygon", {[-100 0; 100 0; 100 100; -100 100],[-5 0]},[0.3 0.3 0.3]); scene.addMesh("Cylinder", {[20 10 10],[0 30]}, [0 1 0]); scene.addMesh("Cylinder", {[46 42 5],[0 20]}, [0 1 0], "UseLatLon", true);
Create a UAV platform with a specified waypoint trajectory in the scenario. Define the mesh for the UAV platform.
traj = waypointTrajectory("Waypoints", [0 -20 -5; 20 -20 -5; 20 0 -5],"TimeOfArrival",[0 1 2]); uavPlat = uavPlatform("UAV",scene,"Trajectory",traj); updateMesh(uavPlat,"quadrotor", {4}, [1 0 0],eul2tform([0 0 pi])); addGeoFence(uavPlat,"Polygon", {[-50 0; 50 0; 50 50; -50 50],[0 100]},true,"ReferenceFrame","ENU");
Attach an INS sensor to the front of the UAV platform.
insModel = insSensor(); ins = uavSensor("INS",uavPlat,insModel,"MountingLocation",[4 0 0]);
Visualize the scenario in 3-D.
ax = show3D(scene);
axis(ax,"equal");
Simulate the scenario.
setup(scene); while advance(scene) % Update sensor readings updateSensors(scene); % Visualize the scenario show3D(scene,"Parent",ax,"FastUpdate",true); drawnow limitrate end
Input Arguments
scene
— UAV scenario
uavScenario
object
UAV scenario, specified as a uavScenario
object.
time
— Time stamp
nonnegative scalar
Time stamp at which to show the scenario, specified as a nonnegative scalar. The
time stamp must already be saved in the scenario. To change the number of saved time
stamps, use the HistoryBufferSize
property of the uavScenario
object, scene
.
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: ax = show3D(scene,"FastUpdate",true)
FastUpdate
— Enable updating from previous map
false
(default) | true
Enable updating from previous map, specified as true
or
false
. When specified as true
, the function
plots the map via a lightweight update to the previous map in the figure. When
specified as false
, the function plots the whole scene on the
figure every time.
Output Arguments
plottedFrames
— Plotted frame information
structure
Plotted frame information, returned as a structure of hgtransform
objects. The structure has two types of field names:
Inertial frame names — The corresponding field value is a
hgtransform
object which contains the transform information from the ego frame to the ENU frame.UAV platform names — The corresponding field value is a structure which contains the
hgtransform
information for all frames defined on the platform.
Version History
Introduced in R2020b
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)