How to use pointAt() to point ground stations gimbals at different satellites at different time in satellite constellation to study link margin?

20 views (last 30 days)
I'm trying to study link budget of ground stations and satellite constellation.
I've gone through the exapmle "https://in.mathworks.com/help/satcom/ug/multihop-satellite-communication.html". This example shows one ground station (GS1) pointing at one satellite (sat1) and another ground station (GS2) at another satellite (sat2), and then calculating link margin from GS1 to GS2.
Im trying to extend this example by using satellite constellation where a ground station can use the presently visible satellite and switch to next one after the crossing of the satellite.
I've tried it using the below code
sc = satelliteScenario(startTime, stopTime, sampleTime, 'AutoSimulate',true);
plotRaditationPattern = true;
% Add ground stations
gsMumbai = groundStation(sc, 'Name', 'BOM GS', 'Latitude', 19.0760, 'Longitude', 72.8777); % Mumbai Ground Station
ueBengaluru = groundStation(sc, 'Name', 'BLR UE', 'Latitude', 12.9716, 'Longitude', 77.5946); % User Equipment in Bengaluru
% Add LEO satellite constellation (Keplerian elements)
numSatellites = 40;
semiMajorAxis = 7000e3 * ones(1, numSatellites); % Approximate altitude for LEO
eccentricity = zeros(1, numSatellites);
argumentOfPeriapsis = 13*ones(1, numSatellites);
trueAnomaly = linspace(0, 360, numSatellites); % Distribute satellites around the orbit
inclination = 40 * ones(1, numSatellites); % Common inclination for constellations
rightAscensionOfAscendingNode = linspace(0, 360, numSatellites);
[accessIntervalsGS2GS, acessGS2GS] = getSource2TargetPaths(gsMumbai, ueBengaluru, satArray, 1,false);
disp('Ground station to Ground Station Access Intervals with max 1 hop:');
disp(accessIntervalsGS2GS);
sc.AutoSimulate = false;
restart(sc);
disp(sc.SimulationStatus)
% Iterate over the simulation time and dynamically point the gimbal at the correct satellite
while sc.SimulationTime <= sc.StopTime
currentSimTime = sc.SimulationTime; % Get the current simulation time
% Check the access intervals to find the satellite that is visible at this time
for i = 1:height(accessIntervalsGS2GS)
% Get the access interval start and end times
intervalStart = accessIntervalsGS2GS(i, 4);
intervalEnd = accessIntervalsGS2GS(i, 5);
% If the current simulation time is within the access interval
if currentSimTime >= intervalStart.Variables && currentSimTime <= intervalEnd.Variables
% Get the satellite associated with this access interval using acessGS2GS
satID = acessGS2GS(i).Sequence(2); % Source asset ID (Satellite ID)
% Find the corresponding satellite object in satArray using the ID
for j = 1:numel(satArray)
if satArray(j).ID == satID
% Point the gimbal at the satellite
pointAt(gimbalGSMumbaitx, satArray(j));
pointAt(gimbalUErx, satArray(j));
break; % Stop after pointing at the correct satellite
end
end
end
end
% Update the simulation time step
if (sc.SimulationStatus ~= "Completed") && (seconds(sc.StopTime - sc.SimulationTime) > sc.SampleTime)
disp(sc.SimulationTime)
advance(sc);
else
break;
end
end
% restart(sc);
sc.AutoSimulate = true;
[linksIntervalsGS2GS, linksGS2GS] = getSource2TargetPathLinks(gsMumbai, ueBengaluru, satArray, 1, false);
disp('Ground station to Ground Station Access Intervals with max 1 hops:');
disp(linksIntervalsGS2GS);
However the pointAt() function causes the ground stations to point only at the last satellite, so for whole simulation they are pointing at only 1 satellite.
How to dynamically point ground stations to the passing satellites at different times of the simulations.?
This should give us link margin between the two ground stations all the time whenver a satellite connects to both the ground stations.
  2 Comments
Aravind
Aravind on 4 Oct 2024
The code you have provided fails to run as some of the variables and functions are not well defined. Could you please provide implementation details of the functions "getSource2TargetPaths" and "getSource2TargetPathLinks". Also, please provide the values for the missing variables like "startTime", "satArray", "stopTime", "sampleTime", etc. This will help in reproducing the issue so that I can try debugging it.
Ravi Raj Saxena
Ravi Raj Saxena on 4 Oct 2024
Edited: Ravi Raj Saxena on 10 Oct 2024
Hello Thanks a lot @Aravind for replying. In the question I only shared a part of the code I wanted to work on. I've shared all the related files here.
Please note that I've also tried by looping over the satellites to point the Ground station towards the satellite but that cause the Ground station to pointAT only at the last satellite in the loop.

Sign in to comment.

Accepted Answer

Aravind
Aravind on 30 Oct 2024
It seems you are encountering difficulties with the "pointAt" function in a loop, where you are adjusting the target at each simulation time step to point at the nearest satellite. I have managed to replicate the issue you are experiencing.
Upon reviewing your code, it appears the problem may stem from the repeated calls to the "pointAt" function within a loop. Since your goal is to dynamically change the satellites that the ground stations point to, you might consider using a "steeringtable" as a workaround. This will allow you to create a pointing schedule for the gimbals instead of repeatedly calling the "pointAt" function. More information can be found in the documentation here: https://www.mathworks.com/help/releases/R2022a/satcom/ref/matlabshared.satellitescenario.satellite.pointat.html#mw_a7e2d1e3-b588-465f-b127-28023bf685f4.
A "steeringtable" is a MATLAB "timetable" object containing the azimuth and elevation angles of the target that the gimbal is pointing to. You can use the table “accessIntervalsGS2GS” which is pre-calculated and contains the time interval and the target satellite, to populate the “steeringtable”. The azimuth and elevation angles of the satellite during that time interval can be calculated using the "aer" function. More details about the "aer" function can be found here: https://www.mathworks.com/help/releases/R2022a/satcom/ref/matlabshared.satellitescenario.satellite.aer.html.
By populating a "steeringtable," you can ensure that the ground station gimbals consistently point to the nearest satellite to establish a communication link. Once the "steeringtable" is created, you can pass it as an argument to the "pointAt" function, making the call only once rather than in a loop, thereby avoiding the previous issue.
Here are some documentation links and resources to help you get started with creating the "steeringtable":
  1. 1. MATLAB timetable: https://www.mathworks.com/help/releases/R2022a/matlab/ref/timetable.html
  2. 2. Overview of timetable in MATLAB: https://www.mathworks.com/help/releases/R2022a//matlab/timetables.html
  3. 3. A related MATLAB Answer where the "pointAt" function is used with a "timetable" object: https://www.mathworks.com/matlabcentral/answers/1943574-need-attitude-of-a-satellite-that-is-pointing-at-a-target
I hope this helps to resolve your issue.
  1 Comment
Ravi Raj Saxena
Ravi Raj Saxena on 18 Nov 2024 at 7:23
Edited: Ravi Raj Saxena on 18 Nov 2024 at 7:29
Hello,
Thanks a lot for your answer. The ground station is able to steer at different location at different times using the steering table created as mentinoed by you.
However, it is not pointing correctly to any satellite and keep moving somewhere else may be because of wrong azimuth and eleavation angles.
I've tried different way to calculate azimuth and elevation using aer function by interchaning asset, target and different coordinate frame however couldn't get succes. Below is the code I've tried
groundStation = gsMumbai; % Replace with the variable for BOM GS ground station
accessTable = accessIntervalsGS2GS2; % Replace with your modified access interval table
% Initialize the steering table
steeringTable = [];%table('Size', [0, 4], 'VariableTypes', {'datetime', 'double', 'double', 'string'},'VariableNames', {'Time', 'Azimuth', 'Elevation', 'SatelliteName'});
% Loop over each visibility interval to populate the steering table
for i = 1:height(accessTable)
startTime = accessTable.StartTime(i);
endTime = accessTable.EndTime(i);
satelliteName = accessTable.SatelliteHops{i};
% Find the satellite object based on the name (assumes unique satellite names)
satellite = getSatfromName(satelliteName, satArray); % satArray is your array of satellite objects
satRx = getCommDevice(satellite(1), 'GS', 'rx');
% Generate time samples within the interval
timeSamples = startTime:sampleTime:endTime;
% Calculate azimuth and elevation for each time sample
azimuth = zeros(length(timeSamples), 1);
elevation = zeros(length(timeSamples), 1);
for t = 1:length(timeSamples)
% Calculate AER (azimuth, elevation, range) from GS to satellite at each time sample
[azimuth(t), elevation(t), ~] = aer(satellite, groundStation, timeSamples(t), coordinateFrame='body');
end
% Add data to the steering table
tempTable = table(timeSamples', azimuth, elevation, {string(satelliteName(1))}, 'VariableNames', {'Time', 'Azimuth', 'Elevation', 'SatelliteName'});
steeringTable = [steeringTable; tempTable];
end
% Sort the table by Time
steeringTableSorted = sortrows(steeringTable, 'Time');
% Combine Azimuth and Elevation into a single [Azimuth, Elevation] vector
steeringTableSorted.AzimuthElevation = [steeringTableSorted.Azimuth, steeringTableSorted.Elevation];
steeringTable = removevars(steeringTableSorted, {'Azimuth', 'Elevation', 'SatelliteName'}); % Remove old columns
% Step 3: Convert to a timetable
steeringTimetable = table2timetable(steeringTable, 'RowTimes', 'Time');
pointAt(gimbalGSMumbaitx, steeringTimetable)

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!