Skip to content
LIBRARY
PlanarMechanics.examples.excavator.PlanarCylinderMount.md

PlanarMechanics.examples.excavator.PlanarCylinderMount

Mounts a translational actuator between two planar frames as a line force element.

The flange position equals the distance between the two frame origins minus s_offset, so a translational actuator (such as a hydraulic cylinder) connected to flange acts along the straight line between the anchor points. A positive flange force pushes the anchors apart. The mount is massless and applies no torque; the actuator inertia acts along the line direction only, which is the standard approximation for cylinder-driven linkages.

An assertion guards the flange position against leaving the interval [0, stroke] (with a small margin for end-stop compliance), where the attached cylinder model is valid; a chamber volume of a DoubleActingCylinder would become non-positive outside it.

The component renders a cylinder barrel anchored at frame_a and a piston rod reaching back from frame_b, overlapping mid-stroke.

This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.examples.excavator.PlanarCylinderMount(render=true, color=[0.85, 0.75, 0.15, 1.0], specular_coefficient=1.5, s_offset=1.0, stroke=1.0, guard_margin=1e-3, barrel_radius=0.05, rod_radius=0.025, barrel_fraction=0.62, rod_fraction=0.55, rod_color=[0.55, 0.57, 0.6, 1.0], z_position=0)

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0.85, 0.75, 0.15, 1.0]
specular_coefficient1.5
s_offsetAnchor distance at zero flange positionm1.0
strokeStroke of the attached actuator, bounding the valid flange positionm1.0
guard_marginAllowed excursion beyond the stroke before the guard assertion firesm1e-3
barrel_radiusRadius of the rendered barrel0.05
rod_radiusRadius of the rendered piston rod0.025
barrel_fractionFraction of the anchor distance covered by the barrel in animations0.62
rod_fractionFraction of the anchor distance covered by the rod in animations0.55
rod_colorColor of the rendered piston rod[0.55, 0.57, 0.6, 1.0]
z_positionz-position of the shapes 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)

  • flange - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. (Flange)

Variables

NameDescriptionUnits
lDistance between the frame originsm
exx-component of the unit vector from frame_a to frame_b
eyy-component of the unit vector from frame_a to frame_b

Behavior

Source

dyad
"""
Mounts a translational actuator between two planar frames as a line force
element.

The flange position equals the distance between the two frame origins minus
`s_offset`, so a translational actuator (such as a hydraulic cylinder) connected
to `flange` acts along the straight line between the anchor points. A positive
flange force pushes the anchors apart. The mount is massless and applies no
torque; the actuator inertia acts along the line direction only, which is the
standard approximation for cylinder-driven linkages.

An assertion guards the flange position against leaving the interval
`[0, stroke]` (with a small margin for end-stop compliance), where the attached
cylinder model is valid; a chamber volume of a `DoubleActingCylinder` would
become non-positive outside it.

The component renders a cylinder barrel anchored at `frame_a` and a piston rod
reaching back from `frame_b`, overlapping mid-stroke.
"""
component PlanarCylinderMount
  extends MultibodyComponents.Renderable(color = [0.85, 0.75, 0.15, 1.0])
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Flange of the translational actuator acting between the frames"
  flange = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  "Barrel visualization anchored at frame_a"
  barrel_shape = MultibodyComponents.CylinderShape(render = render, color = color, r = [frame_a.x, frame_a.y, z_position], length_direction = [ex, ey, 0], width_direction = [0, 0, 1], length = barrel_fraction * l, width = 2 * barrel_radius, height = 2 * barrel_radius)
  "Piston rod visualization anchored at frame_b"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = rod_color, r = [frame_b.x, frame_b.y, z_position], length_direction = [-ex, -ey, 0], width_direction = [0, 0, 1], length = rod_fraction * l, width = 2 * rod_radius, height = 2 * rod_radius)
  "Anchor distance at zero flange position"
  parameter s_offset::Length = 1.0
  "Stroke of the attached actuator, bounding the valid flange position"
  parameter stroke::Length = 1.0
  "Allowed excursion beyond the stroke before the guard assertion fires"
  parameter guard_margin::Length = 1e-3
  "Radius of the rendered barrel"
  parameter barrel_radius::Real = 0.05
  "Radius of the rendered piston rod"
  parameter rod_radius::Real = 0.025
  "Fraction of the anchor distance covered by the barrel in animations"
  parameter barrel_fraction::Real = 0.62
  "Fraction of the anchor distance covered by the rod in animations"
  parameter rod_fraction::Real = 0.55
  "Color of the rendered piston rod"
  parameter rod_color::Real[4] = [0.55, 0.57, 0.6, 1.0]
  "z-position of the shapes in animations"
  parameter z_position::Real = 0
  "Distance between the frame origins"
  variable l::Length
  "x-component of the unit vector from frame_a to frame_b"
  variable ex::Real
  "y-component of the unit vector from frame_a to frame_b"
  variable ey::Real
relations
  l = sqrt((frame_b.x - frame_a.x) ^ 2 + (frame_b.y - frame_a.y) ^ 2)
  ex = (frame_b.x - frame_a.x) / l
  ey = (frame_b.y - frame_a.y) / l
  flange.s = l - s_offset
  # A positive flange force pushes the anchors apart (power balance:
  # flange.f * der(flange.s) + frame_a.f * v_a + frame_b.f * v_b = 0)
  frame_a.fx = flange.f * ex
  frame_a.fy = flange.f * ey
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  frame_a.tau = 0
  frame_b.tau = 0
  assert(flange.s >= -guard_margin and flange.s <= stroke + guard_margin, "Piston extension outside the actuator stroke; the cylinder model is invalid there (a chamber volume becomes non-positive). Increase the cylinder length/stroke or adjust the commanded trajectory.")
metadata {
  "Dyad": {"icons": {"default": "dyad://MultibodyComponents/PlanarCylinderMount.svg"}}
}
end
Flattened Source
dyad
"""
Mounts a translational actuator between two planar frames as a line force
element.

The flange position equals the distance between the two frame origins minus
`s_offset`, so a translational actuator (such as a hydraulic cylinder) connected
to `flange` acts along the straight line between the anchor points. A positive
flange force pushes the anchors apart. The mount is massless and applies no
torque; the actuator inertia acts along the line direction only, which is the
standard approximation for cylinder-driven linkages.

An assertion guards the flange position against leaving the interval
`[0, stroke]` (with a small margin for end-stop compliance), where the attached
cylinder model is valid; a chamber volume of a `DoubleActingCylinder` would
become non-positive outside it.

The component renders a cylinder barrel anchored at `frame_a` and a piston rod
reaching back from `frame_b`, overlapping mid-stroke.
"""
component PlanarCylinderMount
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Flange of the translational actuator acting between the frames"
  flange = Flange() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  "Barrel visualization anchored at frame_a"
  barrel_shape = MultibodyComponents.CylinderShape(render = render, color = color, r = [frame_a.x, frame_a.y, z_position], length_direction = [ex, ey, 0], width_direction = [0, 0, 1], length = barrel_fraction * l, width = 2 * barrel_radius, height = 2 * barrel_radius)
  "Piston rod visualization anchored at frame_b"
  rod_shape = MultibodyComponents.CylinderShape(render = render, color = rod_color, r = [frame_b.x, frame_b.y, z_position], length_direction = [-ex, -ey, 0], width_direction = [0, 0, 1], length = rod_fraction * l, width = 2 * rod_radius, height = 2 * rod_radius)
  "Anchor distance at zero flange position"
  parameter s_offset::Length = 1.0
  "Stroke of the attached actuator, bounding the valid flange position"
  parameter stroke::Length = 1.0
  "Allowed excursion beyond the stroke before the guard assertion fires"
  parameter guard_margin::Length = 1e-3
  "Radius of the rendered barrel"
  parameter barrel_radius::Real = 0.05
  "Radius of the rendered piston rod"
  parameter rod_radius::Real = 0.025
  "Fraction of the anchor distance covered by the barrel in animations"
  parameter barrel_fraction::Real = 0.62
  "Fraction of the anchor distance covered by the rod in animations"
  parameter rod_fraction::Real = 0.55
  "Color of the rendered piston rod"
  parameter rod_color::Real[4] = [0.55, 0.57, 0.6, 1.0]
  "z-position of the shapes in animations"
  parameter z_position::Real = 0
  "Distance between the frame origins"
  variable l::Length
  "x-component of the unit vector from frame_a to frame_b"
  variable ex::Real
  "y-component of the unit vector from frame_a to frame_b"
  variable ey::Real
relations
  l = sqrt((frame_b.x - frame_a.x) ^ 2 + (frame_b.y - frame_a.y) ^ 2)
  ex = (frame_b.x - frame_a.x) / l
  ey = (frame_b.y - frame_a.y) / l
  flange.s = l - s_offset
  # A positive flange force pushes the anchors apart (power balance:
  # flange.f * der(flange.s) + frame_a.f * v_a + frame_b.f * v_b = 0)
  frame_a.fx = flange.f * ex
  frame_a.fy = flange.f * ey
  frame_a.fx + frame_b.fx = 0
  frame_a.fy + frame_b.fy = 0
  frame_a.tau = 0
  frame_b.tau = 0
  assert(flange.s >= -guard_margin and flange.s <= stroke + guard_margin, "Piston extension outside the actuator stroke; the cylinder model is invalid there (a chamber volume becomes non-positive). Increase the cylinder length/stroke or adjust the commanded trajectory.")
metadata {
  "Dyad": {"icons": {"default": "dyad://MultibodyComponents/PlanarCylinderMount.svg"}}
}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses