Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid subtraction operation during visualization #16

Open
zlaouar opened this issue Sep 27, 2022 · 2 comments
Open

invalid subtraction operation during visualization #16

zlaouar opened this issue Sep 27, 2022 · 2 comments

Comments

@zlaouar
Copy link
Contributor

zlaouar commented Sep 27, 2022

After running the simple test script below:

using LaserTag
using POMDPGifs
using QMDP
using Random
using ParticleFilters

rng = MersenneTwister(7)

m = gen_lasertag(rng=rng, robot_position_known=true)
policy = solve(QMDPSolver(verbose=true), m)
filter = SIRParticleFilter(m, 10000, rng=rng)

@show makegif(m, policy, filter, filename="out.gif", rng=rng)

I get the following:

[Iteration 1   ] residual:         10 | iteration runtime:      2.163 ms, (   0.00216 s total)
[Iteration 2   ] residual:        9.5 | iteration runtime:      2.230 ms, (   0.00439 s total)
[Iteration 3   ] residual:       9.02 | iteration runtime:      2.192 ms, (   0.00659 s total)
[Iteration 4   ] residual:       8.57 | iteration runtime:      2.192 ms, (   0.00878 s total)
[Iteration 5   ] residual:       6.92 | iteration runtime:      2.209 ms, (     0.011 s total)
[Iteration 6   ] residual:       6.58 | iteration runtime:      2.179 ms, (    0.0132 s total)
[Iteration 7   ] residual:       6.25 | iteration runtime:      2.212 ms, (    0.0154 s total)
[Iteration 8   ] residual:       5.94 | iteration runtime:      2.249 ms, (    0.0176 s total)
[Iteration 9   ] residual:       5.64 | iteration runtime:      2.207 ms, (    0.0198 s total)
[Iteration 10  ] residual:       5.36 | iteration runtime:      2.208 ms, (     0.022 s total)
[Iteration 11  ] residual:       5.09 | iteration runtime:      2.205 ms, (    0.0242 s total)
[Iteration 12  ] residual:       4.83 | iteration runtime:      2.230 ms, (    0.0265 s total)
[Iteration 13  ] residual:       4.59 | iteration runtime:      2.177 ms, (    0.0287 s total)
[Iteration 14  ] residual:        3.2 | iteration runtime:      2.213 ms, (    0.0309 s total)
[Iteration 15  ] residual:        2.9 | iteration runtime:      2.204 ms, (    0.0331 s total)
[Iteration 16  ] residual:       2.76 | iteration runtime:      2.441 ms, (    0.0355 s total)
[Iteration 17  ] residual:       2.62 | iteration runtime:      2.909 ms, (    0.0384 s total)
[Iteration 18  ] residual:     0.0508 | iteration runtime:      2.705 ms, (    0.0411 s total)
[Iteration 19  ] residual:    0.00966 | iteration runtime:      2.589 ms, (    0.0437 s total)
[Iteration 20  ] residual:    0.00734 | iteration runtime:      2.731 ms, (    0.0464 s total)
[Iteration 21  ] residual:    0.00558 | iteration runtime:      2.638 ms, (    0.0491 s total)
[Iteration 22  ] residual:    0.00424 | iteration runtime:      2.755 ms, (    0.0518 s total)
[Iteration 23  ] residual:    0.00322 | iteration runtime:      2.781 ms, (    0.0546 s total)
[Iteration 24  ] residual:    0.00245 | iteration runtime:      2.213 ms, (    0.0568 s total)
[Iteration 25  ] residual:    0.00186 | iteration runtime:      2.321 ms, (    0.0592 s total)
[Iteration 26  ] residual:    0.00141 | iteration runtime:      3.115 ms, (    0.0623 s total)
[Iteration 27  ] residual:    0.00108 | iteration runtime:      2.605 ms, (    0.0649 s total)
[Iteration 28  ] residual:   0.000817 | iteration runtime:      2.619 ms, (    0.0675 s total)
ERROR: MethodError: no method matching -(::StaticArraysCore.SVector{2, Int64}, ::Float64)
For element-wise subtraction, use broadcasting with dot syntax: array .- scalar
Closest candidates are:
  -(::Base.TwicePrecision, ::Number) at ~/Software/julia-1.7.2/share/julia/base/twiceprecision.jl:293
  -(::GeometryBasics.HyperRectangle{N, T}, ::Number) where {N, T} at ~/.julia/packages/GeometryBasics/6JxlJ/src/primitives/rectangles.jl:266
  -(::LinearAlgebra.UniformScaling, ::Number) at ~/Software/julia-1.7.2/share/julia/stdlib/v1.7/LinearAlgebra/src/uniformscaling.jl:147
  ...
Stacktrace:
 [1] show_meas(o::IOBuffer, s::LTState, obs::StaticArraysCore.MVector{8, Int64})
   @ LaserTag ~/.julia/packages/LaserTag/uG83u/src/visualization.jl:64
 [2] tikz_pic(v::LaserTagVis)
   @ LaserTag ~/.julia/packages/LaserTag/uG83u/src/visualization.jl:108
 [3] show(io::IOStream, mime::MIME{Symbol("image/png")}, v::LaserTagVis)
   @ LaserTag ~/.julia/packages/LaserTag/uG83u/src/visualization.jl:29
 [4] writeframe(filename::String, mime::MIME{Symbol("image/png")}, frame::LaserTagVis)
   @ Reel ~/.julia/packages/Reel/HdonC/src/Reel.jl:35
 [5] push!
   @ ~/.julia/packages/Reel/HdonC/src/Reel.jl:42 [inlined]
 [6] makegif(m::LaserTagPOMDP{DESPOTEmu, StaticArraysCore.MVector{8, Int64}}, hist::POMDPTools.Simulators.SimHistory{NamedTuple{(:s, :a, :sp, :o, :r, :info, :t, :action_info, :b, :bp, :update_info), Tuple{LTState, Int64, LTState, StaticArraysCore.MVector{8, Int64}, Float64, Nothing, Int64, Nothing, ParticleCollection{LTState}, ParticleCollection{LTState}, Nothing}}, Float64}; filename::String, spec::Nothing, show_progress::Bool, extra_initial::Bool, extra_final::Bool, render_kwargs::NamedTuple{(), Tuple{}}, fps::Int64)
   @ POMDPGifs ~/.julia/packages/POMDPGifs/AIFGJ/src/POMDPGifs.jl:145
 [7] simulate(s::GifSimulator, m::LaserTagPOMDP{DESPOTEmu, StaticArraysCore.MVector{8, Int64}}, p::POMDPTools.Policies.AlphaVectorPolicy{LaserTagPOMDP{DESPOTEmu, StaticArraysCore.MVector{8, Int64}}, Int64}, args::BasicParticleFilter{LaserTagPOMDP{DESPOTEmu, StaticArraysCore.MVector{8, Int64}}, LaserTagPOMDP{DESPOTEmu, StaticArraysCore.MVector{8, Int64}}, LowVarianceResampler, MersenneTwister, Vector{LTState}})
   @ POMDPGifs ~/.julia/packages/POMDPGifs/AIFGJ/src/POMDPGifs.jl:61
 [8] #makegif#4
   @ ~/.julia/packages/POMDPGifs/AIFGJ/src/POMDPGifs.jl:89 [inlined]
 [9] top-level scope
   @ show.jl:1047

The issue disappears after modifying line 64 in visualization.jl to use element-wise subtraction: .-

@zsunberg
Copy link
Member

Thanks for reporting! Can you submit a PR to fix it?

@zlaouar
Copy link
Contributor Author

zlaouar commented Sep 28, 2022

Just submitted a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants