Error Implementing parfor while creating satellite objects

조회 수: 4 (최근 30일)
Jon
Jon 2024년 3월 1일
댓글: Jon 2024년 3월 6일
I am having trouble parallelizing a working for loop that reads in TLE files to generate satellite objects via the Aerospace Toolbox.
StarlinkTLE=tleread('constellation.txt'); %pulls in TLEs from the attached "constellation.txt" file
load("FlightDataTimeTable.mat"); %pulls in a timetable with 10 sec increments and Lat/Long/Altitude of an aircraft
a=length(StarlinkTLE); %number of TLEs = number of Satellites...
[r,v]=propagateOrbit(datetime('now')+FlightDataTimeTable.Time,StarlinkTLE); %creates unique position and
% velocity for each satellite at each aircraft time increment, (I'm aware I'm not using v anyware later on yet)
mySatArr = cell(1,a); %placeholder cell structure to catch the satellites as they're made (included for parfor)
for ii=1:20 % 1:a satellites when parfor is working...
sat_pos=timetable(FlightDataTimeTable.Time,r(:,:,ii)'); %creates a position table to generate satellite object
try
mySatArr{ii}=satellite(sc,sat_pos,'Name',StarlinkTLE(ii).Name); %puts satellite object in mySatArr cell, and fixes name
catch
% An unknown # of the TLEs intersect the earth, and this leaves those
% cells empty
end
end
The parfor variation below kicks out the below error.
"Error using StarlinkConstellation
Invalid default value for property 'ColorConverter' in class 'matlabshared.satellitescenario.ScenarioGraphic':
The specified superclass 'matlab.graphics.internal.GraphicsBaseFunctions' contains a parse error, cannot be found
on MATLAB's search path, or is shadowed by another file with the same name."
StarlinkTLE=tleread('constellation.txt');
load("FlightDataTimeTable.mat");
a=length(StarlinkTLE);
[r,v]=propagateOrbit(datetime('now')+FlightDataTimeTable.Time,StarlinkTLE);
mySatArr = cell(1,a);
parfor ii=1:20 %only change to above code...
sat_pos=timetable(FlightDataTimeTable.Time,r(:,:,ii)');
try
mySatArr{ii}=satellite(sc,sat_pos,'Name',StarlinkTLE(ii).Name);
catch
end
end
The for loop finds the GraphicsBaseFunctions just fine, which tells me the constructor isn't missing...
>> which -all matlab.graphics.internal.GraphicsBaseFunctions
matlab.graphics.internal.GraphicsBaseFunctions is a built-in method % matlab.graphics.internal.GraphicsBaseFunctions constructor
I'm blindly guessing this is related to a single class constructor being reserved by the first worker, which is why the second worker tries and fails to use the built-in method, thus throwing the error.
Any help/guidance/sagely-smack-in-the-back-of-the-head is welcome.
Thanks for reading!

채택된 답변

Edric Ellis
Edric Ellis 2024년 3월 4일
I'm guessing you are trying to use this with a thread-based parallel pool. I had to add a line to your code to make it work, namely:
sc = satelliteScenario;
With this, I see that there is a problem when using a thread-base parallel pool, but that things work correctly if you use a process pool.
  댓글 수: 1
Jon
Jon 2024년 3월 6일
Thanks for the guidance! Didn't realize this was a thing, so I'll go dive into the parallel computing fundamentals to fix my knowledge gap....

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 CubeSat and Satellites에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by