Skip to content

Commit

Permalink
Fix error when position bounds are negative.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoolen committed Oct 11, 2018
1 parent 07ca12e commit ee4abe2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/manipulate.jl
Expand Up @@ -28,8 +28,9 @@ function sliders(joint::Joint, values=clamp.(zeros(num_positions(joint)), positi
resolution=0.01, prefix="")
map(bounds, labels, values) do b, label, value
num_steps = ceil(Int, (upper(b) - lower(b)) / resolution)
r = range(lower(b), stop=upper(b), length=num_steps)
slider(range(lower(b), stop=upper(b), length=num_steps),
value=value,
value=clamp(value, first(r), last(r)),
label=string(prefix, label))
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Expand Up @@ -104,6 +104,14 @@ vis = Visualizer()
widget = manipulate!(mvis)
end

@testset "manipulation - negative bounds issue" begin
mechanism = rand_chain_mechanism(Float64, Revolute{Float64})
joint = first(joints(mechanism))
joint.position_bounds .= RigidBodyDynamics.Bounds(-2.0, -1.0)
mvis = MechanismVisualizer(mechanism)
widget = manipulate!(mvis)
end

@testset "examples" begin
dir = joinpath(@__DIR__, "..", "examples")
for file in readdir(dir)
Expand Down

0 comments on commit ee4abe2

Please sign in to comment.