Skip to content
LIBRARY
PlanarMechanics.OneDOFSlippingWheelSegwayTest.md

PlanarMechanics.OneDOFSlippingWheelSegwayTest

Test for OneDOFSlippingWheelJoint: planar segway model.

Two bodies connected via a FixedTranslation on a slip-based wheel. The heavy body (m=10) acts as a pendulum on the wheel, creating a segway-like motion. Translates the segway test from test_OneDOFWheelJoint.jl.

Usage

MultibodyComponents.PlanarMechanics.OneDOFSlippingWheelSegwayTest()

Behavior

julia
using MultibodyComponents #hide
using ModelingToolkit #hide
@named sys = MultibodyComponents.PlanarMechanics.OneDOFSlippingWheelSegwayTest() #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source

dyad
"""
Test for OneDOFSlippingWheelJoint: planar segway model.

Two bodies connected via a FixedTranslation on a slip-based wheel. The heavy body
(m=10) acts as a pendulum on the wheel, creating a segway-like motion.
Translates the segway test from test_OneDOFWheelJoint.jl.
"""
test component OneDOFSlippingWheelSegwayTest
  world = World(g = 9.82) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 40, "y1": 710, "x2": 140, "y2": 810, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 0.7, I = 0.0001, radius = 0.3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 560, "y1": 80, "x2": 760, "y2": 280, "rot": 0}
      },
      "tags": []
    }
  }
  body2 = Body(I = 0.001, radius = 0.2, m = 0.4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 560, "y1": 420, "x2": 760, "y2": 620, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(r = [2, 0], color = [0.5, 0.5, 0.5, 0.5]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 260, "x2": 430, "y2": 460, "rot": 270}
      },
      "tags": []
    }
  }
  wheelJoint = OneDOFSlippingWheelJoint(radius = 1, mu_A = 1, mu_S = 0.7, sAdhesion = 0.04, sSlide = 0.12, vAdhesion_min = 0.05, vSlide_min = 0.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 620, "x2": 430, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial body.phi = 0.0
  initial body.w = 0.0
  initial wheelJoint.x = 0.0
  initial wheelJoint.v = 0.0
  connect(wheelJoint.frame_a, translation_cm.frame_a, body2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 330, "y": 520}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, translation_cm.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 330, "y": 180}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {"Dyad": {"tests": {"case1": {"stop": 50}}}}
end
Flattened Source
dyad
"""
Test for OneDOFSlippingWheelJoint: planar segway model.

Two bodies connected via a FixedTranslation on a slip-based wheel. The heavy body
(m=10) acts as a pendulum on the wheel, creating a segway-like motion.
Translates the segway test from test_OneDOFWheelJoint.jl.
"""
test component OneDOFSlippingWheelSegwayTest
  world = World(g = 9.82) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 40, "y1": 710, "x2": 140, "y2": 810, "rot": 0}
      },
      "tags": []
    }
  }
  body = Body(m = 0.7, I = 0.0001, radius = 0.3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 560, "y1": 80, "x2": 760, "y2": 280, "rot": 0}
      },
      "tags": []
    }
  }
  body2 = Body(I = 0.001, radius = 0.2, m = 0.4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 560, "y1": 420, "x2": 760, "y2": 620, "rot": 0}
      },
      "tags": []
    }
  }
  translation_cm = FixedTranslation(r = [2, 0], color = [0.5, 0.5, 0.5, 0.5]) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 260, "x2": 430, "y2": 460, "rot": 270}
      },
      "tags": []
    }
  }
  wheelJoint = OneDOFSlippingWheelJoint(radius = 1, mu_A = 1, mu_S = 0.7, sAdhesion = 0.04, sSlide = 0.12, vAdhesion_min = 0.05, vSlide_min = 0.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 620, "x2": 430, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial body.phi = 0.0
  initial body.w = 0.0
  initial wheelJoint.x = 0.0
  initial wheelJoint.v = 0.0
  connect(wheelJoint.frame_a, translation_cm.frame_a, body2.frame_a) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [], "E": 2},
        {"S": 3, "M": [], "E": -1}
      ],
      "junctions": [{"x": 330, "y": 520}],
      "renderStyle": "standard"
    }
  }
  connect(body.frame_a, translation_cm.frame_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 330, "y": 180}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {"Dyad": {"tests": {"case1": {"stop": 50}}}}
end


Test Cases

julia
using MultibodyComponents
using DyadInterface: TransientAnalysis, rebuild_sol, ODEAlg
using ModelingToolkit: toggle_namespacing, get_initial_conditions, @named
using CSV, DataFrames, Plots

snapshotsdir = joinpath(dirname(dirname(pathof(MultibodyComponents))), "test", "snapshots")
<< @setup-block not executed in draft mode >>

Test Case case1

julia
@named model_case1 = MultibodyComponents.PlanarMechanics.OneDOFSlippingWheelSegwayTest()
model_case1 = toggle_namespacing(model_case1, false)

model_case1 = toggle_namespacing(model_case1, true)
result_case1 = TransientAnalysis(; model = model_case1, alg = ODEAlg.Auto(), start = 0e+0, stop = 5e+1, abstol=1e-6, reltol=1e-6)
sol_case1 = rebuild_sol(result_case1)
<< @setup-block not executed in draft mode >>