LIBRARY
PlanarMechanics.BodyShape
Body with shape: a rigid rod (FixedTranslation) from frame_a to frame_b with a Body attached at the center of mass via a second FixedTranslation.
This component extends from PartialTwoFrames This component extends from MultibodyComponents.Renderable
Usage
MultibodyComponents.PlanarMechanics.BodyShape(render=true, color=[0.5019608, 0.0, 0.5019608, 1.0], specular_coefficient=0.7, r=[1, 0], r_cm=[0.5, 0], m=1, I=0.1, radius=0.1, z_position=0, l=sqrt(r[1] ^ 2 + r[2] ^ 2))
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
render | – | true | |
color | – | [0.5019608, 0, 0.5019608, 1] | |
specular_coefficient | – | 0.7 | |
r | Vector from frame_a to frame_b resolved in frame_a | m | [1, 0] |
r_cm | Vector from frame_a to center of mass, resolved in frame_a | m | [0.5, 0] |
m | Mass of the body | kg | 1 |
I | Inertia of the body with respect to the center of mass | kg.m2 | 0.1 |
radius | Radius of the body in animations | – | 0.1 |
z_position | z-position of the body shape in animations | – | 0 |
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)
Behavior
@example
using MultibodyComponents #hide
using ModelingToolkit #hide
@variables render #hide
@variables color #hide
@variables specular_coefficient #hide
@variables r #hide
@variables r_cm #hide
@variables m #hide
@variables I #hide
@variables radius #hide
@variables z_position #hide
@named sys = MultibodyComponents.PlanarMechanics.BodyShape(render=render, color=color, specular_coefficient=specular_coefficient, r=r, r_cm=r_cm, m=m, I=I, radius=radius, z_position=z_position) #hide
full_equations(sys) #hideSource
dyad
"""
Body with shape: a rigid rod (FixedTranslation) from frame_a to frame_b with a
Body attached at the center of mass via a second FixedTranslation.
"""
component BodyShape
extends PartialTwoFrames
extends MultibodyComponents.Renderable(color = [0.5019608, 0.0, 0.5019608, 1.0])
translation = FixedTranslation(r = r, render = false)
translation_cm = FixedTranslation(r = r_cm, render = false)
body = Body(m = m, I = I, render = false)
"Visualization shape for the rod (cylinder from frame_a to frame_b)"
rod_shape = MultibodyComponents.CylinderShape(render = render, color = color)
"Vector from frame_a to frame_b resolved in frame_a"
parameter r::Length[2] = [1, 0]
"Vector from frame_a to center of mass, resolved in frame_a"
parameter r_cm::Length[2] = [0.5, 0]
"Mass of the body"
parameter m::Dyad.Mass = 1
"Inertia of the body with respect to the center of mass"
parameter I::MomentOfInertia = 0.1
"Radius of the body in animations"
parameter radius::Real = 0.1
"z-position of the body shape in animations"
parameter z_position::Real = 0
"Length of rod"
final parameter l::Length = sqrt(r[1] ^ 2 + r[2] ^ 2)
relations
connect(frame_a, translation.frame_a, translation_cm.frame_a)
connect(frame_b, translation.frame_b)
connect(translation_cm.frame_b, body.frame_a)
# Rod shape position and orientation (2D lifted to 3D)
rod_shape.r = [frame_a.x, frame_a.y, z_position]
rod_shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
rod_shape.r_shape = [0, 0, 0]
rod_shape.length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0]
rod_shape.width_direction = [0, 0, 1]
rod_shape.length = l
rod_shape.width = 2 * radius
rod_shape.height = 2 * radius
metadata {
"Dyad": {
"icons": {"default": "dyad://MultibodyComponents/BodyShape.svg"},
"labels": [
{
"label": "$(instance)",
"x": 500,
"y": 240,
"rot": 0,
"attrs": {"font-size": "160"}
}
]
}
}
endFlattened Source
dyad
"""
Body with shape: a rigid rod (FixedTranslation) from frame_a to frame_b with a
Body attached at the center of mass via a second FixedTranslation.
"""
component BodyShape
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
translation = FixedTranslation(r = r, render = false)
translation_cm = FixedTranslation(r = r_cm, render = false)
body = Body(m = m, I = I, render = false)
"Visualization shape for the rod (cylinder from frame_a to frame_b)"
rod_shape = MultibodyComponents.CylinderShape(render = render, color = color)
"Vector from frame_a to frame_b resolved in frame_a"
parameter r::Length[2] = [1, 0]
"Vector from frame_a to center of mass, resolved in frame_a"
parameter r_cm::Length[2] = [0.5, 0]
"Mass of the body"
parameter m::Dyad.Mass = 1
"Inertia of the body with respect to the center of mass"
parameter I::MomentOfInertia = 0.1
"Radius of the body in animations"
parameter radius::Real = 0.1
"z-position of the body shape in animations"
parameter z_position::Real = 0
"Length of rod"
final parameter l::Length = sqrt(r[1] ^ 2 + r[2] ^ 2)
relations
connect(frame_a, translation.frame_a, translation_cm.frame_a)
connect(frame_b, translation.frame_b)
connect(translation_cm.frame_b, body.frame_a)
# Rod shape position and orientation (2D lifted to 3D)
rod_shape.r = [frame_a.x, frame_a.y, z_position]
rod_shape.R = MultibodyComponents.RR(MultibodyComponents.nullrotation())
rod_shape.r_shape = [0, 0, 0]
rod_shape.length_direction = [translation.r0[1] / l, translation.r0[2] / l, 0]
rod_shape.width_direction = [0, 0, 1]
rod_shape.length = l
rod_shape.width = 2 * radius
rod_shape.height = 2 * radius
metadata {
"Dyad": {
"icons": {"default": "dyad://MultibodyComponents/BodyShape.svg"},
"labels": [
{
"label": "$(instance)",
"x": 500,
"y": 240,
"rot": 0,
"attrs": {"font-size": "160"}
}
]
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests