Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/Support/bskReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Version |release|
:ref:`scenarioPrescribedMotionWithTranslationBranching` and :ref:`scenarioPrescribedMotionWithRotationBranching`.
- Fixed a bug where :ref:`spinningBodyOneDOFStateEffector` and :ref:`spinningBodyNDOFStateEffector`
both registered their states under the same name, resulting in overwriting and a ``BSK_ERROR``.
- Prevent the same SPICE kernel from being loaded multiple times in :ref:`spiceInterface`.


Version 2.8.0 (August 30, 2025)
Expand Down
29 changes: 29 additions & 0 deletions src/simulation/environment/spiceInterface/spiceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ void SpiceInterface::pullSpiceData(std::vector<SpicePlanetStateMsgPayload> *spic
}
}

const int MAXLEN = 256;

/*! This method loads a requested SPICE kernel into the system memory. It is
its own method because we have to load several SPICE kernels in for our
application. Note that they are stored in the SPICE library and are not
Expand All @@ -439,6 +441,33 @@ int SpiceInterface::loadSpiceKernel(char *kernelName, const char *dataPath)
char *fileName = new char[this->charBufferSize];
SpiceChar *name = new SpiceChar[this->charBufferSize];

// Check if the kernel is already loaded
SpiceChar fileCompare [MAXLEN];
SpiceChar filtyp [MAXLEN];
SpiceChar srcfil [MAXLEN];
SpiceInt handle;
SpiceBoolean found = SPICEFALSE;
SpiceInt total_kernels;
ktotal_c( "ALL", &total_kernels );

for (SpiceInt i = 0; i < total_kernels; i++ )
{
// Get the i-th loaded kernel information
kdata_c(i, "ALL", MAXLEN, MAXLEN, MAXLEN, fileCompare, filtyp, srcfil, &handle, &found);

if (found){
// Check if kernelName is at the end of the file string
size_t fileLen = strlen(fileCompare);
size_t kernelLen = strlen(kernelName);
if (fileLen >= kernelLen &&
strcmp(fileCompare + fileLen - kernelLen, kernelName) == 0)
{
// The kernel_to_check has already been successfully loaded
return 0;
}
}
}

//! - The required calls come from the SPICE documentation.
//! - The most critical call is furnsh_c
strcpy(name, "REPORT");
Expand Down
Loading