Skip to content

Commit 28de12f

Browse files
baggepinnenclaude
andcommitted
Place DyadBot3D center of mass explicitly instead of relying on BodyShape offset doubling
The 3D BodyShape places the center of mass at twice the requested r_cm offset (JuliaComputing/MultibodyComponents.jl#149); DyadBot3D's body only ended up with its center of mass at body_height because of that doubling. Use a plain Body with an explicit r_cm instead, preserving the physical behavior without depending on the bug. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 56ed1ec commit 28de12f

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

dyad/segway_3d.dyad

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ component DyadBot3D
2626
"Small mass at the center of the axle"
2727
axis_body = MultibodyComponents.Body(m = 0.01, r_cm = [0, 0, 0]) {^axis_body}
2828
"Main body extending upward from the axle"
29-
body = MultibodyComponents.BodyShape(m = body_mass, I_11 = 0.01 * 0.05 ^ 2, I_22 = 0.01 * 0.03 ^ 2, I_33 = 0.01 * 0.05 ^ 2, r = [0, body_height, 0]) {^body}
29+
# A plain Body with an explicit r_cm is used instead of BodyShape, which
30+
# places the center of mass at twice the requested r_cm offset
31+
# (JuliaComputing/MultibodyComponents.jl issue 149).
32+
body = MultibodyComponents.Body(m = body_mass, r_cm = [0, body_height, 0], I_11 = 0.01 * 0.05 ^ 2, I_22 = 0.01 * 0.03 ^ 2, I_33 = 0.01 * 0.05 ^ 2) {^body}
3033
damper_left = RotationalComponents.Components.Damper(d = d_wheel) {^damper_left}
3134
damper_right = RotationalComponents.Components.Damper(d = d_wheel) {^damper_right}
3235
"Use a compliant (elastic) vertical wheel-ground contact instead of a rigid contact constraint"
@@ -218,9 +221,9 @@ component RollingDyadBot3D
218221
wheels = MultibodyComponents.RollingWheelSet(radius = R, m_wheel = m / 2, I_axis = Iw / 2, I_long = Iw / 4, track = track) {^wheels}
219222
"Body tilt joint about the axle axis"
220223
pitch = MultibodyComponents.Revolute(n = [0, 0, 1]) {^pitch}
221-
# A plain Body is used instead of BodyShape: BodyShape places its inner Body
222-
# at translation_cm.frame_b and additionally passes r_cm on to it, so the
223-
# center of mass would end up at twice the requested offset.
224+
# A plain Body with an explicit r_cm is used instead of BodyShape, which
225+
# places the center of mass at twice the requested r_cm offset
226+
# (JuliaComputing/MultibodyComponents.jl issue 149).
224227
body = MultibodyComponents.Body(color = [0.2, 0.2, 0.2, 0.9], m = M, r_cm = [0, L, 0], I_11 = Ib, I_22 = Ib / 10, I_33 = Ib) {^body}
225228
"Splits the motor torque equally between the two wheels"
226229
gain_half = BlockComponents.Math.Gain(k = 0.5) {^gain_half}

generated/DyadBot3D_definition.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ stacks, with both rigid and compliant vertical contact.
130130
# Subcomponent axis_body of type MultibodyComponents.Body
131131
axis_body_overrides = __pop_subcomponent_overrides!(__overrides, "axis_body")
132132
push!(__systems, @named axis_body = MultibodyComponents.Body(; m=0.01, r_cm=[Float64(0), Float64(0), Float64(0)], axis_body_overrides...))
133-
# Subcomponent body of type MultibodyComponents.BodyShape
133+
# Subcomponent body of type MultibodyComponents.Body
134134
body_overrides = __pop_subcomponent_overrides!(__overrides, "body")
135-
push!(__systems, @named body = MultibodyComponents.BodyShape(; m=body_mass, I_11=0.01 * 0.05 ^ 2, I_22=0.01 * 0.03 ^ 2, I_33=0.01 * 0.05 ^ 2, r=[Float64(0), body_height, Float64(0)], body_overrides...))
135+
push!(__systems, @named body = MultibodyComponents.Body(; m=body_mass, r_cm=[Float64(0), body_height, Float64(0)], I_11=0.01 * 0.05 ^ 2, I_22=0.01 * 0.03 ^ 2, I_33=0.01 * 0.05 ^ 2, body_overrides...))
136136
# Subcomponent damper_left of type RotationalComponents.Components.Damper
137137
damper_left_overrides = __pop_subcomponent_overrides!(__overrides, "damper_left")
138138
push!(__systems, @named damper_left = RotationalComponents.Components.Damper(; d=d_wheel, damper_left_overrides...))

0 commit comments

Comments
 (0)