From 38c754a4b549100ea0b43982491402fc763b3c82 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Thu, 6 Dec 2018 16:39:46 -0500 Subject: [PATCH 1/8] Added buffer for the positioning data and compensated for light travel time --- modules/dsn/managers/radecmanager.cpp | 82 +++++++++++++++------------ modules/dsn/managers/radecmanager.h | 9 ++- 2 files changed, 52 insertions(+), 39 deletions(-) diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index 97d1b53162..7ed065c452 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -33,14 +33,13 @@ namespace openspace { if (dictionary->hasKeyAndValue(KeyIdentifier)) { objectIdentifier = dictionary->value(KeyIdentifier); } - bool dataFilesSuccess = DataFileHelper::checkFileNames(identifier, dictionary, _dataFiles); return dataFilesSuccess; } bool RadecManager::correctHour(double time) const{ - const bool isTimeInFileInterval = (time >= _checkFileTime) && - (time < _checkFileTime + 3600); + const bool isTimeInFileInterval = (time >= _checkFileTime) && + (time < _checkFileEndTime); return isTimeInFileInterval; } @@ -53,8 +52,8 @@ namespace openspace { glm::vec3 RadecManager::getPosForTime(double time) const { if (!correctHour(time)) { std::vector timeDoubles = DataFileHelper::getHoursFromFileNames(_dataFiles); - int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles); - radecParser(idx); + int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles); + updateRadecData(idx); } if(!correctMinute(time)) { getPositionInVector(time); @@ -64,40 +63,19 @@ namespace openspace { bool RadecManager::radecParser(int index) const{ std::string filename; - - if (index == -1 || index > _dataFiles.size()) - return false; - filename = _dataFiles[index]; - - std::string startTimeString = DataFileHelper::getHourFromFileName(filename); - const double triggerTime = Time::convertTime(startTimeString); - - _checkFileTime = triggerTime; - std::ifstream ifs(filename); nlohmann::json j = nlohmann::json::parse(ifs); - RadecManager::Position position; - positions.clear(); - positions.reserve(0); - int objectCounter = 0; - - for (const auto& pos : j["Positions"]) { - objectCounter++; - try { - position.timeStamp = pos["TimeStamp"].get(); - position.ra = pos["RAUp"].get(); - position.dec = pos["DecUp"].get(); - position.range = pos["GeoRngUp"].get(); - } - catch (const std::exception& e) { - LERROR(fmt::format("{}: Error in json object number {} while reading file '{}'", objectIdentifier, objectCounter, filename)); - } - - RadecManager::positions.push_back(position); - } + for (const auto& pos : j["Positions"]) { + position.timeStamp = pos["TimeStamp"].get(); + position.ra = pos["RADn"].get(); + position.dec = pos["DecDn"].get(); + position.range = pos["GeoRngDn"].get(); + position.lightTravelTime = pos["DLT"].get(); + RadecManager::positions.push_back(position); + } return true; } @@ -108,9 +86,8 @@ namespace openspace { for (int i = 0; i < RadecManager::positions.size(); i++) { minuteTimes.push_back(Time::convertTime(positions[i].timeStamp)); } - int idx = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes); + int idx = DataFileHelper::findFileIndexForCurrentTime(time + position.lightTravelTime, minuteTimes);//Compensate for light travel time to the spacecraft activeMinute = minuteTimes[idx]; - position.timeStamp = positions[idx].timeStamp; position.ra = positions[idx].ra; position.dec = positions[idx].dec; @@ -118,6 +95,39 @@ namespace openspace { return position; } + + void RadecManager::updateRadecData(int index) const { + std::string filename; + int buffer = 1; + if (index == -1 || index > _dataFiles.size()) { + return; + } + positions.clear(); + positions.reserve(10); + + filename = _dataFiles[index]; + std::string startTimeString = DataFileHelper::getHourFromFileName(filename); + const double triggerTime = Time::convertTime(startTimeString); + + _checkFileTime = triggerTime; + _checkFileEndTime = triggerTime + 3600; + + if (index < buffer) { + radecParser(index); + radecParser(index + buffer); + return; + } + else if (index == _dataFiles.size() -1) { + radecParser(index - buffer); + radecParser(index); + return; + } + else { + radecParser(index - buffer); + radecParser(index); + radecParser(index + buffer); + } + } } diff --git a/modules/dsn/managers/radecmanager.h b/modules/dsn/managers/radecmanager.h index a9c41385d3..d0c4af3aa3 100644 --- a/modules/dsn/managers/radecmanager.h +++ b/modules/dsn/managers/radecmanager.h @@ -42,20 +42,21 @@ namespace openspace { mutable double ra; mutable double dec; mutable double range; + mutable double lightTravelTime; //Downlink light time travel time in seconds + }; mutable std::vector positions; mutable std::vector minuteTimes; mutable Position position; - mutable glm::vec3 currentMinute; mutable double activeMinute = 0; /* Identifier for object using the translation, used for logging */ std::string objectIdentifier; - /*Used to check if the loaded file is still relevant or if we should look for another one. */ mutable double _checkFileTime; + /*Time range for the files*/ + mutable double _checkFileEndTime; /* A vector with all our datafile paths*/ std::vector _dataFiles; - /* Extracts all the mandatory information we need from our asset file */ bool extractMandatoryInfoFromDictionary(const char* identifier, std::unique_ptr &dictionary); /*gets the correct datafile, that matches the current time in open space*/ @@ -68,6 +69,8 @@ namespace openspace { bool correctHour(double time) const; /*Check if current minute in open space is already loaded*/ bool correctMinute(double time) const; + /*Update and reate buffer of data so that we can compensate for light travel time without getting out of bounce*/ + void updateRadecData(int index) const; }; } From 9f7a0fd1993eaa61b2bd23b073ff1aa61b906ce1 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Thu, 6 Dec 2018 16:57:20 -0500 Subject: [PATCH 2/8] Fixed weird merge --- modules/dsn/managers/radecmanager.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index 7ed065c452..e12b337e08 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -67,13 +67,20 @@ namespace openspace { std::ifstream ifs(filename); nlohmann::json j = nlohmann::json::parse(ifs); + int objectCounter = 0; for (const auto& pos : j["Positions"]) { - position.timeStamp = pos["TimeStamp"].get(); - position.ra = pos["RADn"].get(); - position.dec = pos["DecDn"].get(); - position.range = pos["GeoRngDn"].get(); - position.lightTravelTime = pos["DLT"].get(); + objectCounter++; + try { + position.timeStamp = pos["TimeStamp"].get(); + position.ra = pos["RADn"].get(); + position.dec = pos["DecDn"].get(); + position.range = pos["GeoRngDn"].get(); + position.lightTravelTime = pos["DLT"].get(); + } + catch (const std::exception& e) { + LERROR(fmt::format("{}: Error in json object number {} while reading file '{}'", objectIdentifier, objectCounter, filename)); + } RadecManager::positions.push_back(position); } return true; From 4428abe9261b81d0a5df2dfb10e4a13c3db465f6 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Fri, 7 Dec 2018 11:41:04 -0500 Subject: [PATCH 3/8] buffer depending on light travel time --- modules/dsn/managers/radecmanager.cpp | 60 +++++++++++++++------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index e12b337e08..0be271ad4e 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -93,6 +93,7 @@ namespace openspace { for (int i = 0; i < RadecManager::positions.size(); i++) { minuteTimes.push_back(Time::convertTime(positions[i].timeStamp)); } + int idx = DataFileHelper::findFileIndexForCurrentTime(time + position.lightTravelTime, minuteTimes);//Compensate for light travel time to the spacecraft activeMinute = minuteTimes[idx]; position.timeStamp = positions[idx].timeStamp; @@ -104,36 +105,41 @@ namespace openspace { } void RadecManager::updateRadecData(int index) const { - std::string filename; - int buffer = 1; - if (index == -1 || index > _dataFiles.size()) { - return; - } - positions.clear(); - positions.reserve(10); + std::string filename; - filename = _dataFiles[index]; - std::string startTimeString = DataFileHelper::getHourFromFileName(filename); - const double triggerTime = Time::convertTime(startTimeString); + if (index == -1 || index > _dataFiles.size()) return; - _checkFileTime = triggerTime; - _checkFileEndTime = triggerTime + 3600; + positions.clear(); + positions.reserve(10); - if (index < buffer) { - radecParser(index); - radecParser(index + buffer); - return; - } - else if (index == _dataFiles.size() -1) { - radecParser(index - buffer); - radecParser(index); - return; - } - else { - radecParser(index - buffer); - radecParser(index); - radecParser(index + buffer); - } + filename = _dataFiles[index]; + std::string startTimeString = DataFileHelper::getHourFromFileName(filename); + const double triggerTime = Time::convertTime(startTimeString); + + _checkFileTime = triggerTime; + _checkFileEndTime = triggerTime + 3600; + + //Light travel time in hours determines where to search for the correct position + int lightTravelHours = ceil(position.lightTravelTime / 3600); + + if (lightTravelHours > 1) + index = index + lightTravelHours; + + if (index < lightTravelHours + 1) { + radecParser(index); + radecParser(index + 1); + return; + } + else if (index == _dataFiles.size() - lightTravelHours) { + radecParser(index); + radecParser(index -1); + return; + } + else { + radecParser(index - 1); + radecParser(index); + radecParser(index + 1); + } } } From cd4b9e77452c4eb3187cf59aa10ca55f0ccaed55 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Fri, 7 Dec 2018 14:49:19 -0500 Subject: [PATCH 4/8] Error message if no positioning data --- modules/dsn/translation/radectranslation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/dsn/translation/radectranslation.cpp b/modules/dsn/translation/radectranslation.cpp index 8d7770a63f..6d93f8341f 100644 --- a/modules/dsn/translation/radectranslation.cpp +++ b/modules/dsn/translation/radectranslation.cpp @@ -114,6 +114,12 @@ glm::dvec3 RadecTranslation::radecToCartesianCoordinates(glm::vec3 pos) const { glm::dvec3 RadecTranslation::position(const UpdateData& data) const{ glm::vec3 pos = radecManager.getPosForTime(data.time.j2000Seconds()); + + const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && + (data.time.j2000Seconds() < radecManager.timeDoubles.back()); + if (!haveDataForTime) { + LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); + } _position = radecToCartesianCoordinates(pos); return _position; } From 4f59d72cb5daaed3a1b7089d1847d2e6e41fef9b Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Fri, 7 Dec 2018 16:55:51 -0500 Subject: [PATCH 5/8] added stereo A with spice --- .../missions/dsn/spacecrafts.asset | 4 +- .../missions/dsn/stereoa/kernels.asset | 13 +++++ .../missions/dsn/stereoa/stereoa.asset | 51 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 data/assets/scene/solarsystem/missions/dsn/stereoa/kernels.asset create mode 100644 data/assets/scene/solarsystem/missions/dsn/stereoa/stereoa.asset diff --git a/data/assets/scene/solarsystem/missions/dsn/spacecrafts.asset b/data/assets/scene/solarsystem/missions/dsn/spacecrafts.asset index ca7a7a56f0..f3bb3519a8 100644 --- a/data/assets/scene/solarsystem/missions/dsn/spacecrafts.asset +++ b/data/assets/scene/solarsystem/missions/dsn/spacecrafts.asset @@ -4,6 +4,8 @@ asset.require('scene/solarsystem/missions/voyager1/voyager1') asset.require('scene/solarsystem/missions/voyager1/trails') asset.require('scene/solarsystem/missions/voyager2/voyager2') + -- added specifically for dsn visualization asset.require('scene/solarsystem/missions/dsn/mro/mro') -asset.require('scene/solarsystem/missions/dsn/marsodyssey/marsodyssey') \ No newline at end of file +asset.require('scene/solarsystem/missions/dsn/marsodyssey/marsodyssey') +asset.require('scene/solarsystem/missions/dsn/stereoa/stereoa') diff --git a/data/assets/scene/solarsystem/missions/dsn/stereoa/kernels.asset b/data/assets/scene/solarsystem/missions/dsn/stereoa/kernels.asset new file mode 100644 index 0000000000..2991dc31c6 --- /dev/null +++ b/data/assets/scene/solarsystem/missions/dsn/stereoa/kernels.asset @@ -0,0 +1,13 @@ +local Kernels = asset.syncedResource({ + Name = "StereoA Kernels", + Type = "HttpSynchronization", + Identifier = "stereoa_kernels", + Version = 1 +}) + +-- spk kernels +local StereoAKernels = { + Kernels .. '/STEREO_A_merged.bsp', +} + +asset.export("StereoAKernels", StereoAKernels) \ No newline at end of file diff --git a/data/assets/scene/solarsystem/missions/dsn/stereoa/stereoa.asset b/data/assets/scene/solarsystem/missions/dsn/stereoa/stereoa.asset new file mode 100644 index 0000000000..3f398bc4fd --- /dev/null +++ b/data/assets/scene/solarsystem/missions/dsn/stereoa/stereoa.asset @@ -0,0 +1,51 @@ +local assetHelper = asset.require('util/asset_helper') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') +local kernels = asset.require('./kernels') +local lights = asset.require('scene/solarsystem/general/lightsources') + +local models = asset.syncedResource({ + Name = "StereoA Kernels", + Type = "HttpSynchronization", + Identifier = "stereo_model", + Version = 1 +}) + +local StereoA = { + Identifier = "StereoA", + Parent = sunTransforms.SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "SpiceTranslation", + Target = "STEREO AHEAD", + Observer = "SUN", + Kernels = kernels.StereoAKernels + } + }, + GUI = { + Name = "Stereo A", + Path = "/Solar System/Missions/Stereo/Stereo A" + } +} + +local StereoAModel = { + Identifier = "StereoA_model", + Parent = StereoA.Identifier, + Renderable = { + Type = "RenderableModel", + Geometry = { + Type = "MultiModelGeometry", + GeometryFile = models .. "/Stereo_main.obj" + }, + ColorTexture = models .. "/texture.png", + LightSources = lights.StandardLights + }, + GUI = { + Name = "3D Model", + Path = "/Solar System/Missions/Stereo A" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, { + StereoA, + StereoAModel + }) From 99e1a91a9fe825e87fa0c910addfc79f10c44cee Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Fri, 7 Dec 2018 17:41:14 -0500 Subject: [PATCH 6/8] missed to commit, for the error message --- data/assets/scene/solarsystem/dsn/testRADEC.asset | 2 +- modules/dsn/managers/radecmanager.cpp | 2 +- modules/dsn/managers/radecmanager.h | 2 ++ modules/dsn/translation/radectranslation.cpp | 10 +++++----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/data/assets/scene/solarsystem/dsn/testRADEC.asset b/data/assets/scene/solarsystem/dsn/testRADEC.asset index cff63cfca7..a206342172 100644 --- a/data/assets/scene/solarsystem/dsn/testRADEC.asset +++ b/data/assets/scene/solarsystem/dsn/testRADEC.asset @@ -1,5 +1,5 @@ local assetHelper = asset.require('util/asset_helper') -local dataFolder = openspace.absPath("../../../sync/http/dsn_data/1/positioning/MRO") +local dataFolder = openspace.absPath("../../../sync/http/dsn_data/1/positioning/MRO_downlink") local models = asset.syncedResource({ Name = "Dsn models", diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index 0be271ad4e..e09647731c 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -51,7 +51,7 @@ namespace openspace { glm::vec3 RadecManager::getPosForTime(double time) const { if (!correctHour(time)) { - std::vector timeDoubles = DataFileHelper::getHoursFromFileNames(_dataFiles); + std::vectortimeDoubles = DataFileHelper::getHoursFromFileNames(_dataFiles); int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles); updateRadecData(idx); } diff --git a/modules/dsn/managers/radecmanager.h b/modules/dsn/managers/radecmanager.h index d0c4af3aa3..c092a14aef 100644 --- a/modules/dsn/managers/radecmanager.h +++ b/modules/dsn/managers/radecmanager.h @@ -57,6 +57,8 @@ namespace openspace { mutable double _checkFileEndTime; /* A vector with all our datafile paths*/ std::vector _dataFiles; + /* A vector with all our datafile times in j2000*/ + // mutable std::vector timeDoubles; /* Extracts all the mandatory information we need from our asset file */ bool extractMandatoryInfoFromDictionary(const char* identifier, std::unique_ptr &dictionary); /*gets the correct datafile, that matches the current time in open space*/ diff --git a/modules/dsn/translation/radectranslation.cpp b/modules/dsn/translation/radectranslation.cpp index 6d93f8341f..098e861cd7 100644 --- a/modules/dsn/translation/radectranslation.cpp +++ b/modules/dsn/translation/radectranslation.cpp @@ -115,11 +115,11 @@ glm::dvec3 RadecTranslation::radecToCartesianCoordinates(glm::vec3 pos) const { glm::dvec3 RadecTranslation::position(const UpdateData& data) const{ glm::vec3 pos = radecManager.getPosForTime(data.time.j2000Seconds()); - const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && - (data.time.j2000Seconds() < radecManager.timeDoubles.back()); - if (!haveDataForTime) { - LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); - } + //const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && + // (data.time.j2000Seconds() < radecManager.timeDoubles.back()); + //if (!haveDataForTime) { + // LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); + //} _position = radecToCartesianCoordinates(pos); return _position; } From f90f13e1e1a1ee826a89105838550de7d4c4597a Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Mon, 10 Dec 2018 12:13:58 -0500 Subject: [PATCH 7/8] fixed random crashing --- modules/dsn/managers/radecmanager.cpp | 17 ++++++++++------- modules/dsn/managers/radecmanager.h | 4 ++-- modules/dsn/translation/radectranslation.cpp | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index e09647731c..56a4eb542b 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -51,7 +51,8 @@ namespace openspace { glm::vec3 RadecManager::getPosForTime(double time) const { if (!correctHour(time)) { - std::vectortimeDoubles = DataFileHelper::getHoursFromFileNames(_dataFiles); + timeDoubles = DataFileHelper::getHoursFromFileNames(_dataFiles); + int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles); updateRadecData(idx); } @@ -105,9 +106,10 @@ namespace openspace { } void RadecManager::updateRadecData(int index) const { - std::string filename; + std::string filename; - if (index == -1 || index > _dataFiles.size()) return; + if (index < -1 || index > _dataFiles.size()) + return; positions.clear(); positions.reserve(10); @@ -123,23 +125,24 @@ namespace openspace { int lightTravelHours = ceil(position.lightTravelTime / 3600); if (lightTravelHours > 1) - index = index + lightTravelHours; + index = index + lightTravelHours; - if (index < lightTravelHours + 1) { + else if (index < 1) { radecParser(index); radecParser(index + 1); return; } - else if (index == _dataFiles.size() - lightTravelHours) { + else if (index == _dataFiles.size() -1) { radecParser(index); radecParser(index -1); return; } - else { + else{ radecParser(index - 1); radecParser(index); radecParser(index + 1); } + } } diff --git a/modules/dsn/managers/radecmanager.h b/modules/dsn/managers/radecmanager.h index c092a14aef..8f52f92909 100644 --- a/modules/dsn/managers/radecmanager.h +++ b/modules/dsn/managers/radecmanager.h @@ -48,7 +48,7 @@ namespace openspace { mutable std::vector positions; mutable std::vector minuteTimes; mutable Position position; - mutable double activeMinute = 0; + mutable double activeMinute; /* Identifier for object using the translation, used for logging */ std::string objectIdentifier; /*Used to check if the loaded file is still relevant or if we should look for another one. */ @@ -58,7 +58,7 @@ namespace openspace { /* A vector with all our datafile paths*/ std::vector _dataFiles; /* A vector with all our datafile times in j2000*/ - // mutable std::vector timeDoubles; + mutable std::vector timeDoubles; /* Extracts all the mandatory information we need from our asset file */ bool extractMandatoryInfoFromDictionary(const char* identifier, std::unique_ptr &dictionary); /*gets the correct datafile, that matches the current time in open space*/ diff --git a/modules/dsn/translation/radectranslation.cpp b/modules/dsn/translation/radectranslation.cpp index 098e861cd7..6d93f8341f 100644 --- a/modules/dsn/translation/radectranslation.cpp +++ b/modules/dsn/translation/radectranslation.cpp @@ -115,11 +115,11 @@ glm::dvec3 RadecTranslation::radecToCartesianCoordinates(glm::vec3 pos) const { glm::dvec3 RadecTranslation::position(const UpdateData& data) const{ glm::vec3 pos = radecManager.getPosForTime(data.time.j2000Seconds()); - //const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && - // (data.time.j2000Seconds() < radecManager.timeDoubles.back()); - //if (!haveDataForTime) { - // LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); - //} + const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && + (data.time.j2000Seconds() < radecManager.timeDoubles.back()); + if (!haveDataForTime) { + LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); + } _position = radecToCartesianCoordinates(pos); return _position; } From d9e2ed807042dbb6d999b369e8c64a0a99752a1c Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Mon, 10 Dec 2018 16:01:12 -0500 Subject: [PATCH 8/8] Speed up for when there's no RaDec data --- modules/dsn/translation/radectranslation.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/dsn/translation/radectranslation.cpp b/modules/dsn/translation/radectranslation.cpp index 6d93f8341f..b84123ce3d 100644 --- a/modules/dsn/translation/radectranslation.cpp +++ b/modules/dsn/translation/radectranslation.cpp @@ -65,8 +65,9 @@ RadecTranslation::RadecTranslation(const ghoul::Dictionary& dictionary) : RadecTranslation() { std::unique_ptr dictionaryPtr = std::make_unique(dictionary); - + extractData(dictionaryPtr); + radecManager.getPosForTime(0); documentation::testSpecificationAndThrow( Documentation(), @@ -113,15 +114,19 @@ glm::dvec3 RadecTranslation::radecToCartesianCoordinates(glm::vec3 pos) const { } glm::dvec3 RadecTranslation::position(const UpdateData& data) const{ - glm::vec3 pos = radecManager.getPosForTime(data.time.j2000Seconds()); - const bool haveDataForTime = (data.time.j2000Seconds() >= radecManager.timeDoubles.front()) && (data.time.j2000Seconds() < radecManager.timeDoubles.back()); + if (!haveDataForTime) { LDEBUG(fmt::format("No positioning data available for spacecraft: {}", radecManager.objectIdentifier.c_str())); + return radecToCartesianCoordinates({ 0,0,0 }); } - _position = radecToCartesianCoordinates(pos); - return _position; + else { + glm::dvec3 pos = radecManager.getPosForTime(data.time.j2000Seconds()); + _position = radecToCartesianCoordinates(pos); + return _position; + } + } } // namespace openspace