JuliaComputing / Multibody.jl

Model and simulate multibody systems in Julia
Other
15 stars 2 forks source link

Examples that include rotation matrix elements in state #80

Closed baggepinnen closed 1 month ago

baggepinnen commented 5 months ago

Wheel example from tests

THIS ONE IS FIXED

@named wheel = RollingWheel(radius = 0.3, m = 2, I_axis = 0.06,
                        I_long = 0.12,
                        x0 = 0.2,
                        y0 = 0.2,
                        der_angles = [0, 5, 1])
wheel = complete(wheel)
defs = [
    collect(world.n .=> [0, 0, -1]);
    vec(ori(wheel.frame_a).R .=> I(3));
    vec(ori(wheel.body.frame_a).R .=> I(3));
    # collect(D.(cwheel.rollingWheel.angles)) .=> [0, 5, 1]
]
ssys = structural_simplify(IRSystem(wheel))
prob = ODEProblem(ssys, defs, (0, 10))
sol = solve(prob, Rodas5P(autodiff=false))

Quaternions in joints

THIS ONE IS FIXED

connections = [connect(world.frame_b, joint.frame_a) connect(joint.frame_b, body.frame_a)]

@named model = ODESystem(connections, t, systems = [world, joint, body]) irsys = IRSystem(model) ssys = structural_simplify(irsys)


# Cut joints
- https://github.com/JuliaComputing/Multibody.jl/pull/67

# Chain without spring
```julia
number_of_links = 3

chain_length = 2
x_dist = 1.5 # Distance between the two mounting points

systems = @named begin
    chain = Rope(l = chain_length, m = 5, n=number_of_links, c=100, d_joint=0.2, dir=[1, 0, 0], color=[0.5, 0.5, 0.5, 1], radius=0.05, cutprismatic=true)
    fixed = FixedTranslation(; r=[x_dist, 0, 0], radius=0.02, color=[0.1,0.1,0.1,1]) # Second mounting point
end

connections = [connect(world.frame_b, fixed.frame_a, chain.frame_a)
               connect(chain.frame_b, fixed.frame_b)]

@named mounted_chain = ODESystem(connections, t, systems = [systems; world])

ssys = structural_simplify(IRSystem(mounted_chain))
prob = ODEProblem(ssys, [], (0, 4))
sol = solve(prob, Rodas4(autodiff=false))
@test SciMLBase.successful_retcode(sol)