Coder Social home page Coder Social logo

thowell / optimization_dynamics Goto Github PK

View Code? Open in Web Editor NEW
46.0 4.0 3.0 4.55 MB

Implementation and examples from Trajectory Optimization with Optimization-Based Dynamics https://arxiv.org/abs/2109.04928

License: MIT License

Julia 100.00%
optimization dynamics bilevel-optimization differentiable-optimization implicit trajectory-optimization control planar-push rocket acrobot

optimization_dynamics's Introduction

Trajectory Optimization with Optimization-Based Dynamics

This repository contains the implementation and examples from our paper: Trajectory Optimization with Optimization-Based Dynamics.

Installation

From the Julia REPL, type ] to enter the Pkg REPL mode and run:

pkg> add https://github.com/thowell/optimization_dynamics

This will install the package.

Run

(OptimizationDynamics) pkg> build

to build the package.

Notebooks are generated upon installation and can be run for the following examples:

planar push

drawing

acrobot with joint limits

drawing

cart-pole with joint friction

drawing

hopper gait

drawing

rocket with thrust limits

drawing

Additional comparisons with MuJoCo and contact-implicit trajectory optimization are available. The path-following solver and hopper model can be found in RoboDojo.jl.

optimization_dynamics's People

Contributors

thowell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

optimization_dynamics's Issues

ERROR: type DataType has no field var

 julia> include("examples/rocket.jl")

┌ Info: MeshCat server started. You can open the visualizer by visiting the following URL in your browser:
└ http://127.0.0.1:8708
ERROR: type DataType has no field var
Stacktrace:
  [1] getproperty @ ./Base.jl:33 [inlined]
  [2] call @ ~/.julia/packages/Cassette/34vIw/src/context.jl:456 [inlined]
  [3] fallback @ ~/.julia/packages/Cassette/34vIw/src/context.jl:454 [inlined]
  [4] overdub @ ~/.julia/packages/Cassette/34vIw/src/context.jl:279 [inlined]
  [5] overdub @ ./operators.jl:50 [inlined]
  [6] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(supertype), ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
  [7] overdub @ ./operators.jl:50 [inlined]
  [8] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(supertype), ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
  [9] overdub @ ./operators.jl:50 [inlined]
 [10] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(supertype), ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [11] overdub @ ./operators.jl:50 [inlined]
 [12] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(supertype), ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [13] StaticArraysCore.Size(::Type{Rotations.RotMatrix}) @ ~/.julia/packages/Rotations/QaTBi/src/core_types.jl:11 [inlined]
 [14] overdub @ ~/.julia/packages/Rotations/QaTBi/src/core_types.jl:11 [inlined]
 [15] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::Type{StaticArraysCore.Size}, ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [16] length(::Type{Rotations.RotMatrix}) @ ~/.julia/packages/StaticArrays/PUoe1/src/abstractarray.jl:2 [inlined]
 [17] overdub @ ~/.julia/packages/StaticArrays/PUoe1/src/abstractarray.jl:2 [inlined]
 [18] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(length), ::Type{Rotations.RotMatrix}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [19] need_rewrap(::Type{Rotations.RotMatrix}, ::Rotations.MRP{Float64}) @ ~/.julia/packages/StaticArrays/PUoe1/src/convert.jl:147 [inlined]
 [20] overdub @ ~/.julia/packages/StaticArrays/PUoe1/src/convert.jl:147 [inlined]
 [21] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(StaticArrays.need_rewrap), ::Type{Rotations.RotMatrix}, ::Rotations.MRP{Float64}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [22] overdub @ ~/.julia/packages/StaticArrays/PUoe1/src/convert.jl:167 [inlined]
 [23] *(::Rotations.MRP{Float64}, ::Rotations.RotX{Float64}) @ ~/.julia/packages/Rotations/QaTBi/src/core_types.jl:118 [inlined]
 [24] overdub @ ~/.julia/packages/Rotations/QaTBi/src/core_types.jl:118 [inlined]
 [25] overdub(::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, ::typeof(*), ::Rotations.MRP{Float64}, ::Rotations.RotX{Float64}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [26] overdub @ ~/codes/optimization_dynamics/src/models/rocket/visuals.jl:40 [inlined]
 [27] overdub(overdub_context#320::Cassette.Context{nametype(AnimationCtx), Tuple{Animation, Int64}, Nothing, Cassette.var"##PassType#322", Nothing, Nothing}, overdub_arguments#321::OptimizationDynamics.var"#101#102"{Int64, Visualizer, Vector{Vector{Float64}}, Int64}) @ Cassette ~/.julia/packages/Cassette/34vIw/src/overdub.jl:0
 [28] atframe @ ~/.julia/packages/MeshCat/Ax8pH/src/atframe.jl:97 [inlined]
 [29] visualize!(vis::Visualizer, p::OptimizationDynamics.Rocket{Float64}, q::Vector{Vector{Float64}}; Δt::Float64, mesh::Bool, T_off::Int64) @ OptimizationDynamics ~/codes/optimization_dynamics/src/models/rocket/visuals.jl:34
 [30] top-level scope @ ~/codes/optimization_dynamics/examples/rocket.jl:120

(OptimizationDynamics) pkg> st
Project OptimizationDynamics v0.1.0
Status `~/codes/optimization_dynamics/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [5ae59095] Colors v0.12.8
  [150eb455] CoordinateTransformations v0.6.2
⌅ [a9f42406] DirectTrajectoryOptimization v0.1.3
⌅ [5c1252a2] GeometryBasics v0.3.13
  [615f187c] IfElse v0.1.1
⌅ [605048dd] IterativeLQR v0.1.1
  [033835bb] JLD2 v0.4.25
⌃ [283c5d60] MeshCat v0.14.1
  [6c8a4c8a] RelevanceStacktrace v0.1.8
  [2859eb88] RoboDojo v0.1.6
⌅ [6038ab10] Rotations v1.0.2
  [6c6a2e73] Scratch v1.1.1
⌅ [0c5d862f] Symbolics v0.1.29
  [37e2e46d] LinearAlgebra
julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 96 × Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, cascadelake)
  Threads: 1 on 96 virtual cores
Environment:
  LD_LIBRARY_PATH = /usr/local/cuda-11.1/lib64:/usr/local/cuda/extras/CUPTI/lib64

Missing impact.jld2 file caused by Apple Silicon? Or Something else?

Summary

Thank you for sharing this implementation online!

I am interested in running this, but I'm a bit unsure if I'm able to. Some Julia libraries that I've recently tried to use were not available to me because of my Mac's use of Apple Silicon.

Have you seen this error before: opening file "/SOME_PATH/.julia/scratchspaces/b76b7f0e-3267-49b4-a6cd-c01948ce091d/acrobot/impact.jld2"? If so, can you easily see what might be wrong? If not, then it is likely just another Apple Silicon issue.

Thank you for your time! More information on the error can be found below.

Specific Error

┌ Warning: Opening file with JLD2.MmapIO failed, falling back to IOStream
└ @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:277
ERROR: LoadError: SystemError: opening file "/MY_MAC_HOME_DIRECTORY/.julia/scratchspaces/b76b7f0e-3267-49b4-a6cd-c01948ce091d/acrobot/impact.jld2": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:176
  [2] #systemerror#80
    @ ./error.jl:175 [inlined]
  [3] systemerror
    @ ./error.jl:175 [inlined]
  [4] open(fname::String; lock::Bool, read::Bool, write::Bool, create::Bool, truncate::Bool, append::Bool)
    @ Base ./iostream.jl:293
  [5] openfile
    @ ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:267 [inlined]
  [6] openfile(T::Type, fname::String, wr::Bool, create::Bool, truncate::Bool, fallback::Type)
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:278
  [7] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO}; fallback::Type{IOStream}, compress::Bool, mmaparrays::Bool, typemap::Dict{String, Any})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:334
  [8] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:291
  [9] jldopen(fname::String, mode::String; iotype::Type, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:414
 [10] jldopen (repeats 2 times)
    @ ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:408 [inlined]
 [11] jldopen(f::Function, args::String; kws::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:2
 [12] jldopen(f::Function, args::String)
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:1
 [13] top-level scope
    @ ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:145
 [14] include
    @ ./Base.jl:419 [inlined]
 [15] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1554
 [16] top-level scope
    @ stdin:1
in expression starting at /MY_MAC_HOME_DIRECTORY/.julia/packages/OptimizationDynamics/1IeSO/src/OptimizationDynamics.jl:1
in expression starting at stdin:1

caused by: SystemError: opening file "/MY_MAC_HOME_DIRECTORY/.julia/scratchspaces/b76b7f0e-3267-49b4-a6cd-c01948ce091d/acrobot/impact.jld2": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:176
  [2] #systemerror#80
    @ ./error.jl:175 [inlined]
  [3] systemerror
    @ ./error.jl:175 [inlined]
  [4] open(fname::String; lock::Bool, read::Bool, write::Bool, create::Bool, truncate::Bool, append::Bool)
    @ Base ./iostream.jl:293
  [5] JLD2.MmapIO(fname::String, write::Bool, create::Bool, truncate::Bool)
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/mmapio.jl:105
  [6] openfile
    @ ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:270 [inlined]
  [7] openfile(T::Type, fname::String, wr::Bool, create::Bool, truncate::Bool, fallback::Type)
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:275
  [8] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO}; fallback::Type{IOStream}, compress::Bool, mmaparrays::Bool, typemap::Dict{String, Any})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:334
  [9] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:291
 [10] jldopen(fname::String, mode::String; iotype::Type, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:414
 [11] jldopen (repeats 2 times)
    @ ~/.julia/packages/JLD2/egQUB/src/JLD2.jl:408 [inlined]
 [12] jldopen(f::Function, args::String; kws::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:2
 [13] jldopen(f::Function, args::String)
    @ JLD2 ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:1
 [14] top-level scope
    @ ~/.julia/packages/JLD2/egQUB/src/loadsave.jl:145
 [15] include
    @ ./Base.jl:419 [inlined]
 [16] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1554
 [17] top-level scope
    @ stdin:1
ERROR: LoadError: Failed to precompile OptimizationDynamics [b76b7f0e-3267-49b4-a6cd-c01948ce091d] to /MY_MAC_HOME_DIRECTORY/.julia/compiled/v1.8/OptimizationDynamics/jl_AoW3M2.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:1707
 [3] compilecache
   @ ./loading.jl:1651 [inlined]
 [4] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1337
 [5] _require_prelocked(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1200
 [6] macro expansion
   @ ./loading.jl:1180 [inlined]
 [7] macro expansion
   @ ./lock.jl:223 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144
in expression starting at /MY_MAC_HOME_DIRECTORY/Documents/Research/manipulation/optimization_dynamics/examples/planar_push.jl:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.