Skip to content

Commit

Permalink
Merge branch 'delay_simulink_load' of https://github.com/RussTedrake/…
Browse files Browse the repository at this point in the history
…drake

Conflicts:
	cmake
  • Loading branch information
RussTedrake committed Apr 27, 2015
2 parents 4b40b70 + 584bd80 commit 133be13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions systems/@DynamicalSystem/DynamicalSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
inport = find_system(mdl,'SearchDepth',1,'BlockType','Inport');
ts = [];
for i=1:length(inport)
ts = [ts,Simulink.Block.getSampleTimes(inport{i}).Value'];
ts = [ts,getSimulinkSampleTimes(inport{i})];
end
end
function ts = getOutputSampleTimes(obj)
Expand All @@ -380,7 +380,7 @@
outport = find_system(mdl,'SearchDepth',1,'BlockType','Outport');
ts = [];
for i=1:length(outport)
ts = [ts,Simulink.Block.getSampleTimes(outport{i}).Value'];
ts = [ts,getSimulinkSampleTimes(outport{i})];
end
end

Expand Down Expand Up @@ -652,7 +652,7 @@
if (nargin<3) mdl = getModel(obj); end

if (isempty(obj.structured_x))
obj.structured_x = Simulink.BlockDiagram.getInitialState(mdl.name);
obj.structured_x = getSimulinkStateStructure(mdl.name);
end
xs = obj.structured_x;
if (length(xs.signals)>1)
Expand Down
1 change: 1 addition & 0 deletions util/force_close_system.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function force_close_system(sys)
end
elseif ischar(sys)
if (strcmpi(sys,'all'))
if isempty(license('inuse','simulink')), return; end % don't load simulink if it's not loaded already
force_close_system(find_system('SearchDepth',0));
else
try
Expand Down
6 changes: 6 additions & 0 deletions util/getSimulinkSampleTimes.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function ts = getSimulinkSampleTimes(ref)
% Note: this used to be inside DynamicalSystem.stateVectorToStructure, but
% having it there caused simulink to be loaded ( see
% https://github.com/RobotLocomotion/drake/issues/1044 )

ts = Simulink.Block.getSampleTimes(ref).Value';
8 changes: 8 additions & 0 deletions util/getSimulinkStateStructure.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function x_struct = getSimulinkStateStructure(mdl)
% Note: this used to be inside DynamicalSystem.stateVectorToStructure, but
% having it there caused simulink to be loaded ( see
% https://github.com/RobotLocomotion/drake/issues/1044 )

x_struct = Simulink.BlockDiagram.getInitialState(mdl);


0 comments on commit 133be13

Please sign in to comment.