From 19684a2adab5ccaf13f43485de0f2078de3a187d Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Sun, 6 Oct 2019 20:03:02 -0400 Subject: [PATCH] Work around #113. Pass GUI callback into `ODEProblem` ctor instead of into `solve` function, since the callback passed into the `ODEProblem` ctor is now simply replaced with the one passed into `solve`, instead of being merged into a `CallbackSet` (https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/pull/919). --- .../Quick start guide/Quick start guide.ipynb | 112 ++++++++++-------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/notebooks/Quick start guide/Quick start guide.ipynb b/notebooks/Quick start guide/Quick start guide.ipynb index ab2f3ef..0b7e3bd 100644 --- a/notebooks/Quick start guide/Quick start guide.ipynb +++ b/notebooks/Quick start guide/Quick start guide.ipynb @@ -16,9 +16,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[32m\u001b[1mActivating\u001b[22m\u001b[39m environment at `~/.julia/dev/RigidBodySim/notebooks/Quick start guide/Project.toml`\n", + "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m registry at `~/.julia/registries/General`\n", + "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m git-repo `ssh://git@github.com/JuliaRegistries/General.git`\n", + "\u001b[?25l\u001b[2K\u001b[?25h\u001b[32m\u001b[1mPrecompiling\u001b[22m\u001b[39m project...\n" + ] + } + ], "source": [ "using Pkg\n", "Pkg.activate(@__DIR__);\n", @@ -28,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -58,10 +69,10 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ - "HTML{String}(\"\")" + "HTML{String}(\"\")" ] }, "metadata": {}, @@ -70,10 +81,10 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ - "HTML{String}(\"\")" + "HTML{String}(\"\")" ] }, "metadata": {}, @@ -127,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -145,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -177,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -195,7 +206,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -206,7 +217,7 @@ "u0: [0.3, 0.4, 1.0, 2.0]" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -246,7 +257,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -263,14 +274,24 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "┌ Warning: `Ext(type, data)` is deprecated, use `MsgPack.Extension(type, data)` instead.\n", + "│ caller = pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MeshCat.PackedVector{Float32}) at msgpack.jl:7\n", + "└ @ MeshCat /Users/tkoolen/.julia/packages/MeshCat/J3ExE/src/msgpack.jl:7\n" + ] + } + ], "source": [ "gui = GUI(mechanism, visuals)\n", "if !haskey(ENV, \"CI\") # don't try to open a GUI on a headless CI build\n", " open(gui)\n", - "end" + "end;" ] }, { @@ -282,7 +303,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -299,15 +320,15 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "using Blink: Window\n", "if !haskey(ENV, \"CI\") # don't try to open a GUI on a headless CI build\n", " open(gui.controls, Window())\n", - " open(gui.visualizer, Window());\n", - "end" + " open(gui.visualizer, Window())\n", + "end;" ] }, { @@ -328,7 +349,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -346,7 +367,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -369,7 +390,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -397,7 +418,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -449,30 +470,19 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "control! (generic function with 1 method)" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "function control!(τ, t, state)\n", " view(τ, velocity_range(state, shoulder)) .= 5 * sin(t)\n", " view(τ, velocity_range(state, elbow)) .= -configuration(state, shoulder)\n", - "end" + "end;" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -499,7 +509,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -517,7 +527,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -528,14 +538,14 @@ "u0: [0.0, 0.0, 0.0, 0.0]" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "zero!(state)\n", - "problem = ODEProblem(Dynamics(mechanism, controller), state, (0., 5.))" + "problem = ODEProblem(Dynamics(mechanism, controller), state, (0., 5.), callback=gui_callback)" ] }, { @@ -547,11 +557,11 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ - "sol = solve(problem, Tsit5(), abs_tol = 1e-10, dt = 0.05, callback = gui_callback);" + "sol = solve(problem, Tsit5(), abs_tol = 1e-10, dt = 0.05);" ] }, { @@ -563,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -579,16 +589,20 @@ } ], "metadata": { + "@webio": { + "lastCommId": null, + "lastKernelId": null + }, "kernelspec": { - "display_name": "Julia 1.0.2", + "display_name": "Julia 1.2.0", "language": "julia", - "name": "julia-1.0" + "name": "julia-1.2" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.0.2" + "version": "1.2.0" } }, "nbformat": 4,