Skip to content

Commit

Permalink
update logo to use wheel and spherical joints (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen authored Oct 7, 2024
1 parent f40ea06 commit 19420b8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
39 changes: 24 additions & 15 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,61 @@ radius_large = length_scale*0.3
@mtkmodel Logo begin
@components begin
world = World(render=false)
revl = Revolute(; radius = radius_large, color=JULIASIM_PURPLE, axisflange=true)
revl2 = Revolute(; radius = radius_large, color=JULIASIM_PURPLE, axisflange=true)
# revl = Revolute(; radius = radius_large, color=JULIASIM_PURPLE, axisflange=true)
revl = Spherical(; radius = radius_large, color=JULIASIM_PURPLE, state=true, phid=[3, 3, 3])
move_up = FixedTranslation(r=[0, radius_large, 0], render=false) # To shift revolute up with radius of wheel
# revl2 = Revolute(; radius = radius_large, color=JULIASIM_PURPLE, axisflange=true)
revl2 = RollingWheel(; radius = radius_large, color=JULIASIM_PURPLE, m=1, I_axis=0.1, I_long=0.1, x0=0, state_priority=1000)
revr = Revolute(; radius = radius_small, color=JULIASIM_PURPLE, axisflange=true)
bodyl = Body(m=1, radius = radius_small, color=JULIASIM_PURPLE)
bodyr = Body(m=1, radius = radius_large, color=JULIASIM_PURPLE)
bodyr = Body(m=1, radius = radius_large, color=JULIASIM_PURPLE, state_priority=-1)
bar_top = FixedTranslation(r=length_scale*[1, 0.05, 0], radius=length_scale*0.025, color=JULIASIM_PURPLE)
barl = FixedTranslation(r=length_scale*[1, -1, 0], radius=length_scale*0.025, color=JULIASIM_PURPLE)
barr = FixedTranslation(r=1.1*length_scale*[-1, -1, 0], radius=length_scale*0.025, color=JULIASIM_PURPLE)
damperl = Rotational.Damper(d=0.1)
damperl2 = Rotational.Damper(d=0.01)
# damperl = Rotational.Damper(d=0.1)
# damperl2 = Rotational.Damper(d=0.01)
damperr = Rotational.Damper(d=0.01)
end
@equations begin
connect(revl.frame_a, world.frame_b)
connect(world.frame_b, move_up.frame_a)
connect(move_up.frame_b, revl.frame_a)
connect(revl.frame_b, barl.frame_a)
connect(barl.frame_b, bodyl.frame_a)
connect(world.frame_b, revl2.frame_a)
connect(revl2.frame_b, bar_top.frame_a)
# connect(world.frame_b, revl2.frame_a)
connect(revl2.frame_a, bar_top.frame_a)
connect(bar_top.frame_b, revr.frame_a)
connect(revr.frame_b, barr.frame_a)
connect(barr.frame_b, bodyr.frame_a)
connect(revl.axis, damperl.flange_a)
connect(revl2.axis, damperl2.flange_a)
# connect(revl.axis, damperl.flange_a)
# connect(revl2.axis, damperl2.flange_a)
connect(revr.axis, damperr.flange_a)
connect(revl.support, damperl.flange_b)
connect(revl2.support, damperl2.flange_b)
# connect(revl.support, damperl.flange_b)
# connect(revl2.support, damperl2.flange_b)
connect(revr.support, damperr.flange_b)
end
end
@named logo = Logo()
logo = complete(logo)
ssys = structural_simplify(multibody(logo))
prob = ODEProblem(ssys, [], (0.0, 3.51))
sol = solve(prob, Rodas5P())
sol = solve(prob, Tsit5())
# Plots.plot(sol)
import GLMakie
framerate = 30
timevec = [zeros(30); range(sol.t[1], sol.t[end], step=1/framerate)] |> reverse
render(logo, sol, timevec; z=-2.5, x=0, y=-0.5, lookat=[0.2,-0.5, 0], filename="JuliaSim_logo.gif", framerate)
timevec = [zeros(40); range(sol.t[1], sol.t[end], step=1/framerate)] |> reverse
render(logo, sol, timevec; z=-2.5, x=0, y=-0.5, lookat=[0.2,-0.5+radius_large, 0], filename="JuliaSim_logo.gif", framerate)
```
![animated logo](JuliaSim_logo.gif)

Expand Down
1 change: 1 addition & 0 deletions src/frames.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@connector function Frame(; name, varw = false, r_0 = zeros(3), render=false, length=1.0, radius=0.1)
@variables r_0(t)[1:3]=r_0 [
description = "Position vector directed from the origin of the world frame to the connector frame origin, resolved in world frame",
state_priority=-1,
]
@variables f(t)[1:3] [
connect = Flow,
Expand Down
19 changes: 12 additions & 7 deletions src/wheels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ this frame.
# Connector frames
- `frame_a`: Frame for the wheel joint
"""
@component function RollingWheelJoint(; name, radius, angles = zeros(3), der_angles=zeros(3), x0=0, y0 = radius, z0=0, sequence = [2, 3, 1], iscut=false, surface = nothing)
@parameters begin radius = radius, [description = "Radius of the wheel"] end
@component function RollingWheelJoint(; name, radius, angles = zeros(3), der_angles=zeros(3), x0=0, y0 = radius, z0=0, sequence = [2, 3, 1], iscut=false, surface = nothing, color = [1, 0, 0, 1], state_priority = 15)
@parameters begin
radius = radius, [description = "Radius of the wheel"]
color[1:4] = color, [description = "Color of the wheel in animations"]
end
@variables begin
(x(t) = x0), [state_priority = 15, description = "x-position of the wheel axis"]
(x(t) = x0), [state_priority = state_priority, description = "x-position of the wheel axis"]
(y(t) = y0), [state_priority = 0, description = "y-position of the wheel axis"]
(z(t) = z0), [state_priority = 15, description = "z-position of the wheel axis"]
(z(t) = z0), [state_priority = state_priority, description = "z-position of the wheel axis"]
(angles(t)[1:3] = angles),
[state_priority = 5, description = "Angles to rotate world-frame into frame_a around z-, y-, x-axis"]
[state_priority = state_priority, description = "Angles to rotate world-frame into frame_a around z-, y-, x-axis"]
(der_angles(t)[1:3] = der_angles), [state_priority = 5, description = "Derivatives of angles"]
(r_road_0(t)[1:3] = zeros(3)),
[
Expand Down Expand Up @@ -176,7 +179,8 @@ this frame.
zeros(3) .~ collect(frame_a.f) + resolve2(Ra, f_wheel_0)
zeros(3) .~ collect(frame_a.tau) +
resolve2(Ra, cross(delta_0, f_wheel_0))]
compose(ODESystem(equations, t; name), frame_a)
sys = compose(ODESystem(equations, t; name=:nothing), frame_a)
add_params(sys, [color;]; name)
end

"""
Expand Down Expand Up @@ -234,7 +238,8 @@ with the wheel itself. A [`Revolute`](@ref) joint rotationg around `n = [0, 1, 0
I_33 = I_axis,
I_21 = 0,
I_31 = 0,
I_32 = 0)
I_32 = 0,
render = false)
end
pars = @parameters begin
radius = radius, [description = "Radius of the wheel"]
Expand Down

0 comments on commit 19420b8

Please sign in to comment.