Matlab STK connection: How to access available existing objects?

조회 수: 39 (최근 30일)
Christina Jetzschmann
Christina Jetzschmann 2021년 10월 15일
이동: Walter Roberson 2024년 11월 7일
Dear all,
I am trying to command STK from Matlab. Connection is running well, but now I am seeking for how I access objects in an existing STK scneario. Everything I found in the internet is how to create a new object.
%%Open STK and Scenario
STK.app = actxserver('STK11.application');
STK.root = STK.app.Personality2;
checkempty = STK.root.Children.Count;
if checkempty == 0
%If a Scenario is not open, create a new scenario
STK.app.visible = 1;
else
%If a Scenario is open, prompt the user to accept closing it or not
rtn = questdlg({'Close the current scenario?',' ','(WARNING: If you have not saved your progress will be lost)'});
if ~strcmp(rtn,'Yes')
return
else
STK.root.CurrentScenario.Unload
STK.app.visible = 1;
end
end
%%Get current working folder path
currentFolder = pwd;
%Define STK scenario name (already existing scenario)
STK.scenario.name = append(pwd,'\Test_Mission\Test_Mission.sc');
%Load STK scenario (must be located in the working path)
scenario = STK.root.LoadScenario(STK.scenario.name);
%%Extract scenario data
% Here I want to get information of a ground station and later also a
% satellite in order to calculate e.g. access
Redu_Station = STK.root.GetObjectFromPath('.\Test_Mission\Redu_Station.f');
%...
%%Leave STK scenario and instance
%Close the scenario
STK.root.CloseScenario;
%Close STK instance
STK.app.Quit;
The error message is:
Check for missing argument or incorrect argument data type in call to function 'GetObjectFromPath'.
Unfortunately I do not find any description for the different funcions and how to use them.
Please help me!
Christina
  댓글 수: 12
Troy McClure
Troy McClure 2023년 11월 6일
이동: Walter Roberson 2024년 11월 7일
Ever find the answer to this? I'm having the same issue. The docs don't explain how to build the path.
Christina Jetzschmann
Christina Jetzschmann 2023년 11월 17일
이동: Walter Roberson 2024년 11월 7일
See answer below...

댓글을 달려면 로그인하십시오.

답변 (2개)

Christina Jetzschmann
Christina Jetzschmann 2023년 11월 17일
For me, this solution is now working:
%% Open STK and Scenario
STK.app = actxserver('STK11.application');
STK.root = STK.app.Personality2;
checkempty = STK.root.Children.Count;
if checkempty == 0
% If a Scenario is not open, create a new scenario
STK.app.visible = 1;
else
% If a Scenario is open, prompt the user to accept closing it or not
rtn = questdlg({'Close the current scenario?',' ','(WARNING: If you have not saved your progress will be lost)'});
if ~strcmp(rtn,'Yes')
return
else
STK.root.CurrentScenario.Unload
STK.app.visible = 1;
end
end
%% Get current working folder path
currentFolder = pwd;
% Define STK scenario name (already existing scenario)
STK.scenario.name = append(pwd,'\Test_Mission\Test_Mission.sc');
% Load STK scenario (must be located in the working path)
scenario = STK.root.LoadScenario(STK.scenario.name);
%% Create handler
% Create handler for spacecraft by using path
handler.MySat = STK.root.GetObjectFromPath('/Satellite/MySat');
% Create handler for facility by using path
handler.Redu_Station= STK.root.GetObjectFromPath('/Facility/Redu_Station');
% Create handler for sensor on spacecraft by using path
handler.MySat_Sensor= STK.root.GetObjectFromPath('/Satellite/MySat/Sensor/Sensor1');
%% Define overall stepsize in [s]
stepsize = 60;
%% Create access
% Define ground station and spacecraft of interest for access calculations.
facility = handler.Redu_Station;
spacecraft = handler.MySat;
sensor = handler.MySat_Sensor;
access_name = 'Redu_Station2MySat_access';
% Call access function (incl. intervals, statistics and AER)
Redu_Station2MySat_access = STKaccess(facility, spacecraft,scenario,stepsize);
Redu_Station2Sensor1_access = STKaccess(facility, sensor,scenario,stepsize);
% ...
%% Leave STK scenario and instance
% Close the scenario
STK.root.CloseScenario;
% Close STK instance
STK.app.Quit;

john
john 2024년 11월 7일
The way I got valid path names for GetObjectFromPath was:
STK.root.AllInstanceNamesToXML
and it prints all the available objects in the scenario.

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by