RoboticExplorationLab / KSLowThrust

MIT License
5 stars 0 forks source link

Expected RobotDynamics.QuadratureRule, got Type{RobotDynamics.RK4} #1

Open louk-spaceman opened 9 months ago

louk-spaceman commented 9 months ago

I received this error:

ERROR: LoadError: TypeError: in keyword argument integration, expected RobotDynamics.QuadratureRule, got Type{RobotDynamics.RK4}
Stacktrace:
 [1] top-level scope
   @ ~/TrajectoryCalculations/KSLowThrust/conference_examples/60_day_transfer.jl:94

Not sure what went wrong here, but I think it's something to do with new versions of all the Julia packages KSLowThrust depends on. I've tried a few things, and seemingly made some progress, but haven't been able to actually solve the issue. For one, I tried formatting things a little differently to match the new style which seems to be that you exchange:

prob = Problem(model, obj,xf, tf, x0=x0, constraints=cons,integration=RD.RK4)

for:

integration = RD.RK4
prob = Problem(model, obj,xf, tf, x0=x0, constraints=cons,integration=integration(model))

But then this gives me a new error:

ERROR: LoadError: NotImplementedError: state_dim needs to be implemented for KSopt.
Stacktrace:
 [1] state_dim(fun::KSopt)
   @ RobotDynamics ~/.julia/packages/RobotDynamics/baZMh/src/functionbase.jl:131
 [2] RobotDynamics.RK4(model::KSopt)
   @ RobotDynamics ~/.julia/packages/RobotDynamics/baZMh/src/discretized_dynamics.jl:104
 [3] top-level scope
   @ ~/TrajectoryCalculations/KSLowThrust/conference_examples/60_day_transfer.jl:95

So I dealt with this by giving it what it wanted (with more or less random values to just see if I could get the code to run):

RD.state_dim(::KSopt) = 14,3
RD.control_dim(::KSopt) = 14,3

Which seemed to cause that error to go away, but it was replaced with a new one:

ERROR: LoadError: MethodError: no method matching RobotDynamics.RK4(::Tuple{Int64, Int64}, ::Tuple{Int64, Int64})

Closest candidates are:
  RobotDynamics.RK4(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
   @ RobotDynamics ~/.julia/packages/RobotDynamics/baZMh/src/integration.jl:259

Stacktrace:
 [1] RobotDynamics.RK4(model::KSopt)
   @ RobotDynamics ~/.julia/packages/RobotDynamics/baZMh/src/discretized_dynamics.jl:104
 [2] top-level scope
   @ ~/TrajectoryCalculations/KSLowThrust/conference_examples/60_day_transfer.jl:97

Any clue what the solution to all this is? Any help would be greatly appreciated! I believe once this issue is resolved, the codebase would be more or less updated to work with the newest versions of all its dependencies, so it may be a worthy pursuit.

kevin-tracy commented 9 months ago

This is a really painful issue that is caused by the broken ecosystem of TrajectoryOptimization.jl, RobotDynamics.jl and Altro.jl. You may keep running into issues, i'm really sorry about this. When I wrote this, all of these packages were in development.

Are you activating the environment in the root directory? In theory this should have all the correct versions saved, I think I was using Julia 1.5.4 at the time (https://julialang.org/downloads/oldreleases/).

kevin-tracy commented 9 months ago

If you want to keep trying your current method, try this:

RD.state_dim(::KSopt) = 14
RD.control_dim(::KSopt) = 3
louk-spaceman commented 9 months ago

Hi Kevin, thanks for your response! I'm not a Julia expert, so bear with me, but when I tried to instantiate the KSLowThrust package, it failed to precompile about half of the dependencies. I had to manually Pkg.add() a lot of them from their respective GitHub repositories. I think this process gave me the newest versions, rather than the ones specified in the manifest. I will see if I can't try running this using an older version of Julia, and report back. Perhaps that is the reason instantiation failed.

Trying your values for state_dim and control_dim, unfortunately I received another error – although, it was different, at least!

ERROR: LoadError: MethodError: no method matching RobotDynamics.DiscretizedDynamics(::KSopt, ::RobotDynamics.RK4)

Closest candidates are:
  RobotDynamics.DiscretizedDynamics(::L, ::Q) where {L<:RobotDynamics.ContinuousDynamics, Q<:RobotDynamics.QuadratureRule}
   @ RobotDynamics ~/.julia/packages/RobotDynamics/baZMh/src/discretized_dynamics.jl:172

Stacktrace:
 [1] Problem(::KSopt, ::Objective{QuadraticCost{14, 3, Float64, Diagonal{Float64, SVector{14, Float64}}, Diagonal{Float64, SVector{3, Float64}}}}, ::Vararg{Any}; integration::RobotDynamics.RK4, kwargs::@Kwargs{x0::SVector{14, Float64}, constraints::ConstraintList})
   @ TrajectoryOptimization ~/.julia/packages/TrajectoryOptimization/cGEqd/src/problem.jl:115
 [2] top-level scope
   @ ~/TrajectoryCalculations/KSLowThrust/conference_examples/60_day_transfer.jl:97
in expression starting at /Users/lg/TrajectoryCalculations/KSLowThrust/conference_examples/60_day_transfer.jl:97
kevin-tracy commented 9 months ago

Can you get the quickstart working? https://github.com/RoboticExplorationLab/TrajectoryOptimization.jl/blob/main/examples/quickstart.jl

louk-spaceman commented 9 months ago

I imagine I might have been able to, had I tried before removing Julia 1.10 and installing 1.5.4. I had a few similar scripts running, performing integration with the Altro solver, such as RobotZoo.yakplane. I am currently working on getting everything up and running on 1.5.4 so I will keep you posted. I edited this comment to remove an incorrect assumption I had made before I left for lunch, so sorry for any confusion.

louk-spaceman commented 9 months ago

I was able to run quickstart.jl on Julia 1.5.4 successfully, but still no luck on 60_day_transfer.jl.

kevin-tracy commented 9 months ago

You can start moving the problem over from 60_day_transfer.jl to quickstart.jl. All of the features used in the former are also in the latter. Does that make sense?

louk-spaceman commented 9 months ago

That does make sense, yes. I will attempt to transfer the problem over, but I'm not sure my understanding of the code is great enough to achieve it.