Skip to content

Error accessing contact details #120

Closed

Description

@yohankar

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

scene.xml

Activity

  1. changed the title [-]Error accessing contact details with[/-] [+]Error accessing contact details[/+] on Sep 18, 2025
  2. added a commit that references this issue on Oct 16, 2025
  3. linked a pull request that will close this issue120 error accessing contact details #121on Oct 16, 2025
  4. added a commit that references this issue on Oct 16, 2025
  5. JamieMair commented on Oct 16, 2025

    @JamieMair
    Owner

    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:

    Base.transpose(x::MuJoCo.LibMuJoCo.mjContact_) = x

    to your script to fix it.

  6. added a commit that references this issue on Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions