BB.Urdf.Parser (bb v0.20.0)

Copy Markdown View Source

Parse a URDF XML document into a plain-map intermediate representation.

The result is intentionally close to the URDF wire format: link/joint lists are flat (joints reference parent and child link names), values are floats in SI base units, and unsupported URDF features are collected as warnings rather than raised as errors. The BB.Urdf.Importer consumes this representation and produces a BB DSL module.

Summary

Functions

Parse a URDF XML file from disk.

Parse a URDF XML string.

Types

collision()

@type collision() :: %{
  name: String.t() | nil,
  origin: origin() | nil,
  geometry: geometry() | nil
}

geometry()

@type geometry() ::
  {:box, %{size: {float(), float(), float()}}}
  | {:cylinder, %{radius: float(), length: float()}}
  | {:sphere, %{radius: float()}}
  | {:mesh, %{filename: String.t(), scale: float()}}

inertial()

@type inertial() :: %{
  origin: origin() | nil,
  mass: float() | nil,
  inertia: %{
    ixx: float(),
    iyy: float(),
    izz: float(),
    ixy: float(),
    ixz: float(),
    iyz: float()
  }
}

joint()

@type joint() :: %{
  name: String.t(),
  type: atom(),
  parent: String.t(),
  child: String.t(),
  origin: origin() | nil,
  axis: {float(), float(), float()} | nil,
  limit:
    %{
      lower: float() | nil,
      upper: float() | nil,
      effort: float() | nil,
      velocity: float() | nil
    }
    | nil,
  dynamics: %{damping: float() | nil, friction: float() | nil} | nil,
  mimic: %{joint: String.t(), multiplier: float(), offset: float()} | nil
}

link()

@type link() :: %{
  name: String.t(),
  visual: visual() | nil,
  collisions: [collision()],
  inertial: inertial() | nil
}

material()

@type material() :: %{
  name: String.t() | nil,
  color: %{red: float(), green: float(), blue: float(), alpha: float()} | nil,
  texture: String.t() | nil
}

origin()

@type origin() :: %{
  xyz: {float(), float(), float()},
  rpy: {float(), float(), float()}
}

robot()

@type robot() :: %{
  name: String.t(),
  links: [link()],
  joints: [joint()],
  transmissions: %{optional(String.t()) => transmission()},
  materials: %{optional(String.t()) => material()},
  warnings: [String.t()]
}

transmission()

@type transmission() :: %{
  name: String.t() | nil,
  joint: String.t(),
  actuator: String.t() | nil,
  reduction: float()
}

visual()

@type visual() :: %{
  name: String.t() | nil,
  origin: origin() | nil,
  geometry: geometry() | nil,
  material: material() | nil
}

Functions

parse_file(path)

@spec parse_file(Path.t()) :: {:ok, robot()} | {:error, term()}

Parse a URDF XML file from disk.

parse_string(xml)

@spec parse_string(String.t()) :: {:ok, robot()} | {:error, term()}

Parse a URDF XML string.