Skip to content
LIBRARY
PlanarMechanics.Body.md

PlanarMechanics.Body

Body component with mass and inertia.

Newton's second law: f + m*gravity_acceleration_2d() = m*a and I*alpha = tau. Gravity is set globally via the PlanarMechanics.World component.

This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.Body(render=true, color=[0.5019608, 0.0, 0.5019608, 1.0], specular_coefficient=0.7, m, I, radius=0.1, z_position=0)

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0.5019608, 0, 0.5019608, 1]
specular_coefficient0.7
mMass of the bodykg
IInertia of the body with respect to the origin of frame_a along the z-axis of frame_akg.m2
radiusRadius of the body sphere in animations0.1
z_positionz-position of the body 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)

Variables

NameDescriptionUnits
fForceN
rx,y positionm
vx,y velocitym/s
ax,y accelerationm/s2
phiRotation anglerad
wAngular velocityrad/s
alphaAngular accelerationrad/s2

Behavior

Dict{MIME{Symbol("text/plain")}, String} with 1 entry: MIME type text/plain => "Error displaying result"

Source

dyad
"""
Body component with mass and inertia.

Newton's second law: `f + m*gravity_acceleration_2d() = m*a` and `I*alpha = tau`.
Gravity is set globally via the PlanarMechanics.World component.
"""
component Body
  extends MultibodyComponents.Renderable(color = [0.5019608, 0.0, 0.5019608, 1.0])
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Visualization shape for the body"
  shape = MultibodyComponents.SphereShape(render = render, color = color)
  "Mass of the body"
  parameter m::Dyad.Mass
  "Inertia of the body with respect to the origin of frame_a along the z-axis of frame_a"
  parameter I::MomentOfInertia
  "Radius of the body sphere in animations"
  parameter radius::Real = 0.1
  "z-position of the body in animations"
  parameter z_position::Real = 0
  "Force"
  variable f::Dyad.Force[2]
  "x,y position"
  variable r::Dyad.Position(statePriority = 1)[2]
  "x,y velocity"
  variable v::Velocity(statePriority = 1)[2]
  "x,y acceleration"
  variable a::Acceleration[2]
  "Rotation angle"
  variable phi::Angle(statePriority = 2)
  "Angular velocity"
  variable w::AngularVelocity(statePriority = 2)
  "Angular acceleration"
  variable alpha::AngularAcceleration
relations
  # position from frame
  r = [frame_a.x, frame_a.y]
  v = der(r)
  phi = frame_a.phi
  w = der(phi)
  # acceleration
  a = der(v)
  alpha = der(w)
  # newton's law
  f = [frame_a.fx, frame_a.fy]
  f + m * gravity_acceleration_2d() = m * a
  I * alpha = frame_a.tau
  # set shape position and orientation (2D lifted to 3D)
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [0, 0, 1]
  shape.width_direction = [1, 0, 0]
  shape.length = 2 * radius
  shape.width = 2 * radius
  shape.height = 2 * radius
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/Body.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
Flattened Source
dyad
"""
Body component with mass and inertia.

Newton's second law: `f + m*gravity_acceleration_2d() = m*a` and `I*alpha = tau`.
Gravity is set globally via the PlanarMechanics.World component.
"""
component Body
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 0.7
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Visualization shape for the body"
  shape = MultibodyComponents.SphereShape(render = render, color = color)
  "Mass of the body"
  parameter m::Dyad.Mass
  "Inertia of the body with respect to the origin of frame_a along the z-axis of frame_a"
  parameter I::MomentOfInertia
  "Radius of the body sphere in animations"
  parameter radius::Real = 0.1
  "z-position of the body in animations"
  parameter z_position::Real = 0
  "Force"
  variable f::Dyad.Force[2]
  "x,y position"
  variable r::Dyad.Position(statePriority = 1)[2]
  "x,y velocity"
  variable v::Velocity(statePriority = 1)[2]
  "x,y acceleration"
  variable a::Acceleration[2]
  "Rotation angle"
  variable phi::Angle(statePriority = 2)
  "Angular velocity"
  variable w::AngularVelocity(statePriority = 2)
  "Angular acceleration"
  variable alpha::AngularAcceleration
relations
  # position from frame
  r = [frame_a.x, frame_a.y]
  v = der(r)
  phi = frame_a.phi
  w = der(phi)
  # acceleration
  a = der(v)
  alpha = der(w)
  # newton's law
  f = [frame_a.fx, frame_a.fy]
  f + m * gravity_acceleration_2d() = m * a
  I * alpha = frame_a.tau
  # set shape position and orientation (2D lifted to 3D)
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [0, 0, 1]
  shape.width_direction = [1, 0, 0]
  shape.length = 2 * radius
  shape.width = 2 * radius
  shape.height = 2 * radius
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/Body.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end


Test Cases

No test cases defined.