diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb5a6fe2..ebeb50c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,11 @@ jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.version == 'nightly' }} + continue-on-error: ${{ matrix.version == 'nightly'}} strategy: matrix: version: + - '1.3' - '1.4' - 'nightly' os: diff --git a/Project.toml b/Project.toml index b9b4ae5e..f13916eb 100644 --- a/Project.toml +++ b/Project.toml @@ -23,13 +23,13 @@ Colors = "0.11.2" CoordinateTransformations = "0.5.1" FileIO = "1.3.0" GeometryTypes = "0.7.10" -LightXML = "0.9.0" +LightXML = "0.8.1, 0.9.0" MeshCat = "0.9.1" MeshIO = "0.3.2" Plots = "1.0.14" Rotations = "0.13.0" StaticArrays = "0.12.3" -julia = "1.4" +julia = "1.3, 1.4" [extras] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 88c0dd90..9cf5ecdf 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -1,3 +1,4 @@ [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" \ No newline at end of file +PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" \ No newline at end of file diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index f4e44152..3f4f6d27 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,4 +1,5 @@ using BenchmarkTools SUITE = BenchmarkGroup() -SUITE["sum"] = @benchmarkable sum($(randn(10_000))) \ No newline at end of file + +include("example_benchmark.jl") \ No newline at end of file diff --git a/benchmark/example_benchmark.jl b/benchmark/example_benchmark.jl new file mode 100644 index 00000000..737fe939 --- /dev/null +++ b/benchmark/example_benchmark.jl @@ -0,0 +1,47 @@ +files = [ + "atlas" + "axes" + "chain_in_chain" + "dice_nofriction" + "dice_tiltedplane" + "dice" + "disconnected_bodies" + "doublependulum_3d" + "doublependulum_urdf" + "football" + "inverted_pyramid_plane" + "joint_force" + "joint_torque" + "n_fourbars" + "n_pendulum" + "nutation" + "pendulum_forced" + "pendulum" + "planar_example" + "scissor_lift" + "slider_crank" + "slider_crank3d" + "wheel" +] + +for i=1:length(files)-1 + include("../test/examples/"*files[i]*".jl") + mech.g = 0.0 + + steps = Base.OneTo(100) + storage = Storage{Float64}(steps,length(mech.bodies)) + + if files[i]=="joint_force" + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $joint_force_control!) samples=1 + elseif files[i]=="pendulum_forced" + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $pendulum_forced_control!) samples=1 + elseif files[i]=="football" + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $football_control!) samples=1 + # elseif files[i]=="nutation" + # SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage, $nutation_control!) samples=1 + # elseif files[i]=="chain_in_chain" + # # + else + SUITE[files[i]] = @benchmarkable simulate!($mech, $steps, $storage) samples=1 + end +end diff --git a/test/allocation_test.jl b/test/allocation_test.jl deleted file mode 100644 index ad10d4aa..00000000 --- a/test/allocation_test.jl +++ /dev/null @@ -1,83 +0,0 @@ -using BenchmarkTools - -files = [ - "atlas" - "axes" - "chain_in_chain" - "dice_nofriction" - "dice_tiltedplane" - "dice" - "disconnected_bodies" - "doublependulum_3d" - "doublependulum_urdf" - "football" - "inverted_pyramid_plane" - "joint_force" - "joint_torque" - "n_fourbars" - "n_pendulum" - "nutation" - "pendulum_forced" - "pendulum" - "planar_example" - "scissor_lift" - "slider_crank" - "slider_crank3d" - "wheel" -] - -warningtimes = [ - 1000.0 # 562.9592 - 50.0 # 24.4849 - 500.0 # 275.3259 - 4000.0 # 873.5784 - 5000.0 # 1249.2964 - 4000.0 # 900.5005 - 50.0 # 18.3757 - 100.0 # 30.044299 - 100.0 # 37.420599 - 4000.0 # 1688.237801 - 500.0 # 227.109 - 100.0 # 32.286301 - 100.0 # 26.4995 - 4000.0 # 2069.365999 - 1000.0 # 519.0557 - 25.0 # 4.226299 - 25.0 # 11.376999 - 25.0 # 11.785099 - 100.0 # 45.874299 - 100.0 # 42.6032 - 100.0 # 59.4295 - 500.0 # 173.376601 - 10.0 # 0.0 -]*10 - -time = zeros(length(files)) - -c1 = maximum(length.(files))+2 -c2 = 9 - -for i=1:length(files)-1 - include("examples/"*files[i]*".jl") - steps = Base.OneTo(1000) - storage = Storage{Float64}(steps,length(mech.bodies)) - if false - # elseif files[i]=="joint_force" || files[i]=="pendulum_forced" || files[i]=="football" || files[i]=="nutation" - # TODO once zero alloc works - # t = @benchmarkable simulate!($mech, $steps, $storage, $control!) - else - t = @benchmarkable simulate!($mech, $steps, $storage) - end - r = BenchmarkTools.minimum(run(t, samples=1)) - @test r.memory == 0 - time[i] = r.time/1e6 - @test time[i] < warningtimes[i] -end - -println(" "^(c1-7)*" Files | Time") -println("-"^(c1+c2+1)) -for i=1:length(files) - l = length(files[i]) - println((" "^(c1-l-1))*files[i]*" | "*string(time[i])) -end - diff --git a/test/example_test.jl b/test/example_test.jl index 53cd9945..a0389f48 100644 --- a/test/example_test.jl +++ b/test/example_test.jl @@ -27,10 +27,10 @@ files = [ ] for file in files - println(file) + # println(file) include("examples/"*file*".jl") if file=="joint_force" || file=="pendulum_forced" || file=="nutation" || file=="football" - storage = simulate!(mech, 10., control!, record = true) + storage = simulate!(mech, 10., eval(Meta.parse(file*"_control!")), record = true) else storage = simulate!(mech, 10., record = true) end diff --git a/test/examples/football.jl b/test/examples/football.jl index 1497b4a3..0dfc6d06 100644 --- a/test/examples/football.jl +++ b/test/examples/football.jl @@ -46,7 +46,7 @@ setPosition!(link4,link5,Δx = [0.;0.;0.03]) spin = 0.35 -function control!(mechanism, k) +function football_control!(mechanism, k) if k<25 setForce!(link3, F = SA[0.;25.;25.], τ=spin*SA[0.2;0.2;1.]) elseif k==40 diff --git a/test/examples/joint_force.jl b/test/examples/joint_force.jl index 9a5c2f87..543fb7f7 100644 --- a/test/examples/joint_force.jl +++ b/test/examples/joint_force.jl @@ -34,7 +34,7 @@ links = [link1; link2] constraints = [joint0to1;joint1to2] shapes = [b1;b2] -function control!(mechanism, k) +function joint_force_control!(mechanism, k) F = SVector{2,Float64}(0.1,0.) setForce!(mechanism, joint1to2, F) return diff --git a/test/examples/nutation.jl b/test/examples/nutation.jl index a3048edb..345f0f6d 100644 --- a/test/examples/nutation.jl +++ b/test/examples/nutation.jl @@ -23,12 +23,12 @@ shapes = [b1] mech = Mechanism(origin, links, constraints, g = 0., shapes = shapes) axis = [0;0;1.] -speed = 20pi #*0 +speed = 2pi #*0 setVelocity!(link1, ω = speed*axis) -function control!(mechanism, k) +function nutation_control!(mechanism, k) if k==1 - setForce!(mechanism.bodies[1], F = SA[0;0;2.], p=SA[0;1.;0]) + setForce!(mechanism.bodies[1], F = SA[0;0;0.2], p=SA[0;1.;0]) else setForce!(mechanism.bodies[1], F = SA[0;0;0.], p=SA[0;0.0;0]) end diff --git a/test/examples/pendulum_forced.jl b/test/examples/pendulum_forced.jl index d328a4b9..33d5c25d 100644 --- a/test/examples/pendulum_forced.jl +++ b/test/examples/pendulum_forced.jl @@ -31,7 +31,7 @@ mech = Mechanism(origin, links, constraints, shapes = shapes) setPosition!(origin,link1,p2 = p2,Δq = q1) jointid = constraints[1].id -function control!(mechanism, k) +function pendulum_forced_control!(mechanism, k) τ = SVector{1,Float64}(cos(0.5 * k*0.01 * 2pi)) setForce!(mechanism, geteqconstraint(mechanism,jointid), τ) end diff --git a/test/runtests.jl b/test/runtests.jl index 4a3bc78a..ff92c61a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,8 +24,4 @@ end @safetestset "Example Tests" begin include("example_test.jl") -end - -@safetestset "Allocation Tests" begin - include("allocation_test.jl") end \ No newline at end of file