Skip to content
LIBRARY
BodyShape.md

BodyShape

Body with shape: a rigid rod (FixedTranslation) from frame_a to frame_b with a Body attached at the center of mass via a second FixedTranslation.

This component extends from Renderable

Usage

MultibodyComponents.BodyShape(render=true, color=world_default_body_color(), specular_coefficient=1.5, m=1, r=[0, 0, 0], r_cm=r / 2, I_11=0.001, I_22=0.001, I_33=0.001, I_21=0, I_31=0, I_32=0, radius=world_default_body_diameter() / 2, shapefile="", shape_transform=[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], shape_scale=1, height=0, width=0, shape="cylinder", r_length=norm_(r), r_dir=r / max(r_length, 1e-10))

Parameters:

NameDescriptionUnitsDefault value
orientation_stateOrientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body.OrientationState.None()
sequenceEuler-angle sequence used when orientation_state = Euler[1, 2, 3]
statePriorityState priority of the rotational state10
linearStatePriorityState priority of the linear (position/velocity) state1
point_gravityUse a point-gravity field pointing towards the world origin (structural; see Body)false
rendertrue
colorworld_defau...ody_color()
specular_coefficient1.5
mmasskg1
rVector from frame_a to frame_b resolved in frame_am[0, 0, 0]
r_cmVector from frame_a to center of mass, resolved in frame_amr / 2
I_11Element (1,1) of inertia tensorkg.m20.001
I_22Element (2,2) of inertia tensorkg.m20.001
I_33Element (3,3) of inertia tensorkg.m20.001
I_21Element (2,1) of inertia tensorkg.m20
I_31Element (3,1) of inertia tensorkg.m20
I_32Element (3,2) of inertia tensorkg.m20
radiusRadius of the body in animationsworld_defau...meter() / 2
shapefile""
shape_transform[1 0 0 0; 0...0; 0 0 0 1]
shape_scale1
heightHeight of the body in animations (if shape = "box")0
widthWidth of the body in animations (if shape = "box")0
shape"cylinder"

Connectors

  • frame_a - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several Frame

connectors that can be connected together (Frame3D)

  • frame_b - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several Frame

connectors that can be connected together (Frame3D)

  • frame_cm - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several Frame

connectors that can be connected together (Frame3D)

Variables

NameDescriptionUnits
r_0Position vector from origin of world frame to origin of frame_am
v_0Absolute velocity of frame_a, resolved in world frame (= D(r_0))m/s
a_0Absolute acceleration of frame_a resolved in world frame (= D(v_0))m/s2

Behavior

Source

dyad
"""
Body with shape: a rigid rod (`FixedTranslation`) from `frame_a` to `frame_b`
with a `Body` attached at the center of mass via a second `FixedTranslation`.
"""
component BodyShape
  extends Renderable(color = world_default_body_color())
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Additional frame at the center of mass location"
  frame_cm = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(final r = r_cm, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 270, "y1": 450, "x2": 370, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(final m = m, final r_cm = r_cm, final I_11 = I_11, final I_22 = I_22, final I_33 = I_33, final I_21 = I_21, final I_31 = I_31, final I_32 = I_32, orientation_state = orientation_state, sequence = sequence, statePriority = statePriority, linearStatePriority = linearStatePriority, point_gravity = point_gravity, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 270}
      },
      "tags": []
    }
  }
  # Visualization shape for the rod
  rod_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length_direction = r_dir, length = r_length, width = 2 * radius, height = 2 * radius)
  "Orientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body."
  structural parameter orientation_state::OrientationState = OrientationState.None()
  "Euler-angle sequence used when orientation_state = Euler"
  structural parameter sequence::Integer[3] = [1, 2, 3]
  "State priority of the rotational state"
  structural parameter statePriority::Integer = 10
  "State priority of the linear (position/velocity) state"
  structural parameter linearStatePriority::Integer = 1
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
  "mass"
  parameter m::Mass = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0, 0, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[3] = r / 2
  "Element (1,1) of inertia tensor"
  parameter I_11::Inertia = 0.001
  "Element (2,2) of inertia tensor"
  parameter I_22::Inertia = 0.001
  "Element (3,3) of inertia tensor"
  parameter I_33::Inertia = 0.001
  "Element (2,1) of inertia tensor"
  parameter I_21::Inertia = 0
  "Element (3,1) of inertia tensor"
  parameter I_31::Inertia = 0
  "Element (3,2) of inertia tensor"
  parameter I_32::Inertia = 0
  "Radius of the body in animations"
  parameter radius::Real = world_default_body_diameter() / 2
  parameter shapefile::String = ""
  parameter shape_transform::Real[4, 4] = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
  parameter shape_scale::Real = 1
  """
  Height of the body in animations (if shape = "box")
  """
  parameter height::Real = 0
  """
  Width of the body in animations (if shape = "box")
  """
  parameter width::Real = 0
  parameter shape::String = "cylinder"
  final parameter r_length::Real = norm_(r)
  final parameter r_dir::Real[3] = r / max(r_length, 1e-10)
  "Position vector from origin of world frame to origin of frame_a"
  variable r_0::Position[3]
  "Absolute velocity of frame_a, resolved in world frame (= D(r_0))"
  variable v_0::Velocity[3]
  "Absolute acceleration of frame_a resolved in world frame (= D(v_0))"
  variable a_0::Acceleration[3]
relations
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a, translation_cm.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 650}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 230, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(translation.frame_b, frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 650}, {"x": 770, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(translation_cm.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(frame_cm, translation_cm.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyShape.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 240,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
Flattened Source
dyad
"""
Body with shape: a rigid rod (`FixedTranslation`) from `frame_a` to `frame_b`
with a `Body` attached at the center of mass via a second `FixedTranslation`.
"""
component BodyShape
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Additional frame at the center of mass location"
  frame_cm = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  # Sub-components
  translation = FixedTranslation(final r = r, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(final r = r_cm, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 270, "y1": 450, "x2": 370, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(final m = m, final r_cm = r_cm, final I_11 = I_11, final I_22 = I_22, final I_33 = I_33, final I_21 = I_21, final I_31 = I_31, final I_32 = I_32, orientation_state = orientation_state, sequence = sequence, statePriority = statePriority, linearStatePriority = linearStatePriority, point_gravity = point_gravity, render = false) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 340, "x2": 460, "y2": 440, "rot": 270}
      },
      "tags": []
    }
  }
  # Visualization shape for the rod
  rod_shape = CylinderShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length_direction = r_dir, length = r_length, width = 2 * radius, height = 2 * radius)
  "Orientation state carried by the internal body (None / Euler / Quaternion). Set to Euler or Quaternion to use this component as a freely-moving root body."
  structural parameter orientation_state::OrientationState = OrientationState.None()
  "Euler-angle sequence used when orientation_state = Euler"
  structural parameter sequence::Integer[3] = [1, 2, 3]
  "State priority of the rotational state"
  structural parameter statePriority::Integer = 10
  "State priority of the linear (position/velocity) state"
  structural parameter linearStatePriority::Integer = 1
  "Use a point-gravity field pointing towards the world origin (structural; see Body)"
  structural parameter point_gravity::Boolean = false
  "mass"
  parameter m::Mass = 1
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[3] = [0, 0, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[3] = r / 2
  "Element (1,1) of inertia tensor"
  parameter I_11::Inertia = 0.001
  "Element (2,2) of inertia tensor"
  parameter I_22::Inertia = 0.001
  "Element (3,3) of inertia tensor"
  parameter I_33::Inertia = 0.001
  "Element (2,1) of inertia tensor"
  parameter I_21::Inertia = 0
  "Element (3,1) of inertia tensor"
  parameter I_31::Inertia = 0
  "Element (3,2) of inertia tensor"
  parameter I_32::Inertia = 0
  "Radius of the body in animations"
  parameter radius::Real = world_default_body_diameter() / 2
  parameter shapefile::String = ""
  parameter shape_transform::Real[4, 4] = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
  parameter shape_scale::Real = 1
  """
  Height of the body in animations (if shape = "box")
  """
  parameter height::Real = 0
  """
  Width of the body in animations (if shape = "box")
  """
  parameter width::Real = 0
  parameter shape::String = "cylinder"
  final parameter r_length::Real = norm_(r)
  final parameter r_dir::Real[3] = r / max(r_length, 1e-10)
  "Position vector from origin of world frame to origin of frame_a"
  variable r_0::Position[3]
  "Absolute velocity of frame_a, resolved in world frame (= D(r_0))"
  variable v_0::Velocity[3]
  "Absolute acceleration of frame_a resolved in world frame (= D(v_0))"
  variable a_0::Acceleration[3]
relations
  r_0 = frame_a.r_0
  v_0 = der(r_0)
  a_0 = der(v_0)
  connect(frame_a, translation.frame_a, translation_cm.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 230, "y": 500}, {"x": 230, "y": 650}], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 230, "y": 500}],
      "renderStyle": "standard"
    }
  }
  connect(translation.frame_b, frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 650}, {"x": 770, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(translation_cm.frame_b, body.frame_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(frame_cm, translation_cm.frame_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/BodyShape.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 240,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end


Test Cases

No test cases defined.