Skip to content
LIBRARY
PlanarMechanics.World.md

PlanarMechanics.World

The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component. The frame_b is fixed at the origin with zero orientation.

Global gravity parameters (n, g) are set here and referenced by Body components via gravity_acceleration_2d.

Usage

MultibodyComponents.PlanarMechanics.World(render=true, n=[0, -1], g=9.80665, nominal_length=1, default_joint_length=nominal_length / 10, default_joint_width=nominal_length / 20, default_body_diameter=nominal_length / 9, default_width_fraction=20, default_arrow_diameter=nominal_length / 40, default_force_length=nominal_length / 10, default_force_width=nominal_length / 20, default_N_to_m=1000, default_Nm_to_m=1000, default_z_position=0, r_0_3d=[0, 0, 0], rot_3d=[0, 0, 0], default_body_color=[0.5019608, 0.0, 0.5019608, 1.0], default_rod_color=[0.5019608, 0.0, 0.5019608, 1.0], default_joint_color=[1, 0, 0, 1], default_prismatic_color=[0, 0.8, 1, 1], default_spring_color=[0, 0, 1, 1], default_force_color=[0, 1, 0, 0.5], default_sensor_color=[0, 1, 0, 0.5], render_ground=false, ground_length_u=2, ground_length_v=2, ground_color=[0.784, 0.784, 0.784, 1.0])

Parameters:

NameDescriptionUnitsDefault value
rendertrue
ngravity direction (unit vector in 2D plane)[0, -1]
ggravitational acceleration magnitudem/s29.80665
nominal_lengthNominal length for scaling visualization defaults1
default_joint_lengthDefault length of joint shapesnominal_length / 10
default_joint_widthDefault width of joint shapesnominal_length / 20
default_body_diameterDefault diameter of body spheresnominal_length / 9
default_width_fractionDefault width fraction (width = length/fraction)20
default_arrow_diameterDefault arrow shaft diameternominal_length / 40
default_force_lengthDefault force visualization lengthnominal_length / 10
default_force_widthDefault force visualization widthnominal_length / 20
default_N_to_mDefault force arrow scaling (N/m)1000
default_Nm_to_mDefault torque arrow scaling (Nm/m)1000
default_z_positionDefault out-of-plane position where the planar plane sits in the 3D worldm0
r_0_3dPosition of the planar-world origin in the 3D world frame (for embedding a planar model into 3D)m[0, 0, 0]
rot_3dOrientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D)rad[0, 0, 0]
default_body_colorDefault body color (RGBA)[0.5019608,...19608, 1.0]
default_rod_colorDefault rod/translation color (RGBA)[0.5019608,...19608, 1.0]
default_joint_colorDefault joint color (RGBA)[1, 0, 0, 1]
default_prismatic_colorDefault prismatic joint color (RGBA)[0, 0.8, 1, 1]
default_spring_colorDefault spring color (RGBA)[0, 0, 1, 1]
default_force_colorDefault force/torque color (RGBA)[0, 1, 0, 0.5]
default_sensor_colorDefault sensor color (RGBA)[0, 1, 0, 0.5]
render_groundWhether to render the world ground planefalse
ground_length_uLength of ground plane along x axis2
ground_length_vLength of ground plane along y axis2
ground_colorRGBA color of the ground plane[0.784, 0.7...0.784, 1.0]

Connectors

  • 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

@example
using MultibodyComponents #hide
using ModelingToolkit #hide
@variables render #hide
@variables n #hide
@variables g #hide
@variables nominal_length #hide
@variables default_joint_length #hide
@variables default_joint_width #hide
@variables default_body_diameter #hide
@variables default_width_fraction #hide
@variables default_arrow_diameter #hide
@variables default_force_length #hide
@variables default_force_width #hide
@variables default_N_to_m #hide
@variables default_Nm_to_m #hide
@variables default_z_position #hide
@variables r_0_3d #hide
@variables rot_3d #hide
@variables default_body_color #hide
@variables default_rod_color #hide
@variables default_joint_color #hide
@variables default_prismatic_color #hide
@variables default_spring_color #hide
@variables default_force_color #hide
@variables default_sensor_color #hide
@variables render_ground #hide
@variables ground_length_u #hide
@variables ground_length_v #hide
@variables ground_color #hide
@named sys = MultibodyComponents.PlanarMechanics.World(render=render, n=n, g=g, nominal_length=nominal_length, default_joint_length=default_joint_length, default_joint_width=default_joint_width, default_body_diameter=default_body_diameter, default_width_fraction=default_width_fraction, default_arrow_diameter=default_arrow_diameter, default_force_length=default_force_length, default_force_width=default_force_width, default_N_to_m=default_N_to_m, default_Nm_to_m=default_Nm_to_m, default_z_position=default_z_position, r_0_3d=r_0_3d, rot_3d=rot_3d, default_body_color=default_body_color, default_rod_color=default_rod_color, default_joint_color=default_joint_color, default_prismatic_color=default_prismatic_color, default_spring_color=default_spring_color, default_force_color=default_force_color, default_sensor_color=default_sensor_color, render_ground=render_ground, ground_length_u=ground_length_u, ground_length_v=ground_length_v, ground_color=ground_color) #hide
let eqs = full_equations(sys); Base.length(eqs) > 25 ? nothing : eqs end #hide

Source

dyad
"""
The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component.
The `frame_b` is fixed at the origin with zero orientation.

Global gravity parameters (`n`, `g`) are set here and referenced by
Body components via `gravity_acceleration_2d`.
"""
external component World
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  "gravity direction (unit vector in 2D plane)"
  parameter n::Real[2] = [0, -1]
  "gravitational acceleration magnitude"
  parameter g::Acceleration = 9.80665
  "Nominal length for scaling visualization defaults"
  parameter nominal_length::Real = 1
  "Default length of joint shapes"
  parameter default_joint_length::Real = nominal_length / 10
  "Default width of joint shapes"
  parameter default_joint_width::Real = nominal_length / 20
  "Default diameter of body spheres"
  parameter default_body_diameter::Real = nominal_length / 9
  "Default width fraction (width = length/fraction)"
  parameter default_width_fraction::Real = 20
  "Default arrow shaft diameter"
  parameter default_arrow_diameter::Real = nominal_length / 40
  "Default force visualization length"
  parameter default_force_length::Real = nominal_length / 10
  "Default force visualization width"
  parameter default_force_width::Real = nominal_length / 20
  "Default force arrow scaling (N/m)"
  parameter default_N_to_m::Real = 1000
  "Default torque arrow scaling (Nm/m)"
  parameter default_Nm_to_m::Real = 1000
  "Default out-of-plane position where the planar plane sits in the 3D world"
  parameter default_z_position::Length = 0
  "Position of the planar-world origin in the 3D world frame (for embedding a planar model into 3D)"
  parameter r_0_3d::Position[3] = [0, 0, 0]
  "Orientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D)"
  parameter rot_3d::Angle[3] = [0, 0, 0]
  "Default body color (RGBA)"
  parameter default_body_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default rod/translation color (RGBA)"
  parameter default_rod_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default joint color (RGBA)"
  parameter default_joint_color::Real[4] = [1, 0, 0, 1]
  "Default prismatic joint color (RGBA)"
  parameter default_prismatic_color::Real[4] = [0, 0.8, 1, 1]
  "Default spring color (RGBA)"
  parameter default_spring_color::Real[4] = [0, 0, 1, 1]
  "Default force/torque color (RGBA)"
  parameter default_force_color::Real[4] = [0, 1, 0, 0.5]
  "Default sensor color (RGBA)"
  parameter default_sensor_color::Real[4] = [0, 1, 0, 0.5]
  "Whether to render the world ground plane"
  parameter render_ground::Boolean = false
  "Length of ground plane along x axis"
  parameter ground_length_u::Real = 2
  "Length of ground plane along y axis"
  parameter ground_length_v::Real = 2
  "RGBA color of the ground plane"
  parameter ground_color::Real[4] = [0.784, 0.784, 0.784, 1.0]
relations
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "g = $(g)",
        "x": 70,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      },
      {
        "label": "n = $(n)",
        "x": 930,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      }
    ],
    "icons": {"default": "dyad://MultibodyComponents/World.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end
Flattened Source
dyad
"""
The root component for all 2D planar mechanics models.

Every planar model must include exactly one PlanarMechanics.World component.
The `frame_b` is fixed at the origin with zero orientation.

Global gravity parameters (`n`, `g`) are set here and referenced by
Body components via `gravity_acceleration_2d`.
"""
external component World
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  "gravity direction (unit vector in 2D plane)"
  parameter n::Real[2] = [0, -1]
  "gravitational acceleration magnitude"
  parameter g::Acceleration = 9.80665
  "Nominal length for scaling visualization defaults"
  parameter nominal_length::Real = 1
  "Default length of joint shapes"
  parameter default_joint_length::Real = nominal_length / 10
  "Default width of joint shapes"
  parameter default_joint_width::Real = nominal_length / 20
  "Default diameter of body spheres"
  parameter default_body_diameter::Real = nominal_length / 9
  "Default width fraction (width = length/fraction)"
  parameter default_width_fraction::Real = 20
  "Default arrow shaft diameter"
  parameter default_arrow_diameter::Real = nominal_length / 40
  "Default force visualization length"
  parameter default_force_length::Real = nominal_length / 10
  "Default force visualization width"
  parameter default_force_width::Real = nominal_length / 20
  "Default force arrow scaling (N/m)"
  parameter default_N_to_m::Real = 1000
  "Default torque arrow scaling (Nm/m)"
  parameter default_Nm_to_m::Real = 1000
  "Default out-of-plane position where the planar plane sits in the 3D world"
  parameter default_z_position::Length = 0
  "Position of the planar-world origin in the 3D world frame (for embedding a planar model into 3D)"
  parameter r_0_3d::Position[3] = [0, 0, 0]
  "Orientation of the planar world in the 3D world as XYZ Euler angles (for embedding a planar model into 3D)"
  parameter rot_3d::Angle[3] = [0, 0, 0]
  "Default body color (RGBA)"
  parameter default_body_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default rod/translation color (RGBA)"
  parameter default_rod_color::Real[4] = [0.5019608, 0.0, 0.5019608, 1.0]
  "Default joint color (RGBA)"
  parameter default_joint_color::Real[4] = [1, 0, 0, 1]
  "Default prismatic joint color (RGBA)"
  parameter default_prismatic_color::Real[4] = [0, 0.8, 1, 1]
  "Default spring color (RGBA)"
  parameter default_spring_color::Real[4] = [0, 0, 1, 1]
  "Default force/torque color (RGBA)"
  parameter default_force_color::Real[4] = [0, 1, 0, 0.5]
  "Default sensor color (RGBA)"
  parameter default_sensor_color::Real[4] = [0, 1, 0, 0.5]
  "Whether to render the world ground plane"
  parameter render_ground::Boolean = false
  "Length of ground plane along x axis"
  parameter ground_length_u::Real = 2
  "Length of ground plane along y axis"
  parameter ground_length_v::Real = 2
  "RGBA color of the ground plane"
  parameter ground_color::Real[4] = [0.784, 0.784, 0.784, 1.0]
relations
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "g = $(g)",
        "x": 70,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      },
      {
        "label": "n = $(n)",
        "x": 930,
        "y": 970,
        "rot": 0,
        "layer": "all",
        "attrs": {
          "fill": "black",
          "font-size": "12",
          "dominant-baseline": "central",
          "text-anchor": "left"
        }
      }
    ],
    "icons": {"default": "dyad://MultibodyComponents/World.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end


Test Cases

No test cases defined.