How to change the colour of a ground station when a satellite accesses it? (Matlab Aerospace Toolbox)

36 Views Asked by At

Recently, I have been trying to use the Aerospace Toolbox for a university project and most of my code is ready to go. However, I would like to add an extra feature to make visualization easier. I want to know if there is any way I can change the colour of a ground station while the simulation is taking place and not before or after.

I have tried to set AutoSimulate to false so that I can use the advance (sc) command but so far, I have only managed for the station to be a different colour immediately after the simulation begins to run. My idea is that the colour changed once the satellite "accesses" it or gets close enough.

Here is the code:

startTime = datetime(2023,2,21,18,0,0);
stopTime = startTime + hours(1);
sampleTime = 60; % seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,'AutoSimulate',false);
GT = readgeotable("landareas.shp");
Eurasia=GT{2,1};
latlim = [35 43];
lonlim = [-10 3];
precision = 1;
gst = groundStation(sc,Name="Location to Photograph", ...
    Latitude=42.3001,Longitude=-71.3504,Altitude=-6378000);
sat(1) = satellite(sc,7000000,0,80, ...
        50,0,0);
        sat(1).ShowLabel=false;
g = gimbal(sat(1));
pointAt(g,gst);
camSensor = conicalSensor(g,MaxViewAngle=80);
%groundTrack(sat,LeadTime=3600);
%v = satelliteScenarioViewer(sc);
fieldOfView(camSensor);
k=0;
for i=latlim(1)+precision:precision:latlim(2)
    for j=lonlim(1)+precision:precision:lonlim(2)
        x=geopointshape(i,j);
        if 1==isinterior(Eurasia,x)
            k=k+1;
           gs(k) = groundStation(sc,i,j);
           gs(k).MarkerColor=[0 1 0];
           gs(k).ShowLabel=false;
        end
    end
end
ac = access(camSensor,gs(59));



while advance(sc)
    intvls = accessIntervals(ac);


end 
restart (sc)
while sc.SimulationTime<sc.StopTime
    if sc.SimulationTime>=intvls.StartTime
       gs(59).MarkerColor=[1 0 0]; 
    end 
    advance(sc)
end

play(sc)

(Note that I only want the colour of 1 ground station to change so that I know my code works)

0

There are 0 best solutions below