Skip to content
LIBRARY
PlanarMechanics.FrameVisualizer2D.md

PlanarMechanics.FrameVisualizer2D

Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).

Attach to any Frame2D connector to display its coordinate axes. The z-axis is not part of the 2D frame but is drawn perpendicular to the plane for visual reference.

This component extends from MultibodyComponents.Renderable

Usage

MultibodyComponents.PlanarMechanics.FrameVisualizer2D(render=true, color=[0.5, 0.5, 0.5, 1.0], specular_coefficient=0.7, axis_length=0.1, axis_radius=axis_length / 20, z_position=0)

Parameters:

NameDescriptionUnitsDefault value
rendertrue
color[0.5, 0.5, 0.5, 1]
specular_coefficient0.7
axis_lengthLength of the axis arrows0.1
axis_radiusRadius of the axis cylindersaxis_length / 20
z_positionz-position 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
phiFrame anglerad

Behavior

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

Source

dyad
"""
Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).

Attach to any Frame2D connector to display its coordinate axes. The z-axis
is not part of the 2D frame but is drawn perpendicular to the plane for
visual reference.
"""
component FrameVisualizer2D
  extends MultibodyComponents.Renderable
  frame_a = Frame2D() {}
  "X-axis shape (red)"
  x_shape = MultibodyComponents.CylinderShape(color = [1, 0, 0, 1])
  "Y-axis shape (green)"
  y_shape = MultibodyComponents.CylinderShape(color = [0, 1, 0, 1])
  "Z-axis shape (blue)"
  z_shape = MultibodyComponents.CylinderShape(color = [0, 0, 1, 1])
  "Length of the axis arrows"
  parameter axis_length::Real = 0.1
  "Radius of the axis cylinders"
  parameter axis_radius::Real = axis_length / 20
  "z-position in animations"
  parameter z_position::Real = 0
  "Frame angle"
  variable phi::Angle
relations
  phi = frame_a.phi
  # Zero forces/torques (sensor-like, does not affect dynamics)
  #frame_a.fx = 0
  #frame_a.fy = 0
  #frame_a.tau = 0
  # X-axis: along local x direction, rotated by frame angle
  x_shape.r = [frame_a.x, frame_a.y, z_position]
  x_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  x_shape.r_shape = [0, 0, 0]
  x_shape.length_direction = [1, 0, 0]
  x_shape.width_direction = [0, 0, 1]
  x_shape.length = axis_length
  x_shape.width = 2 * axis_radius
  x_shape.height = 2 * axis_radius
  # Y-axis: along local y direction, same rotation
  y_shape.r = [frame_a.x, frame_a.y, z_position]
  y_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  y_shape.r_shape = [0, 0, 0]
  y_shape.length_direction = [0, 1, 0]
  y_shape.width_direction = [0, 0, 1]
  y_shape.length = axis_length
  y_shape.width = 2 * axis_radius
  y_shape.height = 2 * axis_radius
  # Z-axis: perpendicular to the plane, same rotation
  z_shape.r = [frame_a.x, frame_a.y, z_position]
  z_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  z_shape.r_shape = [0, 0, 0]
  z_shape.length_direction = [0, 0, 1]
  z_shape.width_direction = [1, 0, 0]
  z_shape.length = axis_length
  z_shape.width = 2 * axis_radius
  z_shape.height = 2 * axis_radius
end
Flattened Source
dyad
"""
Visualizes a 2D frame as three colored axis cylinders (red=x, green=y, blue=z).

Attach to any Frame2D connector to display its coordinate axes. The z-axis
is not part of the 2D frame but is drawn perpendicular to the plane for
visual reference.
"""
component FrameVisualizer2D
  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() {}
  "X-axis shape (red)"
  x_shape = MultibodyComponents.CylinderShape(color = [1, 0, 0, 1])
  "Y-axis shape (green)"
  y_shape = MultibodyComponents.CylinderShape(color = [0, 1, 0, 1])
  "Z-axis shape (blue)"
  z_shape = MultibodyComponents.CylinderShape(color = [0, 0, 1, 1])
  "Length of the axis arrows"
  parameter axis_length::Real = 0.1
  "Radius of the axis cylinders"
  parameter axis_radius::Real = axis_length / 20
  "z-position in animations"
  parameter z_position::Real = 0
  "Frame angle"
  variable phi::Angle
relations
  phi = frame_a.phi
  # Zero forces/torques (sensor-like, does not affect dynamics)
  #frame_a.fx = 0
  #frame_a.fy = 0
  #frame_a.tau = 0
  # X-axis: along local x direction, rotated by frame angle
  x_shape.r = [frame_a.x, frame_a.y, z_position]
  x_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  x_shape.r_shape = [0, 0, 0]
  x_shape.length_direction = [1, 0, 0]
  x_shape.width_direction = [0, 0, 1]
  x_shape.length = axis_length
  x_shape.width = 2 * axis_radius
  x_shape.height = 2 * axis_radius
  # Y-axis: along local y direction, same rotation
  y_shape.r = [frame_a.x, frame_a.y, z_position]
  y_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  y_shape.r_shape = [0, 0, 0]
  y_shape.length_direction = [0, 1, 0]
  y_shape.width_direction = [0, 0, 1]
  y_shape.length = axis_length
  y_shape.width = 2 * axis_radius
  y_shape.height = 2 * axis_radius
  # Z-axis: perpendicular to the plane, same rotation
  z_shape.r = [frame_a.x, frame_a.y, z_position]
  z_shape.R = MultibodyComponents.RR(MultibodyComponents.axis_rotation(3, phi))
  z_shape.r_shape = [0, 0, 0]
  z_shape.length_direction = [0, 0, 1]
  z_shape.width_direction = [1, 0, 0]
  z_shape.length = axis_length
  z_shape.width = 2 * axis_radius
  z_shape.height = 2 * axis_radius
metadata {}
end


Test Cases

No test cases defined.

  • Examples

  • Experiments

  • Analyses