Tudat / tudat

NOTE: This Tudat version is no longer supported. See https://docs.tudat.space/en/stable/ and https://github.com/tudat-team/tudat-bundle for the new version
BSD 3-Clause "New" or "Revised" License
87 stars 143 forks source link

Exception of Leapseconds raised in accessing SPICE toolbox from Windows Mingw compiler #653

Closed pavan8k closed 4 years ago

pavan8k commented 4 years ago

Hello, I have noticed one small issue when I was working with an example tutorial for singlePerturbedSatellitePropagator .

File I was working on is with the following lines added to the above example :

using namespace tudat::spice_interface;
// Load Spice kernels.
spice_interface::loadStandardSpiceKernels( );
printf("%d\n",spice_interface::getTotalCountOfKernelsLoaded() ); // output is always 4

// Set simulation time settings.
const double simulationStartEpoch = convertdateStringToEphemerisTime("2020 June 13, 3:29:48");
const double simulationEndEpoch =  convertdateStringToEphemerisTime("2020 June 14, 3:29:48");

While compiling the above code in Windows with mingw 7.3.0 64 bit C++ compiler, I got the following exception. It should also be noted, the same exception didn't come in Ubuntu with gcc C++ 64 bit compiler and the conversion to Ephemeris Time from the above string format was successful in Ubuntu.

SPICE(NOLEAPSECONDS) -- The variable that points to the leapseconds (DELTET/DELTA_AT) could not be located in the kernel pool. It is likely that the leapseconds kernel has not been loaded via the routine FURNSH. str2et_c --> STR2ET --> TTRANS In all the cases the output of getTotalCountOfKernelsLoaded() was 4 implying that all the kernels were loaded successfully.

Possible fix ??

Looking at the Spice documentation, I noticed that in many examples, leapseconds.tls was loaded prior to the ephemeris binar file *.bsp, so I changed the spice interface file in Tudat so that the leapsecond file of naif0012.tls is loaded first.

void loadStandardSpiceKernels( const std::vector< std::string > alternativeEphemerisKernels  )
{
    std::string kernelPath = input_output::getSpiceKernelPath( );

    loadSpiceKernelInTudat( kernelPath + "naif0012.tls" );
    loadSpiceKernelInTudat( kernelPath + "pck00010.tpc" );
    loadSpiceKernelInTudat( kernelPath + "gm_de431.tpc" );

    if( alternativeEphemerisKernels.size( ) == 0  )
    {
        loadSpiceKernelInTudat( kernelPath + "tudat_merged_spk_kernel.bsp" );
    }
    else
    {
        for( unsigned int i = 0; i < alternativeEphemerisKernels.size( ); i++ )
        {
            loadSpiceKernelInTudat( alternativeEphemerisKernels.at( i ) );
        }
    }
}

Then, the conversion to Ephemeris time from the above string format was proper and there was no exception raised by the Spice in both Windows and Ubuntu environments with mingw and g++ compilers respectively

My question is that, whatever I attempted is that the correct fix or am I losing something if I load naif0012.tls before the merged ephemeris file tudat_merged_spk_kernel.bsp ?

Kindly note: I followed the installation procedures as recommended in your documentation for both Ubuntu and Windows environments. Thanks, Pavan.

DominicDirkx commented 4 years ago

HI Pavan,

Thanks for opening and fixing this issue :) There should be no issue with changing the order of the loading of the kernels. It's odd that it's never happened before, but good to know that this is a fix,

Best,

Dominic

pavan8k commented 4 years ago

Hi Dominic, Thanks for the reply. If you could incorporate this fix in the next commit, it will be very useful in case someone faces a similar situation in Windows. Regards, Pavan.

DominicDirkx commented 4 years ago

Hi Pavan,

We're currently in the process of a very thorough restructuring of Tudat, including the way in which we manage files, and the manner in which we link spice. This issue will also be brought to the table during that process. Thanks for your contribution!

Best,

Dominic