Skip to content

Commit

Permalink
make sure tle is fresh during simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Mar 11, 2024
1 parent 77d76e4 commit 02abbab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package ru.r2cloud.simulation;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.FileSystems;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;

Expand Down Expand Up @@ -37,9 +41,11 @@ public static void main(String[] args) throws Exception {

AntennaConfiguration antenna = new AntennaConfiguration();
antenna.setType(AntennaType.FIXED_DIRECTIONAL);
antenna.setAzimuth(34);
antenna.setElevation(55.0);
antenna.setAzimuth(270);
antenna.setElevation(30.0);
antenna.setBeamwidth(45);
// capture 4 minutes min
long minimumObservationMillis = 4 * 60 * 1000;
Configuration config;
File userSettingsLocation = new File("target/.r2cloud-" + UUID.randomUUID().toString());
try (InputStream is = BaseTest.class.getClassLoader().getResourceAsStream("config-dev.properties")) {
Expand All @@ -57,23 +63,26 @@ public static void main(String[] args) throws Exception {
PredictOreKit predict = new PredictOreKit(config);

SimpleDateFormat sdf = createFormatter();
long current = sdf.parse("2022-07-19 18:47:32").getTime();
long current = sdf.parse("2020-09-27 18:47:32").getTime();

CelestrakClient client = new CelestrakClient(config, new FixedClock(current));

Map<String, Tle> tles = client.downloadTle();
Set<String> supported = loadLeoSatellites("70cm-satellites.txt");

int maxOutput = 50;
int currentOutput = 0;

JsonArray ds = new JsonArray();
for (Tle cur : tles.values()) {
if (!supported.contains(cur.getRaw()[0])) {
continue;
}
TLEPropagator propagator = TLEPropagator.selectExtrapolator(new org.orekit.propagation.analytical.tle.TLE(cur.getRaw()[1], cur.getRaw()[2]));
List<SatPass> schedule = predict.calculateSchedule(antenna, new Date(current), propagator);
for (SatPass curPass : schedule) {
// capture 4 minutes min
long length = curPass.getEndMillis() - curPass.getStartMillis();
if (length < 4 * 60 * 1000) {
if (length < minimumObservationMillis) {
continue;
}
ds.add(output(curPass, predict, propagator, currentOutput));
Expand Down Expand Up @@ -125,6 +134,17 @@ private static JsonObject output(SatPass pass, PredictOreKit predict, TLEPropaga
return ds;
}

private static Set<String> loadLeoSatellites(String file) throws Exception {
Set<String> result = new HashSet<>();
try (BufferedReader r = new BufferedReader(new InputStreamReader(FixedDirectionalAntennaTest.class.getClassLoader().getResourceAsStream(file)))) {
String curLine = null;
while ((curLine = r.readLine()) != null) {
result.add(curLine.trim());
}
}
return result;
}

private static String generateColor(int hash) {
StringBuilder result = new StringBuilder();
result.append("#");
Expand Down
10 changes: 3 additions & 7 deletions src/test/java/ru/r2cloud/simulation/UtilizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public static void main(String[] args) throws Exception {
// config.setProperty("rotator.enabled", false);

SimpleDateFormat sdf = createFormatter();
long current = sdf.parse("2022-07-19 18:47:32").getTime();
long start = sdf.parse("2022-07-19 18:47:32").getTime();
long end = sdf.parse("2022-07-21 18:47:32").getTime(); // +2 days
long current = sdf.parse("2020-09-27 18:47:32").getTime();
long start = sdf.parse("2020-09-27 18:47:32").getTime();
long end = sdf.parse("2020-09-29 18:47:32").getTime(); // +2 days

CelestrakServer celestrak = new CelestrakServer();
celestrak.start();
Expand Down Expand Up @@ -129,10 +129,6 @@ private static SimpleDateFormat createFormatter() {
private static List<Transmitter> getDefaultEnabled(SatelliteDao dao) {
List<Transmitter> result = new ArrayList<>();
for (Satellite cur : dao.findEnabled()) {
// this satellite can't be visible on the tested ground station
if (cur.getId().equals("44365") || cur.getId().equals("44832")) {
continue;
}
result.addAll(cur.getTransmitters());
}
return result;
Expand Down

0 comments on commit 02abbab

Please sign in to comment.