This is the function I wrote to use Symbolics.jl, where variables are of type Num.
function inverseDynamics(θs::Vector{T}, θ̇s::Vector{T}, θ̈s::Vector{T},
g::Vector{T}, Ftip::Vector{T}, Mlist::Vector{T},
Glist::Vector{T}, Slist::Vector{T}) where T <:Union{Int64, Float64, Num, Vector{Float64}, Matrix{Float64}}
However, in a call like this:
@variables θ₁ θ₂ θ₃ θ₄ θ₅ θ₆ θ₇
θs = [θ₁, θ₂, θ₃, θ₄, θ₅, θ₆, θ₇]
n = size(θs, 1)
M = Matrix{typeof(θs)}(undef, n, n)
θ̇s = [0 for i in 1:n]
θ̈s = [0 for i in 1:n]
θ̈s[1] = 1
M[:, 1] .= inverseDynamics(θs, θ̇s, θ̈s, [0, 0, 0], [0, 0, 0, 0, 0, 0], Mlist, Glist, Slist)
given declared variables of type Num: @variables θ₁ θ₂ θ₃ θ₄ θ₅ θ₆ θ₇ and θs is of type Vector{Num}, and θs = [θ₁, θ₂, θ₃, θ₄, θ₅, θ₆, θ₇]
It gives me the error that no method is matching the call. And here is the exact erros:
ERROR: MethodError: no method matching inverseDynamics(::Vector{Num}, ::Vector{Int64},
::Vector{Int64}, ::Vector{Int64}, ::Vector{Int64}, ::Vector{Matrix{Float64}},
::Vector{Matrix{Float64}}, ::Vector{Vector{Float64}})
Closest candidates are:
inverseDynamics(::Vector{T}, !Matched::Vector{T}, !Matched::Vector{T},
!Matched::Vector{T}, !Matched::Vector{T}, !Matched::Vector{T}, !Matched::Vector{T},
!Matched::Vector{T}) where T<:Union{Float64, Int64, Num, VecOrMat{Float64}}
at ~/Julia-scripts/symbolicDynamics/symbolicDynamics.jl:124
I am very new to Julia. I have been scratching my head but cannot find where went wrong. According to the closest candidates, only the first argument θs is a mismatch. I don't quite understand. Isn't θs a sub-type of the Union type in the function definition?
In addition, any Julia coding advice is welcome! Thanks in advance!!