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=[0.5019608, 0.0, 0.5019608, 1.0], specular_coefficient=0.7, r=[1, 0], r_cm=[0.5, 0], m=1, I=0.1, radius=0.1, z_position=0, l=sqrt(r[1] ^ 2 + r[2] ^ 2))

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0.5019608,...19608, 1.0]
specular_coefficient0.7
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_am[0.5, 0]
mMass of the bodykg1
IInertia of the body with respect to the center of masskg.m20.1
radiusRadius of the body in animations0.1
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

[rodshape.r(t)=arrayliteral([3],framea.x(t),framea.y(t),zposition)rodshape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)rodshape.r_shape(t)=[000]rodshape.length_direction(t)=arrayliteral([3],translation.r01(t)l,translation.r02(t)l,0)rodshape.width_direction(t)=[001]rodshape.length(t)=lrodshape.width(t)=2radiusrodshape.height(t)=2radiusconnect(framea,translation+framea,translationcm+frame_a)connect(frameb,translation+frameb)connect(translationcm+frame_b,body+framea)translation.phi(t)=translation.framea.phi(t)translation.w(t)=dtranslation.phi(t)dttranslation.r0(t)=arrayliteral([22],cos(translation.phi(t)),sin(translation.phi(t)),sin(translation.phi(t)),cos(translation.phi(t)))translation.rtranslation.r0(t)=arrayliteral([2],translation.frameb.x(t)translation.framea.x(t),translation.frameb.y(t)translation.framea.y(t))translation.framea.phi(t)=translation.frameb.phi(t)translation.framea.fx(t)+translation.frameb.fx(t)=0translation.frameb.fy(t)+translation.framea.fy(t)=0translation.framea.tau(t)+translation.frameb.tau(t)translation.frameb.fx(t)translation.r02(t)+translation.frameb.fy(t)translation.r01(t)=0translation.shape.r(t)=arrayliteral([3],translation.framea.x(t),translation.framea.y(t),translation.zposition)translation.shape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)translation.shape.rshape(t)=[000]translation.shape.lengthdirection(t)=arrayliteral([3],translation.r01(t)translation.l,translation.r02(t)translation.l,0)translation.shape.widthdirection(t)=[001]translation.shape.length(t)=translation.ltranslation.shape.width(t)=2translation.radiustranslation.shape.height(t)=2translation.radiustranslationcm.phi(t)=translationcm.frame_a.phi(t)translationcm.w(t)=dtranslationcm.phi(t)dttranslationcm.r0(t)=arrayliteral([22],cos(translationcm.phi(t)),sin(translationcm.phi(t)),sin(translationcm.phi(t)),cos(translationcm.phi(t)))translationcm.rtranslationcm.r0(t)=arrayliteral([2],translationcm.frame_b.x(t)translationcm.frame_a.x(t),translationcm.frame_b.y(t)translationcm.frame_a.y(t))translationcm.frame_a.phi(t)=translationcm.frame_b.phi(t)translationcm.frame_a.fx(t)+translationcm.frame_b.fx(t)=0translationcm.frame_b.fy(t)+translationcm.frame_a.fy(t)=0translationcm.frame_a.tau(t)+translationcm.frame_b.tau(t)+translationcm.frame_b.fy(t)translationcm.r0_1(t)translationcm.r0_2(t)translationcm.frame_b.fx(t)=0translationcm.shape.r(t)=arrayliteral([3],translationcm.frame_a.x(t),translationcm.frame_a.y(t),translationcm.z_position)translationcm.shape.R(t)=arrayliteral([33],1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)translationcm.shape.r_shape(t)=[000]translationcm.shape.length_direction(t)=arrayliteral([3],translationcm.r0_1(t)translationcm.l,translationcm.r0_2(t)translationcm.l,0)translationcm.shape.width_direction(t)=[001]translationcm.shape.length(t)=translationcm.ltranslationcm.shape.width(t)=2translationcm.radiustranslationcm.shape.height(t)=2translationcm.radiusbody.r(t)=arrayliteral([2],body.framea.x(t),body.framea.y(t))body.v(t)=dbody.r(t)dtbody.phi(t)=body.framea.phi(t)body.w(t)=dbody.phi(t)dtbody.a(t)=dbody.v(t)dtbody.alpha(t)=dbody.w(t)dtbody.f(t)=arrayliteral([2],body.framea.fx(t),body.framea.fy(t))body.f(t)+arrayliteral([2],body.mgn2d1,body.mgn2d2)=body.mbody.a(t)body.Ibody.alpha(t)=body.framea.tau(t)body.shape.r(t)=arrayliteral([3],body.framea.x(t),body.framea.y(t),body.zposition)body.shape.R(t)=arrayliteral([33],cos(body.phi(t)),sin(body.phi(t)),0,sin(body.phi(t)),cos(body.phi(t)),0,0,0,1)body.shape.rshape(t)=[000]body.shape.lengthdirection(t)=[001]body.shape.widthdirection(t)=[100]body.shape.length(t)=2body.radiusbody.shape.width(t)=2body.radiusbody.shape.height(t)=2body.radius]

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 = [0.5019608, 0.0, 0.5019608, 1.0])
  translation = FixedTranslation(r = r, render = false)
  translation_cm = FixedTranslation(r = r_cm, render = false)
  body = Body(m = m, I = I, render = false)
  "Visualization shape for the rod (cylinder from frame_a to frame_b)"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = color)
  "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] = [0.5, 0]
  "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 = 0.1
  "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)
  # Rod shape position and orientation (2D lifted to 3D)
  rod_shape.r = [frame_a.x, frame_a.y, z_position]
  rod_shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  rod_shape.r_shape = [0, 0, 0]
  rod_shape.length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0]
  rod_shape.width_direction = [0, 0, 1]
  rod_shape.length = l
  rod_shape.width = 2 * radius
  rod_shape.height = 2 * radius
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 = 0.7
  translation = FixedTranslation(r = r, render = false)
  translation_cm = FixedTranslation(r = r_cm, render = false)
  body = Body(m = m, I = I, render = false)
  "Visualization shape for the rod (cylinder from frame_a to frame_b)"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = color)
  "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] = [0.5, 0]
  "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 = 0.1
  "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)
  # Rod shape position and orientation (2D lifted to 3D)
  rod_shape.r = [frame_a.x, frame_a.y, z_position]
  rod_shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  rod_shape.r_shape = [0, 0, 0]
  rod_shape.length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0]
  rod_shape.width_direction = [0, 0, 1]
  rod_shape.length = l
  rod_shape.width = 2 * radius
  rod_shape.height = 2 * radius
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.