JuliaReach / ReachabilityAnalysis.jl

Computing reachable states of dynamical systems in Julia
https://juliareach.github.io/ReachabilityAnalysis.jl/
MIT License
189 stars 17 forks source link

Error: UndefRefError: access to undefined reference #865

Closed paulius92 closed 1 month ago

paulius92 commented 1 month ago

Hi all,

I'm trying to perform a reachability analysis of the kinematic single-track model, which previously worked several months earlier. But, after reinstalling JuliaReach on a new machine, running the same model gives me an error. Any ideas about what could be the issue?

Many thanks!

using ReachabilityAnalysis
using CSV, Tables
using DataFrames
using YAML

@taylorize function vehicle_model!(du, u, p, t)
    local LR = 0.17145
    local LF = 0.15875
    local WHEELBASE_LENGTH =  0.3302 

    x, y, theta, delta, car_v = u
    slip_factor = (LR * tan(delta) / WHEELBASE_LENGTH)

    # write the nonlinear differential equations defining the model
    du[1] = car_v * cos(u[3] + slip_factor)
    du[2] = car_v * sin(u[3] + slip_factor)
    du[3] = car_v * tan(delta) * cos(slip_factor) / WHEELBASE_LENGTH

    return du
end

# set of initial states
X0 = Hyperrectangle([0.0, 0.0, 0.0, 0.0, 0.0], [0.1, 0.1, 0.1, 0.1, 0.1])

# formulate the initial-value problem
prob = @ivp(x' =  vehicle_model!(x), x(0) ∈ X0, dim:5)

# # solve using a Taylor model set representation
sol = solve(prob; T=0.2, alg=TMJets21a(;))

ERROR: LoadError: UndefRefError: access to undefined reference Stacktrace: [1] getindex @ ./essentials.jl:13 [inlined] [2] jetcoeffs!(eqsdiff!::typeof(vehicle_model!), t::Taylor1{Float64}, x::Vector{Taylor1{TaylorN{Float64}}}, dx::Vector{Taylor1{TaylorN{Float64}}}, xaux::Vector{Taylor1{TaylorN{Float64}}}, params::Nothing) @ TaylorIntegration ~/.julia/packages/TaylorIntegration/Vtu13/src/integrator.jl:82 [3] __jetcoeffs! @ ~/.julia/packages/TaylorIntegration/Vtu13/src/integrator.jl:104 [inlined] [4] taylorstep! @ ~/.julia/packages/TaylorIntegration/Vtu13/src/integrator.jl:260 [inlined] [5] validated_step!(f!::typeof(vehicle_model!), t::Taylor1{…}, x::Vector{…}, dx::Vector{…}, xaux::Vector{…}, tI::Taylor1{…}, xI::Vector{…}, dxI::Vector{…}, xauxI::Vector{…}, t0::Float64, tmax::Float64, sign_tstep::Int64, xTMN::Vector{…}, rem::Vector{…}, zbox::IntervalBox{…}, symIbox::IntervalBox{…}, orderT::Int64, abstol::Float64, params::Nothing, adaptive::Bool, minabstol::Float64, absorb::Bool, check_property::ReachabilityAnalysis.var"#389#390") @ TaylorModels ~/.julia/packages/TaylorModels/lP1kA/src/validatedODEs.jl:332 [6] _validated_integ!(f!::Function, t0::Float64, tmax::Float64, orderT::Int64, x::Vector{…}, dx::Vector{…}, xI::Vector{…}, dxI::Vector{…}, abstol::Float64, params::Nothing, maxsteps::Int64, adaptive::Bool, minabstol::Float64, absorb::Bool, check_property::ReachabilityAnalysis.var"#389#390") @ TaylorModels ~/.julia/packages/TaylorModels/lP1kA/src/validatedODEs.jl:641 [7] validated_integ(f!::typeof(vehicle_model!), X0::IntervalBox{…}, t0::Float64, tmax::Float64, orderQ::Int64, orderT::Int64, abstol::Float64, params::Nothing; maxsteps::Int64, parse_eqs::Bool, adaptive::Bool, minabstol::Float64, absorb::Bool, check_property::Function) @ TaylorModels ~/.julia/packages/TaylorModels/lP1kA/src/validatedODEs.jl:820 [8] post(alg::TMJets21a{…}, ivp::InitialValueProblem{…}, timespan::IntervalArithmetic.Interval{…}; Δt0::IntervalArithmetic.Interval{…}, kwargs::@Kwargs{…}) @ ReachabilityAnalysis ~/.julia/packages/ReachabilityAnalysis/kDTYs/src/Algorithms/TMJets/TMJets21a/post.jl:43 [9] solve(::InitialValueProblem{BlackBoxContinuousSystem{typeof(vehicle_model!)}, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}}; kwargs::@Kwargs{T::Float64, alg::TMJets21a{Float64, ZonotopeEnclosure}}) @ ReachabilityAnalysis ~/.julia/packages/ReachabilityAnalysis/kDTYs/src/Continuous/solve.jl:64 [10] top-level scope @ ~/Projects/LikelyToReach/src/model2.jl:29 [11] include(fname::String) @ Base.MainInclude ./client.jl:489 [12] top-level scope @ REPL[2]:1 in expression starting at /home/paulius/Projects/LikelyToReach/src/model2.jl:29 Some type information was truncated. Use show(err) to see complete types.

lbenet commented 1 month ago

Hi!

I think the problem may be related to the fact that u has 5 components, and du only 3. (Internally, some functions in TaylorIntegration and TaylorModels require the same number of components of these quantities, which I think is reflected in the error.)

From what I see in your definition of the equations of motion, delta and car_v act as parameters, and not state variables. Then, either you define components associated to the change in time of delta and car_v, i.e. du[4] and du[5], or you pass those values as parameters.

paulius92 commented 1 month ago

Thank you! I just noticed this too and seems to have fixed it! Many thanks.