Repository navigation
Description
Hi, I was trying to access contact data in the simulation, got bellow error.
ERROR: LoadError: MethodError: no method matching transpose(::MuJoCo.LibMuJoCo.mjContact_) The function `transpose` exists, but no method is defined for this combination of argument types.Closest candidates are:
transpose(::Missing)
@ Base missing.jl:101
transpose(::LinearAlgebra.TransposeFactorization)
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/factorization.jl:62
transpose(::LinearAlgebra.Diagonal{var"#s5052", V} where {var"#s5052"<:Number, V<:AbstractVector{var"#s5052"}})
@ LinearAlgebra ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/diagonal.jl:769
...Stacktrace:
[1] getindex
@ ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/adjtrans.jl:334 [inlined]
[2] getindex
@ ./abstractarray.jl:1353 [inlined]
[3] getindex(A::LinearAlgebra.Transpose{Union{}, UnsafeArrays.UnsafeArray{MuJoCo.LibMuJoCo.mjContact, 2}}, I::Int64)
@ Base ./abstractarray.jl:1312
...
[6] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#3#4"{String})
@ VSCodeDebugger.DebugAdapter ~/.vscode/extensions/julialang.language-julia-1.149.2/scripts/packages/DebugAdapter/src/packagedef.jl:123
[7] startdebugger()
@ VSCodeDebugger ~/.vscode/extensions/julialang.language-julia-1.149.2/scripts/packages/VSCodeDebugger/src/VSCodeDebugger.jl:47
[8] top-level scope
@ ~/.vscode/extensions/julialang.language-julia-1.149.2/scripts/debugger/run_debugger.jl:12
[9] include(mod::Module, _path::String)
@ Base ./Base.jl:562
[10] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:323
[11] _start()
@ Base ./client.jl:531
Script
using MuJoCo
model = MuJoCo.load_model("scene.xml") #Scene is attached
data = MuJoCo.init_data(model)
forward!(model, data)
println("contacts: ", data.ncon)
if data.ncon > 0
for i in 1:data.ncon
contact = data.contact[i]
println("Contact $i: geom1=$(contact.geom1), geom2=$(contact.geom2)")
end
end
Activity
[-]Error accessing contact details with[/-][+]Error accessing contact details[/+]Added a quick fix for #120
Merge pull request #121 from JamieMair/120-error-accessing-contact-de…
JamieMair commentedon Oct 16, 2025
Hi @yohanjk, thanks for the informative bug report and example. I've merged a fix that should work and I've tried to see if there are any other similar bugs in the API. Luckily, this was a relative simple fix. If you need it before the release goes out, you can add:
to your script to fix it.
New version: MuJoCo v0.2.2 (#140546)