JuliaSpace / SatelliteToolbox.jl

A toolbox for satellite analysis written in julia language.
MIT License
249 stars 33 forks source link

Documentation out of date for init_orbit_propagator #51

Closed addifi closed 3 years ago

addifi commented 3 years ago

Example usage for init_orbit_propagator not working for julia 1.4 (does work in 1.2):

julia> tle_scd1 = tle"""
       SCD 1
       1 22490U 93009B   18350.91204528  .00000219  00000-0  10201-4 0  9996
       2 22490  24.9683 170.6788 0043029 357.3326 117.9323 14.44539175364603
       """[1];

julia> orbp = init_orbit_propagator(Val(:sgp4), tle_scd1);

Running this code results in error

julia> orbp = init_orbit_propagator(Val(:sgp4), tle_scd1);
ERROR: MethodError: no method matching init_orbit_propagator(::Val{:sgp4}, ::TLE)
Closest candidates are:
  init_orbit_propagator(::Type{Val{:J2}}, ::TLE) at /.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:219
  init_orbit_propagator(::Type{Val{:J2}}, ::TLE, ::J2_GravCte) at /.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:219
  init_orbit_propagator(::Type{Val{:J4}}, ::TLE) at /.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:266
  ...
Stacktrace:
 [1] top-level scope at none:0
ronisbr commented 3 years ago

Hi @addifi

I think you are using an old version of SatelliteToolbox.jl, can you please check if you are with the latest one? This code works perfectly here:

Captura de Tela 2021-02-21 às 19 09 24
ThatcherC commented 3 years ago

I actually get the same error with the latest SatelliteToolbox:

julia> using SatelliteToolbox

julia> tle = tle"""ZHUHAI-1 03A            
       1 44534U 19060A   21133.54533740  .00001252  00000-0  63266-4 0  9994
       2 44534  97.4348 243.6245 0015236  15.0533  80.6320 15.18815987 91379"""
1-element Vector{TLE}:
 TLE: ZHUHAI-1 03A (Epoch = 2021-05-13T13:05:17)

julia> tleprop = init_orbit_propagator(Val(:sgp4), tle[1]);
ERROR: MethodError: no method matching init_orbit_propagator(::Val{:sgp4}, ::TLE)
Closest candidates are:
  init_orbit_propagator(::Type{Val{:twobody}}, ::TLE) at /home/thatch/.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:300
  init_orbit_propagator(::Type{Val{:twobody}}, ::TLE, ::Number) at /home/thatch/.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:300
  init_orbit_propagator(::Type{Val{:sgp4}}, ::TLE) at /home/thatch/.julia/packages/SatelliteToolbox/0jge1/src/orbit/propagators/api/init_orbit_propagator.jl:333
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

julia> 

However, if I replace the parentheses around around :sgp4 with curly braces, everything works fine (this could be a workaround for the issue @addifi saw):

julia> tleprop = init_orbit_propagator(Val{:sgp4}, tle[1]);

julia> 

I remember a long time ago (a year and a half or so?) I had to use the Val{:sgp4} syntax, but at some point it switched to Val(:sgp4) which I think makes a bit more sense. Odd that it's switched back.

Is there any way the function could be rewritten so that you could pass the :sgp4 or :J2 etc. symbols to the function without wrapping it in a Val() or Val{}?

ronisbr commented 3 years ago

Hi @ThatcherC ,

I think you are using an old version of SatelliteToolbox. Can you please check which version is installed?

ronisbr commented 3 years ago

Probably your version of SatelliteToolbox.jl was downgraded due to some compatibility issue. Can you please run Pkg.update() and paste the result?

ThatcherC commented 3 years ago

Hi @ronisbr - I think you're right!

The output of my update commands didn't show me anything too helpful:

collapsed update output

``` (@v1.6) pkg> update Updating registry at `~/.julia/registries/General` Updating git-repo `https://github.com/JuliaRegistries/General.git` Updating git-repo `https://github.com/fonsp/Pluto.jl.git` Installed XML2_jll ────────── v2.9.12+0 Installed Libmount_jll ────── v2.35.0+0 Installed Libiconv_jll ────── v1.16.1+0 Installed PCRE_jll ────────── v8.44.0+0 Installed Libffi_jll ──────── v3.2.2+0 Installed ArrayInterface ──── v3.1.13 Installed Plots ───────────── v1.15.0 Installed FastBroadcast ───── v0.1.7 Installed LoopVectorization ─ v0.12.20 Downloaded artifact: XML2 Downloaded artifact: XML2 Downloaded artifact: PCRE Downloaded artifact: PCRE Downloaded artifact: Libffi Downloaded artifact: Libffi Downloaded artifact: Libmount Downloaded artifact: Libmount Downloaded artifact: Libiconv Downloaded artifact: Libiconv Updating `~/.julia/environments/v1.6/Project.toml` [91a5bcdd] ↑ Plots v1.14.0 ⇒ v1.15.0 [c3e4b0f8] ~ Pluto v0.14.5 `https://github.com/fonsp/Pluto.jl.git#main` ⇒ v0.14.5 `https://github.com/fonsp/Pluto.jl.git#main` Updating `~/.julia/environments/v1.6/Manifest.toml` [4fba245c] ↑ ArrayInterface v3.1.12 ⇒ v3.1.13 [7034ab61] ↑ FastBroadcast v0.1.6 ⇒ v0.1.7 [bdcacae8] ↑ LoopVectorization v0.12.19 ⇒ v0.12.20 [91a5bcdd] ↑ Plots v1.14.0 ⇒ v1.15.0 [c3e4b0f8] ~ Pluto v0.14.5 `https://github.com/fonsp/Pluto.jl.git#main` ⇒ v0.14.5 `https://github.com/fonsp/Pluto.jl.git#main` [e9f186c6] ↑ Libffi_jll v3.2.1+4 ⇒ v3.2.2+0 [94ce4f54] ↑ Libiconv_jll v1.16.0+7 ⇒ v1.16.1+0 [4b2f31a3] ↑ Libmount_jll v2.34.0+3 ⇒ v2.35.0+0 [2f80f16e] ↑ PCRE_jll v8.42.0+4 ⇒ v8.44.0+0 [02c8fc9c] ↑ XML2_jll v2.9.11+0 ⇒ v2.9.12+0 Progress [========================================>] 82/82 82 dependencies successfully precompiled in 157 seconds (201 already precompiled) julia> using Pkg julia> Pkg.update() Updating registry at `~/.julia/registries/General` Updating git-repo `https://github.com/JuliaRegistries/General.git` Updating git-repo `https://github.com/fonsp/Pluto.jl.git` No Changes to `~/.julia/environments/v1.6/Project.toml` No Changes to `~/.julia/environments/v1.6/Manifest.toml` julia> \```

But checking the status of my SatelliteToolbox install, it's pretty old:

(@v1.6) pkg> status SatelliteToolbox
      Status `~/.julia/environments/v1.6/Project.toml`
  [6ac157d9] SatelliteToolbox v0.6.2

Turns out it's the interaction between SatelliteToolbox and the LsqFit package that's causing this problem for me. I removed LsqFit, installed the latest STB with (@v1.6) pkg> add SatelliteToolbox@v0.8.0 and check it was up-to-date:

(@v1.6) pkg> status SatelliteToolbox
      Status `~/.julia/environments/v1.6/Project.toml`
  [6ac157d9] SatelliteToolbox v0.8.0

(looks great). When I then go to reinstall LsqFit, SatelliteToolbox gets knocked back a few versions for some reason:

(@v1.6) pkg> add LsqFit
   Resolving package versions...
    Updating `~/.julia/environments/v1.6/Project.toml`
  [a93c6f00] ↑ DataFrames v0.22.7 ⇒ v1.1.1
  [2fda8390] + LsqFit v0.12.0
  [6ac157d9] ↓ SatelliteToolbox v0.8.0 ⇒ v0.6.2
    Updating `~/.julia/environments/v1.6/Manifest.toml`
  [324d7699] - CategoricalArrays v0.9.7
  [a93c6f00] ↑ DataFrames v0.22.7 ⇒ v1.1.1
  [a98d9a8b] ↓ Interpolations v0.13.2 ⇒ v0.12.10
  [2fda8390] + LsqFit v0.12.0
  [e1d29d7a] ↑ Missings v0.4.5 ⇒ v1.0.0
  [87e2bd06] + OptimBase v2.0.1
  [fbd9d27c] ↓ OptionalData v0.3.0 ⇒ v0.2.1
  [3a141323] ↓ PolynomialRoots v1.0.0 ⇒ v0.2.0
  [08abe8d2] ↑ PrettyTables v0.11.1 ⇒ v1.0.1
  [189a3867] ↓ Reexport v1.0.0 ⇒ v0.2.0
  [74f56ac7] ↓ ReferenceFrameRotations v0.5.7 ⇒ v0.5.6
  [6ac157d9] ↓ SatelliteToolbox v0.8.0 ⇒ v0.6.2
  [a2af1166] ↑ SortingAlgorithms v0.3.1 ⇒ v1.0.0
  [90137ffa] ↓ StaticArrays v1.2.0 ⇒ v0.12.5
  [856f2bd8] - StructTypes v1.7.2
  Progress [========================================>]  68/68
68 dependencies successfully precompiled in 153 seconds (215 already precompiled)

Trying to again install the latest SatelliteToolbox after this provides a bit more info:

(@v1.6) pkg> add SatelliteToolbox@v0.8.0
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Reexport [189a3867]:
 Reexport [189a3867] log:
 ├─possible versions are: 0.2.0-1.0.0 or uninstalled
 ├─restricted by compatibility requirements with SatelliteToolbox [6ac157d9] to versions: 1.0.0
 │ └─SatelliteToolbox [6ac157d9] log:
 │   ├─possible versions are: 0.3.0-0.8.0 or uninstalled
 │   └─restricted to versions 0.8.0 by an explicit requirement, leaving only versions 0.8.0
 └─restricted by compatibility requirements with OptimBase [87e2bd06] to versions: 0.2.0 — no versions left
   └─OptimBase [87e2bd06] log:
     ├─possible versions are: 2.0.0-2.0.1 or uninstalled
     └─restricted by compatibility requirements with LsqFit [2fda8390] to versions: 2.0.0-2.0.1
       └─LsqFit [2fda8390] log:
         ├─possible versions are: 0.5.0-0.12.0 or uninstalled
         ├─restricted to versions * by an explicit requirement, leaving only versions 0.5.0-0.12.0
         └─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.11.0-0.12.0 or uninstalled, leaving only versions: 0.11.0-0.12.0
           └─Distributions [31c24e10] log:
             ├─possible versions are: 0.16.0-0.25.1 or uninstalled
             ├─restricted by compatibility requirements with LsqFit [2fda8390] to versions: 0.16.0-0.24.18
             │ └─LsqFit [2fda8390] log: see above
             ├─restricted by compatibility requirements with Symbolics [0c5d862f] to versions: 0.23.0-0.24.18
             │ └─Symbolics [0c5d862f] log:
             │   ├─possible versions are: 0.1.0-0.1.25 or uninstalled
             │   └─restricted to versions * by an explicit requirement, leaving only versions 0.1.0-0.1.25
             └─restricted by compatibility requirements with StaticArrays [90137ffa] to versions: [0.16.0-0.23.11, 0.24.5-0.25.1] or uninstalled, leaving only versions: [0.23.0-0.23.11, 0.24.5-0.24.18]
               └─StaticArrays [90137ffa] log:
                 ├─possible versions are: 0.8.0-1.2.0 or uninstalled
                 └─restricted by compatibility requirements with SatelliteToolbox [6ac157d9] to versions: 1.0.0-1.2.0
                   └─SatelliteToolbox [6ac157d9] log: see above

(@v1.6) pkg> 

It looks to be like LsqFit uses OptimBase, which is requiring a much older version of Reexport than SatelliteToolbox, so I guess this really isn't a SatelliteToolbox issue at all - OptimBase is just forcing the use of an old package. I might cross-post this issue on that repo and see if they'll update! For now I'll probably just make two separate Julia environments so I can use the latest SatelliteToolbox.

ronisbr commented 3 years ago

Yes! You found the problem :) I will close the bug, feel free to open if anything changes.

ThatcherC commented 3 years ago

Resolved by https://github.com/JuliaNLSolvers/OptimBase.jl/pull/15! Good to go