-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(matlab): add simulated and actual flights (#12906)
- Loading branch information
1 parent
9b462db
commit 3c98567
Showing
4 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
h = Aero.Animation; | ||
|
||
% timeStep = (1 / FramesPerSecond) * TimeScaling = 0.5s | ||
h.FramesPerSecond = 10; | ||
h.TimeScaling = 5; | ||
|
||
% Simulated and actual flight trajectories | ||
orangeAircraftPath = fullfile(matlabroot, 'toolbox', 'aero', 'astdemos', 'pa24-250_orange.ac'); | ||
blueAircraftPath = fullfile(matlabroot, 'toolbox', 'aero', 'astdemos', 'pa24-250_blue.ac'); | ||
|
||
idx1 = h.createBody(orangeAircraftPath, 'Ac3d'); | ||
idx2 = h.createBody(blueAircraftPath, 'Ac3d'); | ||
|
||
% "simdata" contains logged simulated data in a 6DoF array | ||
simDataPath = fullfile(matlabroot, 'toolbox', 'aero', 'astdemos', 'simdata.mat'); | ||
load(simDataPath, 'simdata'); | ||
h.Bodies{1}.TimeSeriesSource = simdata; | ||
|
||
% "fltdata" contains actual flight test data in a custom format | ||
flightDataPath = fullfile(matlabroot, 'toolbox', 'aero', 'astdemos', 'fltdata.mat'); | ||
load(flightDataPath, 'fltdata'); | ||
h.Bodies{2}.TimeSeriesSource = fltdata; | ||
h.Bodies{2}.TimeSeriesReadFcn = @readTimeSeriesData; | ||
h.Bodies{2}.TimeSeriesSourceType = 'Custom'; | ||
|
||
% Camera | ||
h.Camera.PositionFcn = @doFirstOrderChaseCameraDynamics; | ||
|
||
h.play(); | ||
h.updateCamera(5); | ||
h.wait(); | ||
h.delete(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function [xyz, ptp] = readTimeSeriesData(varargin) | ||
h = varargin{end}; | ||
if size(varargin, 2) == 2 | ||
t = varargin{1}; | ||
if isfinite(varargin{1}) | ||
xyz(1) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.X, t); | ||
xyz(2) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.Y, t); | ||
xyz(3) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.Z, t); | ||
|
||
ptp(1) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.phi, t); | ||
ptp(2) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.theta, t); | ||
ptp(3) = interp1(h.TimeSeriesSource.time, h.TimeSeriesSource.psi, t); | ||
else | ||
xyz = h.TimeSeriesSource.time(1); | ||
ptp = h.TimeSeriesSource.time(end); | ||
end | ||
else | ||
xyz = [h.TimeSeriesSource.X(1), ... | ||
h.TimeSeriesSource.Y(1), ... | ||
h.TimeSeriesSource.Z(1)]; | ||
ptp = [h.TimeSeriesSource.phi(1), ... | ||
h.TimeSeriesSource.theta(1), ... | ||
h.TimeSeriesSource.psi(1)]; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters