MBSE
Mechanism definition YAML files

MBSE allows users to define mechanisms by means of a human-friendly YAML file.

Example: mechanisms/fourbars1-with-rel-angle.yaml

%YAML 1.2
---
# A four bars mecahnism, with crank angle as relative coordinate.
# Degrees of freedom in q=[x1 y1 x2 y2 q5]^T
# Modeled in Natural coordinates plus one relative angle coordinate
# at the left-hand side fixed end.
#
# 2:(q3,q4)
# +---------o
# | (xb,yb)
# |
# |
# o---------+ 1:(q1,q2)
# (xa,ya)
#
# - q5: Angle (xa,ya)-(q1,q2)
#
parameters:
L: 1.0 # length [m]
xb: 4.0
points:
# 0 (="A")
- {x: 0, y: 0, fixed: true}
# 1
- { x: L, y: 0 }
# 2
- { x: L, y: 2*L }
# 3 (="B")
- { x: xb, y: 0, fixed: true }
planar_bodies:
# 0
- points: [0, 1]
length: L
mass: 1.0
I0: (1/3)*mass*length^2
cog: [0.5*length, 0.0]
# 1
- points: [1, 2]
length: 2*L
mass: 2.0
I0: (1/3)*mass*length^2
cog: [0.5*length, 0.0]
# 3
- points: [2, 3]
length: auto
mass: 4.0
I0: (1/3)*mass*length^2
cog: [0.5*length, 0.0]
# Relative coordinates:
relative_coordinates:
# 0
- type: RelativeAngleAbsoluteDOF
points: [0, 1]

1. YAML file structure

Prototype file structure:

    %YAML 1.2
    ---
    # Optional top comment section.
    #
    # Define points (mandatory)
    points:
      # 0 (="A")
      - {x: 0, y: 0, fixed: true}
      # 1
      # ...
    # Define bodies (mandatory)
    planar_bodies:
      # 0
      - points: [0, 1]
        # ...
    # Relative coordinates (Optional section)
    relative_coordinates:
      # 0
      - type: RelativeAngleAbsoluteDOF
Note
YAML requires correct indentation to be observed

Required sections are:

  • points: one entry per defined "point", both moving and fixed ones.
  • planar_bodies: each planar body is defined by means of exactly two points. Length, mass, inertia with respect to the first point (I0), and center of gravity (cog) must be also specified, possibly using equations that get evaluated (in that order) substituting these variables:
    • index: 0-based index of the body,
    • length: the length. You can use auto to compute length automatically from the distance |pt(1)-pt(0)|.
    • mass: The mass.
    • I0: The inertia.

2. C++ API

Usage:

// Load mechanism model:
const auto yamlData = mrpt::containers::yaml::FromFile(filename);
const mbse::CModelDefinition model = mbse::CModelDefinition::FromYAML(yamlData);