diff --git a/src/animate.jl b/src/animate.jl index 89c6882..237c2c9 100644 --- a/src/animate.jl +++ b/src/animate.jl @@ -1,24 +1,3 @@ -""" -Interpolations.jl requires that one(::Type{T}) be defined for any data -type we want to interpolate. Rather than defining one(::Type{Vector}) here, -which might have unforeseen consequences in other packages, we'll create -a very simple wrapper type that just knows one() and * -""" -struct InterpolatableArray{A <: AbstractArray} - data::A -end - -Base.one(::Type{InterpolatableArray{A}}) where {A} = 1 -Base.:*(n::Number, a::InterpolatableArray) = n * a.data - -rbd.normalize_configuration!(joint_type::JointType, q) = nothing -function rbd.normalize_configuration!(joint_type::QuaternionFloating, q) - n = norm(q[1:4]) - for i = 1:4 - q[i] /= n - end -end - """ animate(vis::MechanismVisualizer, times::Vector{Float64}, @@ -36,8 +15,7 @@ function animate(vis::MechanismVisualizer, @assert 0 < realtimerate < Inf state = vis.state - interp_values = [InterpolatableArray(c) for c in configurations] - interpolated_configurations = interpolate((times,), interp_values, Gridded(Linear())) + interpolated_configurations = interpolate((times,), configurations, Gridded(Linear())) t0, tf = first(times), last(times) framenum = 0 walltime0 = time() @@ -51,7 +29,3 @@ function animate(vis::MechanismVisualizer, t == tf && break end max_rate = fps end - -animate(mechanism::Mechanism, times::Vector{Float64}, - configurations::Vector{Vector{Float64}}) = - animate(Visualizer(mechanism), mechanism, times, configurations) diff --git a/src/visualizer.jl b/src/visualizer.jl index af4f1b2..f533c53 100644 --- a/src/visualizer.jl +++ b/src/visualizer.jl @@ -30,12 +30,12 @@ function _set_mechanism!(mvis::MechanismVisualizer, frame_to_visuals) body_ancestors = rbd.Graphs.ancestors(vertex, tree) for definition in rbd.frame_definitions(body) frame = definition.from - path = Symbol.(vcat(string.(reverse(body_ancestors)), string(frame))) + path = vcat(string.(reverse(body_ancestors)), string(frame)) frame_vis = vis[path...] if frame in keys(frame_to_visuals) settransform!(frame_vis, to_affine_map(definition)) for (i, (object, tform)) in enumerate(frame_to_visuals[frame]) - obj_vis = frame_vis[Symbol("geometry_", i)] + obj_vis = frame_vis["geometry_$i"] setobject!(obj_vis, object) settransform!(obj_vis, tform) end @@ -58,7 +58,7 @@ function _render_state!(mvis::MechanismVisualizer, state::MechanismState=mvis.st settransform!(vis, to_affine_map(transform_to_root(state, body))) else body_ancestors = rbd.Graphs.ancestors(vertex, tree) - path = Symbol.(string.(reverse(body_ancestors))) + path = string.(reverse(body_ancestors)) tform = relative_transform(state, default_frame(body), default_frame(body_ancestors[2])) settransform!(vis[path...], to_affine_map(tform)) end