Skip to content
LIBRARY
PlanarMechanics.BodyShape.md

PlanarMechanics.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 PartialTwoFrames This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.BodyShape(render=true, color=MultibodyComponents.world_default_body_color(), specular_coefficient=1.5, r=[1, 0], r_cm=r / 2, m=1, I=0.1, radius=MultibodyComponents.world_default_body_diameter() / 2, z_position=0, l=sqrt(r[1] ^ 2 + r[2] ^ 2))

Parameters:

NameDescriptionUnitsDefault value
rendertrue
colorMultibodyCo...ody_color()
specular_coefficient1.5
rVector from frame_a to frame_b resolved in frame_am[1, 0]
r_cmVector from frame_a to center of mass, resolved in frame_amr / 2
mMass of the bodykg1
IInertia of the body with respect to the center of masskg.m20.1
radiusRadius of the body in animationsMultibodyCo...meter() / 2
z_positionz-position of the body shape in animations0

Connectors

  • frame_a - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. (Frame2D)

  • frame_b - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. (Frame2D)

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 PartialTwoFrames
  extends MultibodyComponents.Renderable(color = MultibodyComponents.world_default_body_color())
  translation = FixedTranslation(final r = r, render = false)
  translation_cm = FixedTranslation(final r = r_cm, render = false)
  body = Body(final m = m, final I = I, render = false)
  "Visualization shape for the rod (cylinder from frame_a to frame_b)"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = color, r = [frame_a.x, frame_a.y, z_position], length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0], width_direction = [0, 0, 1], length = l, width = 2 * radius, height = 2 * radius)
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[2] = [1, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[2] = r / 2
  "Mass of the body"
  parameter m::Dyad.Mass = 1
  "Inertia of the body with respect to the center of mass"
  parameter I::MomentOfInertia = 0.1
  "Radius of the body in animations"
  parameter radius::Real = MultibodyComponents.world_default_body_diameter() / 2
  "z-position of the body shape in animations"
  parameter z_position::Real = 0
  "Length of rod"
  final parameter l::Length = sqrt(r[1] ^ 2 + r[2] ^ 2)
relations
  connect(frame_a, translation.frame_a, translation_cm.frame_a)
  connect(frame_b, translation.frame_b)
  connect(translation_cm.frame_b, body.frame_a)
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
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 450, "x2": 950, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  translation = FixedTranslation(final r = r, render = false)
  translation_cm = FixedTranslation(final r = r_cm, render = false)
  body = Body(final m = m, final I = I, render = false)
  "Visualization shape for the rod (cylinder from frame_a to frame_b)"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = color, r = [frame_a.x, frame_a.y, z_position], length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0], width_direction = [0, 0, 1], length = l, width = 2 * radius, height = 2 * radius)
  "Vector from frame_a to frame_b resolved in frame_a"
  parameter r::Length[2] = [1, 0]
  "Vector from frame_a to center of mass, resolved in frame_a"
  parameter r_cm::Length[2] = r / 2
  "Mass of the body"
  parameter m::Dyad.Mass = 1
  "Inertia of the body with respect to the center of mass"
  parameter I::MomentOfInertia = 0.1
  "Radius of the body in animations"
  parameter radius::Real = MultibodyComponents.world_default_body_diameter() / 2
  "z-position of the body shape in animations"
  parameter z_position::Real = 0
  "Length of rod"
  final parameter l::Length = sqrt(r[1] ^ 2 + r[2] ^ 2)
relations
  connect(frame_a, translation.frame_a, translation_cm.frame_a)
  connect(frame_b, translation.frame_b)
  connect(translation_cm.frame_b, body.frame_a)
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.