Skip to content
Merged
22 changes: 12 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Colors = "<0.12.8, 0.12.8"
CoordinateTransformations = "<0.6.2, 0.6.2"
DocStringExtensions = "<0.8.6, 0.8.6"
FFMPEG = "0.4.1"
GeometryBasics = "<0.4.0, 0.4.0"
FFMPEG = "0.4.0, 0.4.1"
FiniteDiff = "2.0, 2.11"
GeometryBasics = "<0.4.2, 0.4.2"
Graphs = "1.5, 1.6"
JLD2 = "<0.4.22, 0.4.22"
LaTeXStrings = "1.3"
LaTeXStrings = "1.3, 1.3"
LightXML = "<0.9.0, 0.9.0"
MeshCat = "<0.14.0, 0.14.0"
MeshCat = "<0.14.2, 0.14.2"
Meshing = "<0.5.7, 0.5.7"
Parameters = "<0.12.0, 0.12.0"
Polyhedra = "<0.7.1, 0.7.1"
Quaternions = "0.5.2"
Scratch = "1.1"
StaticArrays = "1.4"
julia = "1.7"
Parameters = "<0.12.3, 0.12.3"
Polyhedra = "<0.7.3, 0.7.3"
Quaternions = "0.5.2, 0.5.3"
Scratch = "1.1, 1.1"
StaticArrays = "1.2, 1.4"
julia = "1.6, 1.7"
18 changes: 9 additions & 9 deletions src/integrators/integrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ current_configuration_velocity(state::State) = (current_position(state), state.v
initial_configuration_velocity(state::State) = (current_position(state), state.v15, current_orientation(state), state.ϕ15)

# next
next_position(x2::SVector{3,T}, v25::SVector{3,T}, timestep::T) where T = x2 + v25 * timestep
next_orientation(q2::Quaternion{T}, ϕ25::SVector{3,T}, timestep::T) where T = q2 * quaternion_map(ϕ25, timestep) * timestep / 2
next_position(x2::SVector{3}, v25::SVector{3}, timestep::Real) = x2 + v25 * timestep
next_orientation(q2::Quaternion, ϕ25::SVector{3}, timestep::Real) = q2 * quaternion_map(ϕ25, timestep) * timestep / 2
next_position(state::State, timestep) = next_position(state.x2, state.vsol[2], timestep)
next_orientation(state::State, timestep) = next_orientation(state.q2, state.ϕsol[2], timestep)
next_configuration(state::State, timestep) = (next_position(state, timestep), next_orientation(state, timestep))
Expand All @@ -32,13 +32,13 @@ function ∂angular_velocity∂q2(q1::Quaternion, q2::Quaternion, timestep)
end

# Jacobians
function integrator_jacobian_velocity(x2::AbstractVector{T}, v25::AbstractVector{T}, q2::Quaternion{T}, ϕ25::SVector{3,T}, timestep::T) where T
function integrator_jacobian_velocity(x2::AbstractVector, v25::AbstractVector, q2::Quaternion, ϕ25::SVector{3}, timestep::T) where T
V = [linear_integrator_jacobian_velocity(x2, v25, timestep) szeros(T,3,3)]
Ω = [szeros(T,4,3) rotational_integrator_jacobian_velocity(q2, ϕ25, timestep)]
return [V; Ω] # 7x6
end

function integrator_jacobian_configuration(x2::AbstractVector{T}, v25::AbstractVector{T}, q2::Quaternion{T}, ϕ25::SVector{3,T}, timestep::T;
function integrator_jacobian_configuration(x2::AbstractVector, v25::AbstractVector, q2::Quaternion, ϕ25::SVector{3}, timestep::T;
attjac::Bool=true) where T

Z = attjac ? szeros(T,3,3) : szeros(T,3,4)
Expand All @@ -47,22 +47,22 @@ function integrator_jacobian_configuration(x2::AbstractVector{T}, v25::AbstractV
return [X; Q] # 7x6 or 7x7
end

function linear_integrator_jacobian_position(x2::AbstractVector{T}, v2::AbstractVector{T}, timestep::T) where T
function linear_integrator_jacobian_position(x2::AbstractVector, v2::AbstractVector, timestep::T) where T
return SMatrix{3,3,T,9}(Diagonal(sones(T, 3)))
end

function linear_integrator_jacobian_velocity(x2::AbstractVector{T}, v2::AbstractVector{T}, timestep::T) where T
function linear_integrator_jacobian_velocity(x2::AbstractVector, v2::AbstractVector, timestep::T) where T
return timestep * SMatrix{3,3,T,9}(Diagonal(sones(T,3)))
end

function rotational_integrator_jacobian_orientation(q2::Quaternion{T}, ϕ25::SVector{3,T}, timestep::T;
attjac::Bool = true) where T
function rotational_integrator_jacobian_orientation(q2::Quaternion, ϕ25::SVector{3}, timestep::Real;
attjac::Bool = true)
M = Rmat(quaternion_map(ϕ25, timestep) * timestep / 2)
attjac && (M *= LVᵀmat(q2))
return M
end

function rotational_integrator_jacobian_velocity(q2::Quaternion{T}, ϕ25::SVector{3,T}, timestep::T) where T
function rotational_integrator_jacobian_velocity(q2::Quaternion, ϕ25::SVector{3}, timestep::Real)
return Lmat(q2) * quaternion_map_jacobian(ϕ25, timestep) * timestep / 2
end

Expand Down
6 changes: 3 additions & 3 deletions src/joints/rotational/minimal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function displacement(joint::Rotational,
vmat ? (return Vmat(q)) : (return q)
end

function displacement_jacobian_configuration(relative::Symbol, joint::Rotational,
xa::AbstractVector{T}, qa::Quaternion,
xb::AbstractVector{T}, qb::Quaternion;
function displacement_jacobian_configuration(relative::Symbol, joint::Rotational{T},
xa::AbstractVector, qa::Quaternion,
xb::AbstractVector, qb::Quaternion;
attjac::Bool=true, vmat=true) where T
X = szeros(T, 3, 3)
if relative == :parent
Expand Down
2 changes: 1 addition & 1 deletion src/mechanism/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mechanism: Mechanism
y: minimal state
"""
function minimal_to_maximal(mechanism::Mechanism{T,Nn,Ne,Nb,Ni}, y::AbstractVector{Tx}) where {T,Nn,Ne,Nb,Ni,Tx}
function minimal_to_maximal(mechanism::Mechanism{T,Nn,Ne,Nb,Ni}, y::AbstractVector) where {T,Nn,Ne,Nb,Ni}
off = 0
for id in mechanism.root_to_leaves
(id > Ne) && continue # only treat joints
Expand Down
Loading