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

Update Animation given the changes upstream in MeshCat.jl #71

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
16 changes: 8 additions & 8 deletions src/animate.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""
animate(vis::MechanismVisualizer,
animate(mvis::MechanismVisualizer,
times::Vector{Float64},
configurations::Vector{Vector{Float64}};
fps::Float64=60, realtimerate::Float64=1.)

Animate the given mechanism passing through a time-coded series of
configurations by linearly interpolating the configuration vectors.
"""
function animate(vis::MechanismVisualizer,
function animate(mvis::MechanismVisualizer,
times::Vector{Float64},
configurations::AbstractVector{<:AbstractVector{Float64}};
fps::Float64 = 60., realtimerate::Float64 = 1.)
@assert fps > 0
@assert 0 < realtimerate < Inf

state = vis.state
state = mvis.state
interpolated_configurations = interpolate((times,), configurations, Gridded(Linear()))
t0, tf = first(times), last(times)
framenum = 0
Expand All @@ -24,19 +24,19 @@ function animate(vis::MechanismVisualizer,
q = interpolated_configurations(t)
set_configuration!(state, q)
rbd.normalize_configuration!(state)
_render_state!(vis)
_render_state!(mvis)
framenum += 1
t == tf && break
end max_rate = fps
end

function MeshCat.Animation(mvis::MechanismVisualizer,
times::AbstractVector{<:Real},
configurations::AbstractVector{<:AbstractVector{<:Real}};
fps::Integer=30)
times::AbstractVector{<:Real},
configurations::AbstractVector{<:AbstractVector{<:Real}};
fps::Integer=30)
@assert axes(times) == axes(configurations)
interpolated_configurations = interpolate((times,), configurations, Gridded(Linear()))
animation = Animation()
animation = Animation(mvis.visualizer["/meshcat"])
ferrolho marked this conversation as resolved.
Show resolved Hide resolved
num_frames = floor(Int, (times[end] - first(times)) * fps)
for frame in 0 : num_frames
time = first(times) + frame / fps
Expand Down
Loading