mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Added error checking codes to SpiceManager
Changed method to return instrument visibility by reference and used return value for errors
This commit is contained in:
@@ -260,8 +260,9 @@ public:
|
||||
* \param from The frame to be converted from
|
||||
* \param to The frame to be converted to
|
||||
* \param ephemerisTime Time at which to get rotational matrix that transforms vector
|
||||
* \return <code>true</code> if the conversion succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
void frameConversion(glm::dvec3& v, const std::string& from, const std::string& to, double ephemerisTime) const;
|
||||
bool frameConversion(glm::dvec3& v, const std::string& from, const std::string& to, double ephemerisTime) const;
|
||||
|
||||
/**
|
||||
* Finds the projection of one vector onto another vector.
|
||||
@@ -354,7 +355,8 @@ public:
|
||||
* \param method Type of shape model used for the target.
|
||||
* \param referenceFrame Body-fixed, body-centered frame for target body.
|
||||
* \param targetEpoch Time of the observation (seconds past J2000).
|
||||
* \return Visibility flag (SPICETRUE/SPICEFALSE).
|
||||
* \param isVisible <code>true</code> if the target is visible
|
||||
* \return The success of the function
|
||||
* For further detail, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovtrg_c.html
|
||||
*/
|
||||
@@ -364,7 +366,9 @@ public:
|
||||
const std::string& method,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const;
|
||||
double& targetEpoch,
|
||||
bool& isVisible
|
||||
) const;
|
||||
/**
|
||||
* This method performs the same computation as the function its overloading
|
||||
* with the exception that in doing so it assumes the inertial bodyfixed frame
|
||||
@@ -376,7 +380,9 @@ public:
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const;
|
||||
double& targetEpoch,
|
||||
bool& isVisible
|
||||
) const;
|
||||
|
||||
/**
|
||||
* Returns the state vector (<code>position</code> and <code>velocity</code>) of a
|
||||
|
||||
Submodule openspace-data updated: e32b0c3da7...c0b29e01ee
@@ -1,5 +1,8 @@
|
||||
openspace.setInvertRoll(true);
|
||||
|
||||
-- openspace.time.setTime("2007 FEB 27 16:30:00")
|
||||
-- openspace.time.setDeltaTime(50);
|
||||
|
||||
openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO
|
||||
-- NH takes series of images from visible to dark side (across terminator)
|
||||
-- Sequence lasts ~10 mins, (recommended dt = 10)
|
||||
|
||||
@@ -392,8 +392,8 @@ void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
|
||||
std::string _fovTarget = "";
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0]);
|
||||
if (_withinFOV){
|
||||
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0], _withinFOV);
|
||||
if (success && _withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -443,10 +443,10 @@ void RenderableFov::render(const RenderData& data){
|
||||
|
||||
_fovTarget = potential[0]; //default
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
_spacecraft, _method,
|
||||
_aberrationCorrection, _time);
|
||||
if (_withinFOV){
|
||||
_aberrationCorrection, _time, _withinFOV);
|
||||
if (success && _withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& fileP
|
||||
}
|
||||
FileSys.setCurrentDirectory(fileDirectory);
|
||||
|
||||
LINFO("Loading SPICE kernel '" << path << "'");
|
||||
// Load the kernel
|
||||
furnsh_c(path.c_str());
|
||||
|
||||
@@ -126,6 +127,7 @@ void SpiceManager::unloadKernel(KernelIdentifier kernelId) {
|
||||
|
||||
if (it != _loadedKernels.end()) {
|
||||
// No need to check for errors as we do not allow empty path names
|
||||
LINFO("Unloading SPICE kernel '" << it->path << "'");
|
||||
unload_c(it->path.c_str());
|
||||
_loadedKernels.erase(it);
|
||||
}
|
||||
@@ -142,6 +144,7 @@ void SpiceManager::unloadKernel(const std::string& filePath) {
|
||||
[&path](const KernelInformation& info) { return info.path == path; });
|
||||
|
||||
if (it != _loadedKernels.end()) {
|
||||
LINFO("Unloading SPICE kernel '" << path << "'");
|
||||
unload_c(path.c_str());
|
||||
_loadedKernels.erase(it);
|
||||
}
|
||||
@@ -243,7 +246,8 @@ bool SpiceManager::spacecraftClockToET(const std::string& craftIdCode, double& c
|
||||
int craftID;
|
||||
getNaifId(craftIdCode, craftID);
|
||||
sct2e_c(craftID, craftTicks, &et);
|
||||
return true;
|
||||
bool hasError = checkForError("Error transforming spacecraft clock of '" + craftIdCode + "' at time " + std::to_string(craftTicks));
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
bool SpiceManager::getETfromDate(const std::string& timeString,
|
||||
@@ -321,18 +325,22 @@ bool SpiceManager::getTargetPosition(const std::string& target,
|
||||
}
|
||||
|
||||
// do NOT remove this method.
|
||||
void SpiceManager::frameConversion(glm::dvec3& v, const std::string& from, const std::string& to, double ephemerisTime) const{
|
||||
bool SpiceManager::frameConversion(glm::dvec3& v, const std::string& from, const std::string& to, double ephemerisTime) const{
|
||||
glm::dmat3 transform;
|
||||
// get rotation matrix from frame A - frame B
|
||||
pxform_c(from.c_str(), to.c_str(), ephemerisTime, (double(*)[3])glm::value_ptr(transform));
|
||||
bool hasError = checkForError("Error converting from frame '" + from +
|
||||
"' to frame '" + to + "' at time " + std::to_string(ephemerisTime));
|
||||
if (hasError)
|
||||
return false;
|
||||
// re-express vector in new frame
|
||||
mxv_c((double(*)[3])glm::value_ptr(transform), glm::value_ptr(v), glm::value_ptr(v));
|
||||
return true;
|
||||
}
|
||||
|
||||
glm::dvec3 SpiceManager::orthogonalProjection(glm::dvec3& v1, glm::dvec3& v2){
|
||||
glm::dvec3 projected;
|
||||
vproj_c(glm::value_ptr(v1), glm::value_ptr(v2), glm::value_ptr(projected));
|
||||
|
||||
return projected;
|
||||
}
|
||||
|
||||
@@ -342,9 +350,12 @@ bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& method,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const{
|
||||
double& targetEpoch,
|
||||
bool& isVisible
|
||||
) const
|
||||
{
|
||||
|
||||
int visible ;
|
||||
int visible;
|
||||
fovtrg_c(instrument.c_str(),
|
||||
target.c_str(),
|
||||
method.c_str(),
|
||||
@@ -353,7 +364,12 @@ bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
observer.c_str(),
|
||||
&targetEpoch,
|
||||
&visible);
|
||||
return visible;
|
||||
isVisible = (visible == SPICETRUE);
|
||||
|
||||
bool hasError = checkForError("Checking if target '" + target +
|
||||
"' is in view of instrument '" + instrument + "' failed");
|
||||
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
@@ -361,7 +377,9 @@ bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const{
|
||||
double& targetEpoch,
|
||||
bool& isVisible
|
||||
) const{
|
||||
|
||||
int visible;
|
||||
|
||||
@@ -376,7 +394,12 @@ bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
observer.c_str(),
|
||||
&targetEpoch,
|
||||
&visible);
|
||||
return visible;
|
||||
isVisible = (visible == SPICETRUE);
|
||||
|
||||
bool hasError = checkForError("Checking if target '" + target +
|
||||
"' is in view of instrument '" + instrument + "' failed");
|
||||
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
|
||||
@@ -512,7 +535,7 @@ bool SpiceManager::getPositionPrimeMeridian(const std::string& fromFrame,
|
||||
|
||||
bool hasError = checkForError("Error retrieving position transform matrix from "
|
||||
"frame '" + fromFrame + "' to frame '" + body +
|
||||
"at time '" + std::to_string(ephemerisTime) + "'");
|
||||
"at time '" + std::to_string(ephemerisTime) + "' for prime meridian");
|
||||
positionMatrix = glm::transpose(positionMatrix);
|
||||
|
||||
return !hasError;
|
||||
@@ -544,7 +567,8 @@ bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
|
||||
|
||||
bool hasError = checkForError("Error retrieving position transform matrix from "
|
||||
"frame '" + fromFrame + "' to frame '" + toFrame +
|
||||
"' at time '" + std::to_string(ephemerisTimeTo) + "'");
|
||||
"' from time '" + std::to_string(ephemerisTimeFrom) + " to time '"
|
||||
+ std::to_string(ephemerisTimeTo) + "'");
|
||||
positionMatrix = glm::transpose(positionMatrix);
|
||||
|
||||
return !hasError;
|
||||
|
||||
Reference in New Issue
Block a user