Skip to content
LIBRARY
PlanarMechanics.FixedTranslation.md

PlanarMechanics.FixedTranslation

A fixed translation between two components (rigid rod). The translation vector is resolved w.r.t. body frame_a at phi = 0.

This component extends from PartialTwoFrames This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.FixedTranslation(render=true, color=[0.5019608, 0.0, 0.5019608, 1.0], specular_coefficient=0.7, r=[1, 0], l=norm(r), radius=0.1, z_position=0)

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0.5019608, 0, 0.5019608, 1]
specular_coefficient0.7
rFixed x,y-length of the rod resolved w.r.t to body frame_a at phi = 0m[1, 0]
radiusRadius of the rod in animations0.1
z_positionz-position of the rod 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)

Variables

NameDescriptionUnits
phiAnglerad
wAngular velocityrad/s
r0

Behavior

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

Source

dyad
"""
A fixed translation between two components (rigid rod).
The translation vector is resolved w.r.t. body frame_a at phi = 0.
"""
component FixedTranslation
  extends PartialTwoFrames
  extends MultibodyComponents.Renderable(color = [0.5019608, 0.0, 0.5019608, 1.0])
  "Visualization shape for the rod"
  shape = MultibodyComponents.CylinderShape(render = render, color = color)
  "Fixed x,y-length of the rod resolved w.r.t to body frame_a at phi = 0"
  parameter r::Length[2] = [1, 0]
  final parameter l::Length = norm(r)
  "Radius of the rod in animations"
  parameter radius::Real = 0.1
  "z-position of the rod in animations"
  parameter z_position::Real = 0
  "Angle"
  variable phi::Angle
  "Angular velocity"
  variable w::AngularVelocity
  variable r0::Real[2]
relations
  phi = frame_a.phi
  w = der(phi)
  # rotate the rod vector by the current angle
  r0 = [[cos(phi), -sin(phi)], [sin(phi), cos(phi)]] * r
  # position constraint
  r0 = [frame_b.x, frame_b.y] - [frame_a.x, frame_a.y]
  # rigidly transfer rotation
  frame_a.phi = frame_b.phi
  # force balance
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  # torque balance with lever-arm contribution
  frame_a.tau + frame_b.tau + dot(r0, [frame_b.fy, -frame_b.fx]) = 0
  # set shape position and orientation (2D lifted to 3D)
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [r0[1] / l, r0[2] / l, 0]
  shape.width_direction = [0, 0, 1]
  shape.length = l
  shape.width = 2 * radius
  shape.height = 2 * radius
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/FixedTranslation.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 280,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
Flattened Source
dyad
"""
A fixed translation between two components (rigid rod).
The translation vector is resolved w.r.t. body frame_a at phi = 0.
"""
component FixedTranslation
  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
  "Visualization shape for the rod"
  shape = MultibodyComponents.CylinderShape(render = render, color = color)
  "Fixed x,y-length of the rod resolved w.r.t to body frame_a at phi = 0"
  parameter r::Length[2] = [1, 0]
  final parameter l::Length = norm(r)
  "Radius of the rod in animations"
  parameter radius::Real = 0.1
  "z-position of the rod in animations"
  parameter z_position::Real = 0
  "Angle"
  variable phi::Angle
  "Angular velocity"
  variable w::AngularVelocity
  variable r0::Real[2]
relations
  phi = frame_a.phi
  w = der(phi)
  # rotate the rod vector by the current angle
  r0 = [[cos(phi), -sin(phi)], [sin(phi), cos(phi)]] * r
  # position constraint
  r0 = [frame_b.x, frame_b.y] - [frame_a.x, frame_a.y]
  # rigidly transfer rotation
  frame_a.phi = frame_b.phi
  # force balance
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  # torque balance with lever-arm contribution
  frame_a.tau + frame_b.tau + dot(r0, [frame_b.fy, -frame_b.fx]) = 0
  # set shape position and orientation (2D lifted to 3D)
  shape.r = [frame_a.x, frame_a.y, z_position]
  shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
  shape.r_shape = [0, 0, 0]
  shape.length_direction = [r0[1] / l, r0[2] / l, 0]
  shape.width_direction = [0, 0, 1]
  shape.length = l
  shape.width = 2 * radius
  shape.height = 2 * radius
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/FixedTranslation.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 280,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end


Test Cases

No test cases defined.