uc3m-aerospace / MOLTO-IT

Multi-Objective Low-Thrust Optimizer for Interplanetary Transfers
MIT License
33 stars 12 forks source link

Issues setting up install - leapseconds kernel not being correctly loaded #20

Closed TFT-Ben closed 3 years ago

TFT-Ben commented 4 years ago

Just setting up a default install and attempting to run the 'Ceres' example. Command is being run from the MOLTI-IT directory, if that matters.

Two observations: 1) running input.problem_name = example; generates an error: Unrecognized function or variable 'example'.

but more pressing, 2) upon configuring the input variable as given in the Ceres example, I get this:

SPICE(NOLEAPSECONDS): [str2et_c->STR2ET->TTRANS] 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.

Error in cspice_str2et (line 164)
      [et] = mice('str2et_c',str);

Error in fitness_nsga2 (line 79)
et0_min           = cspice_str2et(setup.t0_min);

Error in evaluate>evalIndividual (line 50)
[y, cons] = objfun( indi.var, varargin{:} );

Error in evaluate (line 28)
        [pop(i), allTime(i)] = evalIndividual(pop(i),
        opt.objfun, varargin{:});

Error in nsga2 (line 81)
[pop, state] = evaluate(opt, pop, state, varargin{:});

Error in molto_it (line 231)
    output = nsga2(options,input);

SPICE package has been installed as per instructions. Directory has the MOLTO-IT name, and should be seen by molto_it.m calling load_spice_kernels(input.spice_dir);. Input directory is set as default as input.spice_dir = '~/MOLTO-IT/spice'; and the directories have the correct names. For some reason, these files still aren't being seen. Any ideas?

It's been a while since I've seriously used MATLAB, so I apologise if I've missed something obvious.

TFT-Ben commented 4 years ago

Should probably mention I'm running on MATLAB R2020a

TFT-Ben commented 3 years ago

Briefly poking this, as revisited the package and still have the issue

su101195 commented 3 years ago

I am having similar issue as well. Any solutions to this?

BrandonEscamilla commented 3 years ago

Hi @TFT-Ben,

Sorry for the late response, can you tell me which operating system are you using?

BrandonEscamilla commented 3 years ago

Hi @su101195,

Can you tell me which operating system are you using?

TFT-Ben commented 3 years ago

Hi @BrandonEscamilla - I'm on Windows 10

BrandonEscamilla commented 3 years ago

ok, I think the problem is related to the relative path of the kernels. The version of this repo is working for Unix systems, so the path used won't work for you since it's hardcoded. I will work on a feature to use the correct path on both operating systems. In the meantime, you can always change the path directly in your local installation.

TFT-Ben commented 3 years ago

Thanks, I'll try and find the paths I need to set up manually. Failing that, I have a Ubuntu dual-boot I can try if it comes to it.

BrandonEscamilla commented 3 years ago

The path you need to change is under /molto_it/molto_it.m, there is a variable called input.spice_dir, there you can set the path to the kernels directly using the relative path of your OS

su101195 commented 3 years ago

Hi @BrandonEscamilla I am using Windows 10.

BrandonEscamilla commented 3 years ago

@TFT-Ben @su101195 Can you try to pull the changes I made to MOLTO, and try a clean installation again? I already fixed the paths problem, but I am not able to really test it, since I am not a Windows 10 user

su101195 commented 3 years ago

@BrandonEscamilla Cool. Would that mean redownloading the entire code? I am very new to Github. Thanks!

su101195 commented 3 years ago

@BrandonEscamilla Running input.problem_name = example; generates an error: Unrecognized function or variable 'example'.

BrandonEscamilla commented 3 years ago

@BrandonEscamilla Cool. Would that mean redownloading the entire code? I am very new to Github. Thanks!

You just need to use the command git fetch and after that the command git pull origin master

BrandonEscamilla commented 3 years ago

@BrandonEscamilla

Running input.problem_name = example; generates an error: Unrecognized function or variable 'example'.

@su101195 You need to run the file Examples.m which already has a mission example to Ceres, under MOLTO-IT/examples

su101195 commented 3 years ago

@BrandonEscamilla Thanks! I get the following error when I run Examples.m:

Undefined function or variable 'cspice_str2et'.

Error in fitness_nsga2 (line 79) et0_min = cspice_str2et(setup.t0_min);

Error in evaluate>evalIndividual (line 50) [y, cons] = objfun( indi.var, varargin{:} );

BrandonEscamilla commented 3 years ago

@BrandonEscamilla Thanks! I get the following error when I run Examples.m:

Undefined function or variable 'cspice_str2et'.

Error in fitness_nsga2 (line 79)

et0_min = cspice_str2et(setup.t0_min);

Error in evaluate>evalIndividual (line 50)

[y, cons] = objfun( indi.var, varargin{:} );

@su101195 Did you install spice in your local computer? Check if you have a folder called MOLTO-IT/Spice/mice

su101195 commented 3 years ago

@BrandonEscamilla Ah! I do not have that folder. But I am unable to download it either from the NAIF website. The link seems to be broken over there. Thanks!

BrandonEscamilla commented 3 years ago

@BrandonEscamilla Ah! I do not have that folder. But I am unable to download it either from the NAIF website. The link seems to be broken over there. Thanks!

I did have the same problem last time, try to open it using incognito mode, or use right click and click in the incognito option, let me know if that works

su101195 commented 3 years ago

@BrandonEscamilla Thanks for the suggestion! Right clicking and opening it in Incognito Mode worked. Will try to run the Examples.m script again now!

su101195 commented 3 years ago

@BrandonEscamilla The same error pops up. I have installed the mice folder in the spice folder.

BrandonEscamilla commented 3 years ago

Did you follow up the instructions in the read me file? And added the directory to the MATLAB path?

su101195 commented 3 years ago

@BrandonEscamilla Yes I did. The same error as described by @TFT-Ben pops up. Error using mice SPICE(NOLEAPSECONDS): [str2et_c->STR2ET->TTRANS] 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.

Error in cspice_str2et (line 164) [et] = mice('str2et_c',str);

BrandonEscamilla commented 3 years ago

@BrandonEscamilla Yes I did. The same error as described by @TFT-Ben pops up.

Error using mice

SPICE(NOLEAPSECONDS): [str2et_c->STR2ET->TTRANS] 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.

Error in cspice_str2et (line 164)

  [et] = mice('str2et_c',str);

Ok, @su101195 Can you provide me an screenshot of your spice directory structure? just to check it out, And also it could be useful if you can print the variables: kernels, mice_lib and mice_src, in the file spice/load_spice_kernels.m, and share them here

su101195 commented 3 years ago

@BrandonEscamilla Here you go: image

When I gave the path to the spice/mice folder I got the following error. So was unable to print the variables you requested: image

BrandonEscamilla commented 3 years ago

@su101195 I will check it out. I'll install a Windows Virtual Machine to test MOLTO, I will let you know if I find any issue to correctly setup MOLTO

BrandonEscamilla commented 3 years ago

Hi @su101195 I already try MOLTO-IT in a Windows 10 virtual machine, I had somes issues installing MOLTO but not related to the Kernels, I suggest you to double check your Matlab paths. I will let you the step by step I follow to make it work in Windows 10. It will be very detailed since some others users could find this information useful. I think this week I will update the README file to add this explanation.

  1. Install git from https://git-scm.com/

  2. Open CMD and Go to Documents (or the path you want to use)

  3. Captura

  4. Use git clone https://github.com/uc3m-aerospace/MOLTO-IT.git

  5. Enter the cloned directory 2

  6. Before running the code, SPICE/mice needs to be installed, go here and download mice.zip (if the link is not working use incognito mode), uncompress the folder in your downloads directory and copy the extracted directory called "mice"

  7. Go to Users/youruser/Documents/MOLTO-IT/spice and paste the copied directory ("mice") - your directory structrure now should look like this dir

  8. At this point, MOLTO-IT should work now, but there are some issues you will find even after the kernels of SPICE are loaded correctly.

  9. First, add the folder and subfolder paths of MOLTO-IT to Matlab, select all the folders within MOLTO-IT and follow the steps: Secondary click -> add path -> selected folders and subfolders path

  10. After adding the paths you need to solve an issue related to Windows 10, you need to rename a function called "propagate_spirals_mex" to "propagate_spirals" within the files "MOLTO-IT\molto_it\inner_loop\departure_cons.m" and "MOLTO-IT\molto_it\inner_loop\flyby_cons.m" (this function is called at least 2 times in every file)

  11. After these changes, you can go to the directory Examples using Matlab and run the file Examples.m, it should work now.

examples run

If you have any issue please let me know

su101195 commented 3 years ago

@BrandonEscamilla It works perfectly! Thanks for all the help. Any idea on how to obtain the DV for maneuver and final velocities? Is it possible to obtain the plots for the example cases as obtained in the research paper that was published? Also, I get the follwoing error when I run the example case for Pluto:

image

BrandonEscamilla commented 3 years ago

@su101195 when running a mission, you will notice a new directory called tmp, this directory is created to save all the data generated during the genetic algorithm runtime, so once you run a successful mission, there should be another directory with the name of your mission (input.problem_name) which is harcoded in the examples file. (ex. tmp/Ceres), this directory could have four types of files: gen[number].txt, Results_extendend.txt, Accel[number].eps, and Trajectory[number].eps, the latter two .eps files, are plots of the accel vs time, and other for the trajectory. To obtain both files, you need to change the input.plot value to 1 (default is 0), this should be done once you have ran a successful mission, this means you have a Results_extended.txt file within tmp/your_mission_name.

In the case of Pluto, it looks like you are trying to run the mission with the value input.plot as 1, before running the mission with the input.plot as 0, it's related to what I did mention just above. Double check input.plot in Pluto example.

If you have any problem let me know.

su101195 commented 3 years ago

@BrandonEscamilla Is it possible to plot the trajectory of the planets for a mission for better visualization? Currently I am getting plots such as below and I don't know what to interpret from this. Its for a Earth-Ceres mission. E-Ceres

TFT-Ben commented 3 years ago

Hi @su101195 I already try MOLTO-IT in a Windows 10 virtual machine, I had somes issues installing MOLTO but not related to the Kernels, I suggest you to double check your Matlab paths. I will let you the step by step I follow to make it work in Windows 10. It will be very detailed since some others users could find this information useful. I think this week I will update the README file to add this explanation.

1. Install git from https://git-scm.com/

2. Open CMD and Go to Documents (or the path you want to use)

3. ![Captura](https://user-images.githubusercontent.com/21966716/115161057-1b95b500-a061-11eb-95a2-dbe48b5bae80.PNG)

4. Use `git clone https://github.com/uc3m-aerospace/MOLTO-IT.git`

5. Enter the cloned directory
   ![2](https://user-images.githubusercontent.com/21966716/115161125-716a5d00-a061-11eb-9279-9a0f50c167dc.PNG)

6. Before running the code, SPICE/mice needs to be installed, go [here](https://naif.jpl.nasa.gov/naif/toolkit_MATLAB_PC_Windows_VisualC_MATLAB8.x_64bit.html) and download mice.zip (if the link is not working use incognito mode), uncompress the folder in your downloads directory and copy the extracted directory called "mice"

7. Go to Users/youruser/Documents/MOLTO-IT/spice and paste the copied directory ("mice") - your directory structrure now should look like this
   ![dir](https://user-images.githubusercontent.com/21966716/115161649-885e7e80-a064-11eb-91bc-b454efc05b8c.PNG)

8. At this point, MOLTO-IT should work now, but there are some issues you will find even after the kernels of SPICE are loaded correctly.

9. First, add the folder and subfolder paths of MOLTO-IT to Matlab, select all the folders within MOLTO-IT and follow the steps: Secondary click -> add path -> selected folders and subfolders
   ![path](https://user-images.githubusercontent.com/21966716/115161679-aa580100-a064-11eb-97aa-3c2fc99ecc94.PNG)

10. After adding the paths you need to solve an issue related to Windows 10, you need to rename a function called "propagate_spirals_mex" to "propagate_spirals" within the files "MOLTO-IT\molto_it\inner_loop\departure_cons.m" and "MOLTO-IT\molto_it\inner_loop\flyby_cons.m" (this function is called at least 2 times in every file)

11. After these changes, you can go to the directory Examples using Matlab and run the file Examples.m, it should work now.

examples run

If you have any issue please let me know

Hi Brandon.

I just followed this and now have a well functioning, healthy, running install! Thank you so much for your time, and thanks for writing one of the only toolkits doing this analysis!

Now to play with some configs and work out how to obtain dV estimates...

Cheers!

TFT-Ben commented 3 years ago

Just wondering, is there a description of the plot anywhere?

image

For instance, I assume solid lines are propulsive, dashed are coast - what are the solid and hollow points?

edit: additionally, what is the logic behind which trajectory gets selected for plotting? it is automatically shortest transfer/lowest propellant mass fraction?

Further question - is there a reasonable way to get burn duration out of the results data/acceleration plot?

Cheers

su101195 commented 3 years ago

@TFT-Ben The above plot is for an Earth- Jupiter trajectory??

TFT-Ben commented 3 years ago

@TFT-Ben The above plot is for an Earth- Jupiter trajectory??

No, Earth-Ceres, I was experimenting with different allowable flybys

su101195 commented 3 years ago

@TFT-Ben The above plot is for an Earth- Jupiter trajectory??

No, Earth-Ceres, I was experimenting with different allowable flybys

I see! Were you able to stabilize the plot windows. They seem to disappear as soon as it gets plotted. I have to everytime convert the .eps file to .jpg file to view them.

TFT-Ben commented 3 years ago

@TFT-Ben The above plot is for an Earth- Jupiter trajectory??

No, Earth-Ceres, I was experimenting with different allowable flybys

I see! Were you able to stabilize the plot windows. They seem to disappear as soon as it gets plotted. I have to everytime convert the .eps file to .jpg file to view them.

Nope, I just downloaded EPSviewer and open them separately

I did see that Brandon has some very impressive trajectory plots in his dissertation, including the planet trajectories, so maybe it's doable with some poking around

su101195 commented 3 years ago

@TFT-Ben The above plot is for an Earth- Jupiter trajectory??

No, Earth-Ceres, I was experimenting with different allowable flybys

I see! Were you able to stabilize the plot windows. They seem to disappear as soon as it gets plotted. I have to everytime convert the .eps file to .jpg file to view them.

Nope, I just downloaded EPSviewer and open them separately

I did see that Brandon has some very impressive trajectory plots in his dissertation, including the planet trajectories, so maybe it's doable with some poking around

Yes! I did see it in the research paper and I had asked him that question but not sure if he has seen this thread.

TFT-Ben commented 3 years ago

Yes! I did see it in the research paper and I had asked him that question but not sure if he has seen this thread.

Well this issue has gone a bit off topic now ;)

su101195 commented 3 years ago

Yes! I did see it in the research paper and I had asked him that question but not sure if he has seen this thread.

Well this issue has gone a bit off topic now ;)

true that!

BrandonEscamilla commented 3 years ago

Hi @TFT-Ben, @su101195,

I can see that both of you have more questions, and I am very happy you've found MOLTO useful for your use cases. Right now, there are more than 2 or 3 questions in this thread, and it's difficult to follow up on each of them.

It would be awesome if you can collect your last questions without answers and open different issues to them, so we can correctly follow up and close them. 🙏 Besides, I would like to clear out that this dissertation belongs to David Morante @dmoranteg, but during the last 2 years I've been working with him to bring a web interface to MOLTO to make it easier for everyone to play with different missions. That's why I can answer most of the questions, but there are some questions that the correct person to give an answer will be David. I will let him know about all these new open issues so he can also check them out. 😃

I would also like to invite you to contribute to MOLTO if you are in conditions to do so. Pull requests are always welcome as well as new ideas!

I will close this issue for now, and I will be very happy to answer the new individual issues.

Thank you! 🛰️