potential videowriter compat fix
This commit is contained in:
11
agent.m
11
agent.m
@@ -15,7 +15,8 @@ classdef agent
|
|||||||
lastPos = NaN(1, 3); % position from previous timestep
|
lastPos = NaN(1, 3); % position from previous timestep
|
||||||
pos = NaN(1, 3); % current position
|
pos = NaN(1, 3); % current position
|
||||||
vel = NaN(1, 3); % current velocity
|
vel = NaN(1, 3); % current velocity
|
||||||
cBfromC = NaN(3); % current DCM body from sim cartesian (assume fixed for now)
|
pan = NaN; % pan angle
|
||||||
|
tilt = NaN; % tilt angle
|
||||||
|
|
||||||
% Collision
|
% Collision
|
||||||
collisionGeometry;
|
collisionGeometry;
|
||||||
@@ -28,12 +29,13 @@ classdef agent
|
|||||||
end
|
end
|
||||||
|
|
||||||
methods (Access = public)
|
methods (Access = public)
|
||||||
function obj = initialize(obj, pos, vel, cBfromC, collisionGeometry, sensorModel, guidanceModel, comRange, index, label)
|
function obj = initialize(obj, pos, vel, pan, tilt, collisionGeometry, sensorModel, guidanceModel, comRange, index, label)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
obj (1, 1) {mustBeA(obj, 'agent')};
|
obj (1, 1) {mustBeA(obj, 'agent')};
|
||||||
pos (1, 3) double;
|
pos (1, 3) double;
|
||||||
vel (1, 3) double;
|
vel (1, 3) double;
|
||||||
cBfromC (3, 3) double {mustBeDcm};
|
pan (1, 1) double;
|
||||||
|
tilt (1, 1) double;
|
||||||
collisionGeometry (1, 1) {mustBeGeometry};
|
collisionGeometry (1, 1) {mustBeGeometry};
|
||||||
sensorModel (1, 1) {mustBeSensor}
|
sensorModel (1, 1) {mustBeSensor}
|
||||||
guidanceModel (1, 1) {mustBeA(guidanceModel, 'function_handle')};
|
guidanceModel (1, 1) {mustBeA(guidanceModel, 'function_handle')};
|
||||||
@@ -47,7 +49,8 @@ classdef agent
|
|||||||
|
|
||||||
obj.pos = pos;
|
obj.pos = pos;
|
||||||
obj.vel = vel;
|
obj.vel = vel;
|
||||||
obj.cBfromC = cBfromC;
|
obj.pan = pan;
|
||||||
|
obj.tilt = tilt;
|
||||||
obj.collisionGeometry = collisionGeometry;
|
obj.collisionGeometry = collisionGeometry;
|
||||||
obj.sensorModel = sensorModel;
|
obj.sensorModel = sensorModel;
|
||||||
obj.guidanceModel = guidanceModel;
|
obj.guidanceModel = guidanceModel;
|
||||||
|
|||||||
10
miSim.m
10
miSim.m
@@ -13,7 +13,6 @@ classdef miSim
|
|||||||
end
|
end
|
||||||
|
|
||||||
properties (Access = private)
|
properties (Access = private)
|
||||||
v = VideoWriter(fullfile('sandbox', strcat(string(datetime('now'), 'yyyy_MM_dd_HH_mm_ss'), '_miSimHist')));
|
|
||||||
connectionsPlot; % objects for lines connecting agents in spatial plots
|
connectionsPlot; % objects for lines connecting agents in spatial plots
|
||||||
graphPlot; % objects for abstract network graph plot
|
graphPlot; % objects for abstract network graph plot
|
||||||
end
|
end
|
||||||
@@ -94,9 +93,8 @@ classdef miSim
|
|||||||
times = linspace(0, obj.timestep * obj.maxIter, obj.maxIter+1)';
|
times = linspace(0, obj.timestep * obj.maxIter, obj.maxIter+1)';
|
||||||
|
|
||||||
% Start video writer
|
% Start video writer
|
||||||
% obj.v.FrameRate = 1/obj.timestep;
|
v = setupVideoWriter(obj.timestep);
|
||||||
% obj.v.Quality = 90;
|
v.open();
|
||||||
obj.v.open();
|
|
||||||
|
|
||||||
for ii = 1:size(times, 1)
|
for ii = 1:size(times, 1)
|
||||||
% Display current sim time
|
% Display current sim time
|
||||||
@@ -116,11 +114,11 @@ classdef miSim
|
|||||||
|
|
||||||
% Write frame in to video
|
% Write frame in to video
|
||||||
I = getframe(f);
|
I = getframe(f);
|
||||||
obj.v.writeVideo(I);
|
v.writeVideo(I);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Close video file
|
% Close video file
|
||||||
obj.v.close();
|
v.close();
|
||||||
end
|
end
|
||||||
function [obj, f] = updatePlots(obj, f)
|
function [obj, f] = updatePlots(obj, f)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="setupVideoWriter.m" type="File"/>
|
||||||
17
setupVideoWriter.m
Normal file
17
setupVideoWriter.m
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
function v = setupVideoWriter(timestep)
|
||||||
|
arguments (Input)
|
||||||
|
timestep (1, 1) double;
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
v (1, 1) {mustBeA(v, 'VideoWriter')};
|
||||||
|
end
|
||||||
|
|
||||||
|
if ispc || ismac
|
||||||
|
v = VideoWriter(fullfile('sandbox', strcat(string(datetime('now'), 'yyyy_MM_dd_HH_mm_ss'), '_miSimHist')), 'MPEG-4');
|
||||||
|
elseif isunix
|
||||||
|
v = VideoWriter(fullfile('sandbox', strcat(string(datetime('now'), 'yyyy_MM_dd_HH_mm_ss'), '_miSimHist')), 'Motion JPEG AVI');
|
||||||
|
end
|
||||||
|
|
||||||
|
v.FrameRate = 1/timestep;
|
||||||
|
v.Quality = 90;
|
||||||
|
end
|
||||||
@@ -194,7 +194,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|||||||
sensor = sensor.initialize(tc.sensingLength);
|
sensor = sensor.initialize(tc.sensingLength);
|
||||||
|
|
||||||
% Initialize candidate agent
|
% Initialize candidate agent
|
||||||
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), eye(3), candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii));
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii));
|
||||||
|
|
||||||
% Make sure candidate agent doesn't collide with
|
% Make sure candidate agent doesn't collide with
|
||||||
% domain
|
% domain
|
||||||
@@ -362,7 +362,7 @@ classdef test_miSim < matlab.unittest.TestCase
|
|||||||
sensor.initialize(tc.sensingLength);
|
sensor.initialize(tc.sensingLength);
|
||||||
|
|
||||||
% Initialize candidate agent
|
% Initialize candidate agent
|
||||||
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), eye(3), candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii));
|
newAgent = tc.agents{ii}.initialize(candidatePos, zeros(1,3), 0, 0, candidateGeometry, sensor, @gradientAscent, tc.comRange, ii, sprintf("Agent %d", ii));
|
||||||
|
|
||||||
% Make sure candidate agent doesn't collide with
|
% Make sure candidate agent doesn't collide with
|
||||||
% domain
|
% domain
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
function mustBeDcm(dcm)
|
|
||||||
% Assert 2D
|
|
||||||
assert(numel(size(dcm)) == 2, "DCM is not 2D");
|
|
||||||
% Assert square
|
|
||||||
assert(size(unique(size(dcm)), 1) == 1, "DCM is not a square matrix");
|
|
||||||
|
|
||||||
epsilon = 1e-9;
|
|
||||||
% Assert inverse equivalent to transpose
|
|
||||||
assert(all(abs(inv(dcm) - dcm') < epsilon, "all"), "DCM inverse is not equivalent to transpose");
|
|
||||||
% Assert determinant is 1
|
|
||||||
assert(det(dcm) > 1 - epsilon && det(dcm) < 1 + epsilon, "DCM has determinant not equal to 1");
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user