Matlab STK connection: How to access available existing objects?

60 visualizaciones (últimos 30 días)
Christina Jetzschmann
Christina Jetzschmann el 15 de Oct. de 2021
Movida: Walter Roberson el 7 de Nov. de 2024
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 comentarios
Troy McClure
Troy McClure el 6 de Nov. de 2023
Movida: Walter Roberson el 7 de Nov. de 2024
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 el 17 de Nov. de 2023
Movida: Walter Roberson el 7 de Nov. de 2024
See answer below...

Iniciar sesión para comentar.

Respuestas (2)

Christina Jetzschmann
Christina Jetzschmann el 17 de Nov. de 2023
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 el 7 de Nov. de 2024
The way I got valid path names for GetObjectFromPath was:
STK.root.AllInstanceNamesToXML
and it prints all the available objects in the scenario.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by