Page
1
UAV Toolbox User's Guide R2020b
Page
2
How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us Phone: 508-647-7000 The MathWorks, Inc. 1 Apple Hill Drive Natick, MA 01760-2098 UAV Toolbox User's Guide © COPYRIGHT 2020 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. Patents MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information. Revision History September 2020 Online only New for Version 1.0 (R2020b)
Page
3
UAV Toolbox Examples 1 Visualize and Playback MAVLink Flight Log . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Flight Instrument Gauge Visualization for a Drone . . . . . . . . . . . . . . . . . . 1-5 Visualize Custom Flight Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11 Tuning Waypoint Follower for Fixed-Wing UAV . . . . . . . . . . . . . . . . . . . . . 1-25 Approximate High-Fidelity UAV model with UAV Guidance Model block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29 Motion Planning with RRT for Fixed-Wing UAV . . . . . . . . . . . . . . . . . . . . 1-40 UAV Package Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46 UAV Scenario Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57 Tune UAV Parameters Using MAVLink Parameter Protocol . . . . . . . . . . . 1-61 Exchange Data for MAVLink Microservices like Mission Protocol and Parameter Protocol Using Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66 3D Simulation – User's Guide 2 Unreal Engine Simulation for Unmanned Aerial Vehicles . . . . . . . . . . . . . 2-2 Unreal Engine Simulation Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Algorithm Testing and Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Unreal Engine Simulation Environment Requirements and Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Minimum Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 How Unreal Engine Simulation for UAVs Works . . . . . . . . . . . . . . . . . . . . . 2-7 Communication with 3D Simulation Environment . . . . . . . . . . . . . . . . . . . 2-7 Block Execution Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 iii Contents
Page
4
Coordinate Systems for Unreal Engine Simulation in UAV Toolbox . . . . . 2-9 Earth-Fixed (Inertial) Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Body (Non-Inertial) Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Unreal Engine World Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . 2-11 Choose a Sensor for Unreal Engine Simulation . . . . . . . . . . . . . . . . . . . . 2-13 Simulate Simple Flight Scenario and Sensor in Unreal Engine Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 Depth and Semantic Segmentation Visualization Using Unreal Engine Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Customize Unreal Engine Scenes for UAVs . . . . . . . . . . . . . . . . . . . . . . . . 2-24 Install Support Package for Customizing Scenes . . . . . . . . . . . . . . . . . . . 2-25 Verify Software and Hardware Requirements . . . . . . . . . . . . . . . . . . . . . 2-25 Install Support Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25 Set Up Scene Customization Using Support Package . . . . . . . . . . . . . . . 2-25 Customize Unreal Engine Scenes Using Simulink and Unreal Editor . . . 2-28 Open Unreal Editor from Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 Reparent Actor Blueprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29 Create or Modify Scenes in Unreal Editor . . . . . . . . . . . . . . . . . . . . . . . . 2-29 Run Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Package Custom Scenes into Executable . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 Package Scene into Executable Using Unreal Engine . . . . . . . . . . . . . . . 2-33 Apply Semantic Segmentation Labels to Custom Scenes . . . . . . . . . . . . . 2-35 iv Contents
Page
5
UAV Toolbox Examples 1
Page
6
Visualize and Playback MAVLink Flight Log This example shows how to load a telemetry log (TLOG) containing MAVLink packets into MATLAB®. Details of the messages are extracted for plotting. Then, to simulate the flight again, the messages are republished over the MAVLink communication interface. This publishing mimics an unmanned aerial vehicle (UAV) executing the flight recorded in the tlog. Load MAVLink TLOG Create a mavlinkdialect object using the "common.xml" dialect. Use mavlinktlog with this dialect to load the TLOG data. dialect = mavlinkdialect('common.xml'); logimport = mavlinktlog('mavlink_flightlog.tlog',dialect); Extract the GPS messages from the TLOG and visualize them using geoplot. msgs = readmsg(logimport, 'MessageName', 'GPS_RAW_INT', ... 'Time',[0 100]); latlon = msgs.Messages{1}; % filter out zero-valued messages latlon = latlon(latlon.lat ~= 0 & latlon.lon ~= 0, :); figure() geoplot(double(latlon.lat)/1e7, double(latlon.lon)/1e7); Extract the attitude messages from the TLOG. Specify the message name for attitude messages. Plot the roll, pitch, yaw data using stackedplot. 1 UAV Toolbox Examples 1-2
Page
7
msgs = readmsg(logimport,'MessageName','ATTITUDE','Time',[0 100]); figure() stackedplot(msgs.Messages{1},{'roll','pitch','yaw'}); Playback MAVLink Log Entries Create a MAVLink communication interface and publish the messages from the TLOG to user defined UDP port. Create a sender and receiver for passing the MAVLink messages. This communication system works the same way that real hardware would publish messages using the MAVLink communication protocols. sender = mavlinkio(dialect,'SystemID',1,'ComponentID',1,... 'AutopilotType',"MAV_AUTOPILOT_GENERIC",... 'ComponentType',"MAV_TYPE_QUADROTOR"); connect(sender,'UDP'); destinationPort = 14550; destinationHost = '127.0.0.1'; receiver = mavlinkio(dialect); connect(receiver,'UDP','LocalPort',destinationPort); subscriber = mavlinksub(receiver,'ATTITUDE','NewMessageFcn',@(~,msg)disp(msg.Payload)); Send the first 100 messages at a rate of 50 Hz. Visualize and Playback MAVLink Flight Log 1-3
Page
8
payloads = table2struct(msgs.Messages{1}); attitudeDefinition = msginfo(dialect, 'ATTITUDE'); for msgIdx = 1:100 sendudpmsg(sender,struct('MsgID', attitudeDefinition.MessageID, 'Payload', payloads(msgIdx)),destinationHost,destinationPort); pause(1/50); end Disconnect from both MAVLink communcation interfaces. disconnect(receiver) disconnect(sender) 1 UAV Toolbox Examples 1-4
Page
9
Flight Instrument Gauge Visualization for a Drone Import and visualize a drone flight log using 3-D animations and flight intrument gauges. This example obtains a high level overview of flight performance in MATLAB® using “Flight Instruments” (Aerospace Toolbox) functions in Aerospace Toolbox™. Then, to view signals in a custom interface in Simulink® , the example uses the “Flight Instruments” (Aerospace Blockset) blocks from Aerospace Blockset™ The example extracts the signals of interest from a ULOG file and plays back the UAV flight trajectory in MATLAB. Then, those signals are replayed in a Simulink model using instrument blocks. Import a Flight log A drone log file records information about the flight at regular time intervals. This information gives insight into the flight performance. Flight instrument gauges display navigation variables such as attitude, altitude, and heading of the drone. The ULOG log file for this example was obtained from an airplane model running in the Gazebo simulator. Import the logfile using ulogreader. Create a flightLogSignalMapping object for ULOG files. To understand the convention of the signals, the units, and their reference frame, inspect the information within the plotter object. This information about units within log file becomes important when connecting the signals to flight instrument gauges. data = ulogreader("fwflight.ulg"); plotter = flightLogSignalMapping("ulog"); info(plotter,"Signal") ans=14×4 table SignalName IsMapped SignalFields FieldUnits "Accel" true "AccelX, AccelY, AccelZ" "m/s^2, m/s^2, m/s^2" "Airspeed" true "PressDiff, IndicatedAirSpeed, Temperature" "Pa, m/s, degreeC" "AttitudeEuler" true "Roll, Pitch, Yaw" "rad, rad, rad" "AttitudeRate" true "BodyRotationRateX, BodyRotationRateY, BodyRotationRateZ" "rad/s, rad/s, rad/s" "AttitudeTargetEuler" true "RollTarget, PitchTarget, YawTarget" "rad, rad, rad" "Barometer" true "PressAbs, PressAltitude, Temperature" "Pa, m, degreeC" "Battery" true "Voltage_1, Voltage_2, Voltage_3, Voltage_4, Voltage_5, Voltage_6, Voltage_7, Voltage_8, Voltage_9, Voltage_10, Voltage_11, Voltage_12, Voltage_13, Voltage_14, Voltage_15, Voltage_16, RemainingCapacity" "v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, %" "GPS" true "Latitude, Longitude, Altitude, GroundSpeed, CourseAngle, SatellitesVisible" "degree, degree, m, m/s, degree, N/A" "Gyro" true "GyroX, GyroY, GyroZ" "rad/s, rad/s, rad/s" "LocalNED" true "X, Y, Z" "m, m, m" "LocalNEDTarget" true "XTarget, YTarget, ZTarget" "m, m, m" "LocalNEDVel" true "VX, VY, VZ" "m/s, m/s, m/s" "LocalNEDVelTarget" true "VXTarget, VYTarget, VZTarget" "m/s, m/s, m/s" "Mag" true "MagX, MagY, MagZ" "Gs, Gs, Gs" Extract Signals of Interest To visualize the drone flight using instrument gauges, extract the attitude, position, velocity, and airspeed at each timestep. Specify the appropriate signal name from the info table in the previous step. Call the extract function with the appropriate signal names. The time vector element of signals are adjusted so they start at 0 seconds. % Extract attitude and roll-pitch-yaw data. rpy = extract(plotter, data,"AttitudeEuler"); Flight Instrument Gauge Visualization for a Drone 1-5
Page
10
rpy{1}.Time=rpy{1}.Time-rpy{1}.Time(1); RollData = timetable(rpy{1}.Time,rpy{1}.Roll,... 'VariableNames',{'Roll'}); PitchData = timetable(rpy{1}.Time,rpy{1}.Pitch,... 'VariableNames',{'Pitch'}); YawData = timetable(rpy{1}.Time,rpy{1}.Yaw,... 'VariableNames',{'Yaw'}); % Extract position and xyz data. Position = extract(plotter, data,"LocalNED"); Position{1}.Time = Position{1}.Time-Position{1}.Time(1); X = timetable(Position{1}.Time,Position{1}.X,... 'VariableNames',{'X'}); Y = timetable(Position{1}.Time,Position{1}.Y,... 'VariableNames',{'Y'}); Z = timetable(Position{1}.Time,Position{1}.Z,... 'VariableNames',{'Z'}); % Extract velocity data. vel = extract(plotter, data,"LocalNEDVel"); vel{1}.Time=vel{1}.Time-vel{1}.Time(1); XVel = timetable(vel{1}.Time,vel{1}.VX,... 'VariableNames',{'VX'}); YVel = timetable(vel{1}.Time,vel{1}.VY,... 'VariableNames',{'VY'}); ZVel = timetable(vel{1}.Time,vel{1}.VZ,... 'VariableNames',{'VZ'}); % Extract Airspeed magnitude data. airspeed = extract(plotter, data,"Airspeed"); Airspeed = timetable(airspeed{1}.Time,airspeed{1}.IndicatedAirSpeed,... 'VariableNames',{'Airspeed'}); Convert Units and Preprocess Data for Gauges Our flight log records data in SI Units. The flight instrument gauges require a conversion to Aerospace Standard Unit System represented by English System. This conversion is handled in the visualization block available in attached Simulink model for the user. The turn coordinator indicates the yaw rate of the aircraft using an indicative banking motion (which differs from the bank angle). In order to compute the yaw rate, convert the angular rates from body frame to vehicle frame as given below: ψ̇ = qcos ϕ + rsin ϕ cosθ The inclinometer ball within turn coordinator indicates the sideslip of the aircraft. This sideslip angle is based on the angle between the body of the aircraft and computed airspeed. For an accurate airspeed, a good estimate of velocity and wind vector is required. Most small UAV's do not possess sensors to estimate wind vector data or airspeed while flying. UAV's can face between 20-50% of their airspeed in the form of crosswinds. Vg- Vw=Va To compute sideslip and turn, extract wind and attitude rate data directly from the log file. 1 UAV Toolbox Examples 1-6
Page
11
% Extract roll, pitch and yaw rates and an estimated windspeed. [p,q,r,wn,we] = helperExtractUnmappedData(data); % Merge timetables. FlightData = synchronize(X,Y,Z,RollData,PitchData,YawData,XVel,YVel,ZVel,p,q,r,Airspeed,wn,we,'union','linear'); % Assemble an array for the data. FlightDataArray = double([seconds(FlightData.Time) FlightData.X FlightData.Y FlightData.Z FlightData.Roll ... FlightData.Pitch FlightData.Yaw,FlightData.VX,FlightData.VY,... FlightData.VZ,FlightData.p,FlightData.q,FlightData.r,FlightData.Airspeed,FlightData.wn,FlightData.we]); % Ensure time rows are unique. [~,ind]=unique(FlightDataArray(:,1)); FlightDataArray=FlightDataArray(ind,:); % Preprocess time data to specific times. flightdata = double(FlightDataArray(FlightDataArray(:,1)>=0,1:end)); Visualize Standard Flight Instrument Data in MATLAB To get a quick overview of the flight , use the animation interface introduced in the “Display Flight Trajectory Data Using Flight Instruments and Flight Animation” (Aerospace Toolbox) example. The helper function helperDroneInstruments creates an instrument animation interface. helperDroneInstruments; Flight Instrument Gauge Visualization for a Drone 1-7
Page
12
The Airspeed indicator dial indicates the speed of the drone. The Artificial Horizon indicator reveals the attitude of the drone excluding yaw. The Altimeter and Climb Rate indicator reveal the altitude as recorded within the barometer and the climb rate sensors respectively. The Turn Coordinator indicates the yaw rate of the aircraft and sideslip. If the inclinometer skews towards left or right, this denotes a slip or skid situation. In a coordinated turn, the sideslip should be zero. Visualize Signals in Simulink In Simulik, you can create custom visualizations of signals using intrument blocks to help diagnose problems with a flight. For example, voltage and battery data in log files can help diagnose failures due to inadequate power or voltage spikes. Extract this batter data below to visualize them. % Extract battery data. Battery = extract(plotter,data,"Battery"); % Extract voltage data from topic. Voltage = timetable(Battery{1}.Time,Battery{1}.Voltage_1,... 'VariableNames',{'Voltage_1'}); % Extract remaing battery capacity data from topic. Capacity = timetable(Battery{1}.Time,Battery{1}.RemainingCapacity,... 'VariableNames',{'RemainingCapacity'}); 1 UAV Toolbox Examples 1-8
Page
13
Open the 'dronegauge' model, which takes the loaded data and displays it on the different gauges and the UAV animation figure. open_system('dronegauges'); Run the model. The generated figure shows the trajectory of the UAV in real time and the gauges show the current status of the flight. sim('dronegauges'); Flight Instrument Gauge Visualization for a Drone 1-9
Page
14
1 UAV Toolbox Examples 1-10
Page
15
Visualize Custom Flight Log Configure the flightLogSignalMapping object to visualize data from a custom flight log. Load Custom Flight Log In this example, it is assumed that flight data is already parsed into MATLAB® and stored as a mat file. This example focuses on configuring the flightLogSignalMapping object so that it could properly handle the log data saved in the mat file and visualize them. The data, customFlightData.mat, stores a struct that contains 3 fields. Fs is the sampling frequency of the signals stored in the mat file. IMU and Trajectory are matrices containing actual flight information. The trajectory and IMU data are based on a simulated flight that follows a projected rectangular path on an XY-plane. customData = load("customFlightData.mat"); logData = customData.logData logData = struct with fields: IMU: [2785x9 double] Fs: 100 Trajectory: [2785x10 double] The IMU field in logData is an n-by-9 matrix, with the first 3 columns as accelerometer readings in m/s2. The next 3 columns are gyroscope readings in rad/s, and the last 3 columns are magnetometer readings in μT. logData.IMU(1:5, :) ans = 5×9 0.8208 0.7968 10.7424 0.0862 0.0873 0.0862 327.6000 297.6000 283.8000 0.8016 0.8160 10.7904 0.0883 0.0873 0.0862 327.6000 297.6000 283.8000 0.7680 0.7680 10.7568 0.0862 0.0851 0.0851 327.6000 297.6000 283.8000 0.8208 0.7536 10.7520 0.0873 0.0883 0.0819 327.6000 297.6000 283.8000 0.7872 0.7728 10.7328 0.0873 0.0862 0.0830 327.6000 297.6000 283.8000 The Trajectory field in logData is an n-by-9 matrix, with the first 3 columns are XYZ NED coordinates in m. The next 3 columns are velocity in XYZ NED direction in m/s, and the last 4 columns are quaternions describing the UAV rotation from the inertia NED frame to body frame. Each row is a single point of the trajectory with all these parameters defined. logData.Trajectory(1:5,:) ans = 5×10 0.0200 0 -4.0000 2.0000 0 -0.0036 1.0000 0 0 -0.0000 0.0400 0 -4.0001 2.0000 0 -0.0072 1.0000 0 0 -0.0000 0.0600 0 -4.0002 2.0000 0 -0.0108 1.0000 0 0 -0.0000 0.0800 0 -4.0003 2.0000 0 -0.0143 1.0000 0 0 -0.0000 0.1000 0 -4.0004 2.0000 0 -0.0179 1.0000 0 0 -0.0001 Visualize Custom Flight Log 1-11
Page
16
Visualize Custom Flight Log Using Pre-defined Signal Format and Plots A flightLogSignalMapping object is created with no input argument since the custom log format is not following a standard "ulog" or "tlog" definition. customPlotter = flightLogSignalMapping; The object has a predefined set of signals that you can map. By mapping these predefined signals, you gain access to a set of predefined plots. Notice that a few signals has a "#" symbol suffix. This means that you can optionally suffix these signal names with integers so that the flight log plotter can handle multiple of signals of this kind, such as secondary IMU signals, barometer readings, etc. Call info % Predefined signals info(customPlotter, "Signal") ans=18×4 table SignalName IsMapped SignalFields FieldUnits "Accel#" false "AccelX, AccelY, AccelZ" "m/s^2, m/s^2, m/s^2" "Airspeed#" false "PressDiff, IndicatedAirSpeed, Temperature" "Pa, m/s, degreeC" "AttitudeEuler" false "Roll, Pitch, Yaw" "rad, rad, rad" "AttitudeRate" false "BodyRotationRateX, BodyRotationRateY, BodyRotationRateZ" "rad/s, rad/s, rad/s" "AttitudeTargetEuler" false "RollTarget, PitchTarget, YawTarget" "rad, rad, rad" "Barometer#" false "PressAbs, PressAltitude, Temperature" "Pa, m, degreeC" "Battery" false "Voltage_1, Voltage_2, Voltage_3, Voltage_4, Voltage_5, Voltage_6, Voltage_7, Voltage_8, Voltage_9, Voltage_10, Voltage_11, Voltage_12, Voltage_13, Voltage_14, Voltage_15, Voltage_16, RemainingCapacity" "v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, %" "GPS#" false "Latitude, Longitude, Altitude, GroundSpeed, CourseAngle, SatellitesVisible" "degree, degree, m, m/s, degree, N/A" "Gyro#" false "GyroX, GyroY, GyroZ" "rad/s, rad/s, rad/s" "LocalENU" false "X, Y, Z" "m, m, m" "LocalENUTarget" false "XTarget, YTarget, ZTarget" "m, m, m" "LocalENUVel" false "VX, VY, VZ" "m/s, m/s, m/s" "LocalENUVelTarget" false "VXTarget, VYTarget, VZTarget" "m/s, m/s, m/s" "LocalNED" false "X, Y, Z" "m, m, m" "LocalNEDTarget" false "XTarget, YTarget, ZTarget" "m, m, m" "LocalNEDVel" false "VX, VY, VZ" "m/s, m/s, m/s" ⋮ % Predefined plots info(customPlotter,"Plot") ans=10×4 table PlotName ReadyToPlot MissingSignals RequiredSignals "Attitude" false "AttitudeEuler, AttitudeRate, Gyro#" "AttitudeEuler, AttitudeRate, Gyro#" "AttitudeControl" false "AttitudeEuler, AttitudeTargetEuler" "AttitudeEuler, AttitudeTargetEuler" "Battery" false "Battery" "Battery" "Compass" false "AttitudeEuler, Mag#, GPS#" "AttitudeEuler, Mag#, GPS#" "GPS2D" false "GPS#" "GPS#" "Height" false "Barometer#, GPS#, LocalNED" "Barometer#, GPS#, LocalNED" "Speed" false "GPS#, Airspeed#" "GPS#, Airspeed#" "Trajectory" false "LocalNED, LocalNEDTarget" "LocalNED, LocalNEDTarget" "TrajectoryTracking" false "LocalNED, LocalNEDTarget" "LocalNED, LocalNEDTarget" "TrajectoryVelTracking" false "LocalNEDVel, LocalNEDVelTarget" "LocalNEDVel, LocalNEDVelTarget" 1 UAV Toolbox Examples 1-12
Page
17
The flightLogSignalMapping object needs to know how data is stored in the flight log before it can visualize the data. To associate signal names with function handles that access the relevant information in the logData, you must map signals using mapSignal. Each signal is defined as a timestamp vector and a signal value matrix. For example, to map the Gyro# signal, define a timeAccess function handle based on the sensor data sampling frequency. This function handle generates the timestamp vector for the signal values using a global timestamp interval for the data. timeAccess = @(x)seconds(1/x.Fs*(1:size(x.IMU))); Next, check what fields must be defined for the Gyro# signal using info. info(customPlotter,"Signal","Gyro#") ans=1×4 table SignalName IsMapped SignalFields FieldUnits "Gyro#" false "GyroX, GyroY, GyroZ" "rad/s, rad/s, rad/s" The Gyro# signal needs three columns containing the gyroscope readings for the XYZ axes. Define the gyroAccess function handle accordingly and map it with timeAccess using mapSignal. gyroAccess = @(x)x.IMU(:,4:6); mapSignal(customPlotter,"Gyro",timeAccess,gyroAccess); Similarly, map other predefined signalsfor data that is present in the flight log. Define the value function handles for the data. Map the signals using the same timeAccess timestamp vector function. % IMU data stores accelerometer and magnetometer data. accelAccess = @(x)x.IMU(:,1:3); magAccess = @(x)x.IMU(:,7:9)*1e-2; % Flight trajectory in local NED coordinates % XYZ coordinates nedAccess = @(x)x.Trajectory(:, 1:3); % XYZ celocities nedVelAccess = @(x)x.Trajectory(:, 4:6); % Roll Pitch Yaw rotations converted from a quaternion attitudeAccess = @(x)flip(quat2eul(x.Trajectory(:, 7:10)),2); % Configure flightLogSignalMapping for custom data mapSignal(customPlotter, "Accel", timeAccess, accelAccess); mapSignal(customPlotter, "Mag", timeAccess, magAccess); mapSignal(customPlotter, "LocalNED", timeAccess, nedAccess); mapSignal(customPlotter, "LocalNEDVel", timeAccess, nedVelAccess); mapSignal(customPlotter, "AttitudeEuler", timeAccess, attitudeAccess); Once all signals are mapped, customPlotter is ready to generate plots based on signal data stored in the log. To visualize the flight log data, call show and specify logData. All the plots available based on the mapped signals are shown in figures. predefinedPlots = show(customPlotter,logData); Visualize Custom Flight Log 1-13
Page
18
1 UAV Toolbox Examples 1-14
Page
19
Visualize Custom Flight Log 1-15
Page
20
1 UAV Toolbox Examples 1-16