Skip to content
LIBRARY

URDF import

MultibodyComponents.jl supports import of URDF files by means of the functions urdf2MTK and urdf2dyad. The functionality requires the user to install and load the packages LightXML.jl, Graphs.jl, MetaGraphsNext.jl and JuliaFormatter.jl, e.g.,

julia
using Pkg
Pkg.add([
    "LightXML",
    "Graphs",
    "MetaGraphsNext",
    "JuliaFormatter"
])
using MultibodyComponents, LightXML, Graphs, MetaGraphsNext, JuliaFormatter

Usage

ModelingToolkit output

The following example demonstrates how to import a URDF file to a ModelingToolkit @component function. The translated model is saved in file doublependulum.jl. extras = true makes the file self contained by including package imports, simulation and plotting.

julia
filename = joinpath(dirname(pathof(MultibodyComponents)), "..", "test/urdf/doublependulum.urdf")
out = "doublependulum.jl"
urdf2MTK(filename; extras=true, out)

include(joinpath(pwd(), out)) # Include model, perform simulation and plotting

Dyad output

To generate a .dyad component file instead:

julia
filename = joinpath(dirname(pathof(MultibodyComponents)), "..", "test/urdf/doublependulum.urdf")
out = "doublependulum.dyad"
urdf2dyad(filename; out)

Limitations

The URDF import currently has the following limitations:

  • Sensors are not imported.

  • Transmissions are not imported.

  • friction is not translated, but damping is translated to a 1D Damper component attached using the axisflange structural parameter.

  • Meshes are not fully supported yet, they will be imported as generic shapes (inertial properties are imported).

  • Floating and planar joints are not yet supported.

  • urdf2dyad does not support function-based worldconnection.

Structure of the translated model

URDF does not store the transformation implied by links in the link itself, instead, the links store visual and inertial geometry information, while the translation between frames is implied by the origin of the following joint(s). Therefore, we do generally not make use of the r argument to bodies, and let this be arbitrarily set. The transformation between two joints is instead encoded as r, n and angle arguments to each joint, where joints are wrapped in URDFRevolute and URDFPrismatic components respectively. Internally, these wrapper components are comprised of a FixedRotation followed by the actual joint. The interface to these special joints is identical to their non-wrapped counterparts, i.e., they have the frame_a and frame_b connectors as expected. When damping is present in the URDF, the axisflange structural parameter is set to true, exposing 1D axis and support connectors for attaching damper components. Due to this approach, we always connect to the frame_a connector of links/bodies and let frame_b be unused.