Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/.benchmarkci
/benchmark/*.json
/notes
/testscripts
/testscripts
/examples/strandbeest.jl
/examples/examples_files/strandbeest.urdf
4 changes: 2 additions & 2 deletions examples/atlas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using ConstrainedDynamicsVis


path = "examples/examples_files/atlas_simple.urdf"
mech, shapes = Mechanism(path, floating=false, g = -.5)
mech = Mechanism(path, floating=false, g = -.5)

storage = simulate!(mech, 10., record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
9 changes: 3 additions & 6 deletions examples/dice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ joint_axis = [1.0;0.0;0.0]

length1 = 0.5
width, depth = 0.5, 0.5
box1 = Box(width, depth, length1, 1., color = RGBA(1., 1., 0.))
b1 = Box(0.1, 0.1, .1, .1, color = RGBA(1., 0., 0.))

# Corner vectors
corners = [
Expand All @@ -28,7 +26,7 @@ q1 = UnitQuaternion(RotX(ϕ1))

# Links
origin = Origin{Float64}()
link1 = Body(box1)
link1 = Box(width, depth, length1, 1., color = RGBA(1., 1., 0.))

# Constraints
impacts = [InequalityConstraint(Friction(link1,[0;0;1.0], 0.2; p = corners[i])) for i=1:8]
Expand All @@ -38,15 +36,14 @@ joint0to1 = EqualityConstraint(Floating(origin, link1))
links = [link1]
eqcs = [joint0to1]
ineqcs = impacts
shapes = [box1]


mech = Mechanism(origin, links, eqcs, ineqcs, shapes = shapes)
mech = Mechanism(origin, links, eqcs, ineqcs)

setPosition!(link1,x = [0.;-2;1.5])
ωtemp = (rand(3) .- 0.5) * 100

setVelocity!(link1,v = [0;3;7.],ω = ωtemp)

storage = simulate!(mech, 10, record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
11 changes: 4 additions & 7 deletions examples/disconnected_bodies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,26 @@ joint_axis = [1.0;0.0;0.0]

length1 = 0.5
width, depth = 0.5, 0.5
box1 = Box(width, depth, length1, length1, color = RGBA(1., 1., 0.))
box2 = Box(width, depth, length1, length1, color = RGBA(1., 0., 0.))

# Links
origin = Origin{Float64}()
link1 = Body(box1)
link2 = Body(box2)
link1 = Box(width, depth, length1, length1, color = RGBA(1., 1., 0.))
link2 = Box(width, depth, length1, length1, color = RGBA(1., 0., 0.))

# Constraints
joint1 = EqualityConstraint(Floating(origin, link1))
joint2 = EqualityConstraint(Floating(origin, link2))

links = [link1;link2]
constraints = [joint1;joint2]
shapes = [box1;box2]


mech = Mechanism(origin, links, constraints, g = -5., shapes = shapes)
mech = Mechanism(origin, links, constraints, g = -5.)
setPosition!(link1,x = [0.;1.;0.])
setPosition!(link2,x = [0.;-1.;0.])
setVelocity!(link1,v = [-5.;-5;5])
setVelocity!(link2,v = [-2.5;2.5;5],ω = [2;4;10.])


storage = simulate!(mech, 10., record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
11 changes: 4 additions & 7 deletions examples/doublependulum_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ ex = [1.;0.;0.]
l1 = 1.0
l2 = sqrt(2) / 2
x, y = .1, .1
b1 = Box(x, y, l1, l1, color = RGBA(1., 1., 0.))
b2 = Box(x, y, l2, l2, color = RGBA(1., 1., 0.))

vert11 = [0.;0.;l1 / 2]
vert12 = -vert11
Expand All @@ -22,21 +20,20 @@ q1 = UnitQuaternion(RotX(phi1))

# Links
origin = Origin{Float64}()
link1 = Body(b1)
link2 = Body(b2)
link1 = Box(x, y, l1, l1, color = RGBA(1., 1., 0.))
link2 = Box(x, y, l2, l2, color = RGBA(1., 1., 0.))

# Constraints
socket0to1 = EqualityConstraint(Spherical(origin, link1; p2=vert11))
socket1to2 = EqualityConstraint(Spherical(link1, link2; p1=vert12, p2=vert21))

links = [link1;link2]
constraints = [socket0to1;socket1to2]
shapes = [b1,b2]


mech = Mechanism(origin, links, constraints, shapes = shapes)
mech = Mechanism(origin, links, constraints)
setPosition!(origin,link1,p2 = vert11,Δq = q1)
setPosition!(link1,link2,p1 = vert12,p2 = vert21,Δq = inv(q1)*UnitQuaternion(RotY(0.2)))

storage = simulate!(mech, 10., record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
9 changes: 3 additions & 6 deletions examples/doublependulum_disconnection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ex = [1.;0.;0.]

h = 1.
r = .05
b1 = Cylinder(r, h, h, color = RGBA(1., 0., 0.))

vert11 = [0.;0.;h / 2]
vert12 = -vert11
Expand All @@ -18,16 +17,14 @@ q1 = UnitQuaternion(RotX(phi))

# Links
origin = Origin{Float64}()
links = [Body(b1) for i = 1:2]
links = [Cylinder(r, h, h, color = RGBA(1., 0., 0.)) for i = 1:2]

# Constraints
jointb1 = EqualityConstraint(Revolute(origin, links[1], ex; p2=vert11))
joint12 = EqualityConstraint(Revolute(links[1], links[2], ex; p1=vert12, p2=vert11))
constraints = [jointb1;joint12]

shapes = [b1]

mech = Mechanism(origin, links, constraints;Δt = 0.01, shapes = shapes)
mech = Mechanism(origin, links, constraints;Δt = 0.01)
setPosition!(origin, links[1], p2 = vert11,Δq = q1)
setPosition!(links[1], links[2], p1 = vert12, p2 = vert11)

Expand All @@ -38,4 +35,4 @@ function control!(mechanism,k)
end

storage = simulate!(mech, 10., control!,record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
4 changes: 2 additions & 2 deletions examples/doublependulum_urdf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using ConstrainedDynamicsVis


path = "examples/examples_files/doublependulum.urdf"
mech, shapes = Mechanism(path)
mech = Mechanism(path)

storage = simulate!(mech, 10., record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)
8 changes: 3 additions & 5 deletions examples/elliptic_joint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ using StaticArrays
# Parameters
length1 = 1.0
width, depth = 0.1, 0.1
box = Box(width, depth, length1, length1)

# Links
origin = Origin{Float64}()
link1 = Body(box)
link1 = Box(width, depth, length1, length1)


@inline function g(joint::GenericJoint, xb::AbstractVector, qb::UnitQuaternion)
Expand Down Expand Up @@ -40,16 +39,15 @@ joint_between_origin_and_link1 = EqualityConstraint(GenericJoint{5}(origin,link1

links = [link1]
constraints = [joint_between_origin_and_link1]
shapes = [box]


mech = Mechanism(origin, links, constraints, shapes = shapes)
mech = Mechanism(origin, links, constraints)
setPosition!(link1,x=[0;0.0;2],q = UnitQuaternion(RotX(0)))
setVelocity!(link1,v=[0;2.0;0])

steps = Base.OneTo(1000)
storage = Storage{Float64}(steps,1)

simulate!(mech, storage, record = true)
visualize(mech, storage, shapes)
visualize(mech, storage)

Loading