Skip to content

Commit

Permalink
merge branch 'dev';
Browse files Browse the repository at this point in the history
# Conflicts:
#	examples/robots/jixiebi.jl
#	src/control/control.jl
#	src/get.jl
#	src/mechanics/contact.jl
#	src/mechanics/dynamics.jl
#	src/mechanics/dynamics_solvers/Zhong06_family/Zhong06_CCP_constant_mass_hole.jl
#	src/mechanics/dynamics_solvers/Zhong06_family/Zhong06_constant_mass.jl
#	src/mechanics/dynamics_solvers/Zhong06_family/Zhong06_constant_mass_hole.jl
#	src/mechanics/dynamics_solvers/Zhong06_family/Zhong06_sliding_cable_FB.jl
#	src/members/apparatus.jl
#	src/postprocess/vis.jl
#	src/structures/constraints.jl
#	src/structures/linearization.jl
#	src/structures/mutate.jl
#	src/structures/structure.jl
#	test/vis.jl
#	yard/jixiebi/Group2_1.jl
  • Loading branch information
jacobleft committed May 21, 2024
1 parent 5d8a997 commit 7432a13
Show file tree
Hide file tree
Showing 103 changed files with 2,419 additions and 1,404 deletions.
File renamed without changes.
Binary file added assets/EWei_STL/截面形状-2.STL
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added assets/EWei_STL/截面形状-5-随动段.STL
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added assets/EWei_STL/截面形状-9-随动段.STL
Binary file not shown.
Binary file added assets/EWei_STL/装配体-中间梁6.0-32.STL
Binary file not shown.
Binary file added assets/EWei_STL/装配体-中间梁6.0-40.STL
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added assets/EWei_STL/装配体-电机.STL
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/bodies/build_2d_tri.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ state = RB.RigidBodyState(prop,ro,α,ṙo,ω)
coords = RB.NonminimalCoordinates(nmcs,ci,cstr_idx)
trimesh = begin
if id == 1
load(RB.assetpath("零件1 - 副本.STL")) |> make_patch(;scale=1/1000,color=:mediumpurple4)
load(RB.assetpath("零件1 - 副本.STL")) |> RB.make_patch(;scale=1/1000,color=:mediumpurple4)
else
load(RB.assetpath("零件1.STL")) |> make_patch(;scale=1/1000,color=:slategray4)
load(RB.assetpath("零件1.STL")) |> RB.make_patch(;scale=1/1000,color=:slategray4)
end
end
body = RB.RigidBody(prop,state,coords,trimesh)
Expand Down
2 changes: 1 addition & 1 deletion examples/bodies/make_3d_tri.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if loadmesh
else
trimesh = GB.merge(
[
endpoints2mesh(loci_positions[i],loci_positions[j];
RB.endpoints2mesh(loci_positions[i],loci_positions[j];
radius,color)
for (i,j) in [
[1,2],[1,3],[1,4],
Expand Down
199 changes: 118 additions & 81 deletions yard/EWei/define.jl → examples/robots/EWei.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function BuildTail()
function Get_apsAB(r̄, mass_locus)
ri =
rj =+ 2* [mass_locus[2], mass_locus[1]]
aps = [[0.0, 0.0], 2r̄g, [15.1, 0.0]]
aps = [[0.0, 0.0], 2, [15.1, 0.0]]
return ri, rj, aps
end

Expand Down Expand Up @@ -161,51 +161,38 @@ function BuildTail()
α = atan(u[2], u[1])
mass_locus = rdsi.mass_locus
m = rdsi.m*1e-3
I = rdsi.i
## I = rdsi.i
@show m
nrp = length(aps)
ṙo = zeros(2); ω = 0.0
prop = RB.RigidBodyProperty(
i,
contactable,
m,
SMatrix{2, 2}([
I 0
0 0
m 0
0 m
]),
SVector{2}(mass_locus),
[SVector{2}(aps[i]) for i in 1:nrp],
visible=visible
)
ro = SVector{2}(ri)
if i in rigidIndex
nmcs = RB.NCF.NC2P1V(SVector{2}(ri), SVector{2}(rj), ro, α)
@show i, "NC2P1V", ri, rj
nmcs = RB.NCF.NC2P1V(SVector{2}(ri), SVector{2}(rj), ro, RB.rotation_matrix(α))
else
nmcs = RB.NCF.NC2D2P(SVector{2}(ri), SVector{2}(rj), ro, α)
@show i, "NC2D2P"
nmcs = RB.NCF.NC2D2P(SVector{2}(ri), SVector{2}(rj), ro, RB.rotation_matrix(α))
end
state = RB.RigidBodyState(prop, nmcs, ri, α, ṙo, ω, ci, cstr_idx)
body = RB.RigidBody(prop, state)
state = RB.RigidBodyState(prop, ri, α, ṙo, ω, )
coords = RB.NonminimalCoordinates(nmcs, ci, cstr_idx)
body = RB.RigidBody(prop, state,coords)
end

rbs = [rigidbody(i, rds[i], r̄s[i]) for i in 1:nb]
rigdibodies = TypeSortedCollection(rbs)
numbered = RB.number(rigdibodies)
matrix_sharing_raw = Vector{Matrix{Int}}()
for i in 1:nb-1
s = zeros(2, nb)
if i == 1
s[1:2, 1] = 3:4
s[1:2, 2] = 1:2
elseif i in 2:2:16
s[1:2, i] = 1:2
s[1:2, i+1] = 1:2
else
s[1:2, i] = 3:4
s[1:2, i+1] = 1:2
end
push!(matrix_sharing_raw, s)
end
matrix_sharing = reduce(vcat, matrix_sharing_raw)
indexed = RB.index(rigdibodies, matrix_sharing)

nstrings = 8 * 4 + 8 * 2
ks = zeros(nstrings); restlens = zeros(nstrings)
for i in 1:4*8
Expand All @@ -217,8 +204,7 @@ function BuildTail()
restlens[i] = 25
ks[i] = 0.3
end
cables = [RB.DistanceSpringDamper2D( restlens[i], ks[i], 0.0) for i in 1:nstrings]
apparatuses = (cables=cables,)
spring_dampers = [RB.DistanceSpringDamper2D( restlens[i], ks[i], 0.0) for i in 1:nstrings]

matrix_cnt_raw = Vector{Matrix{Int}}()
s = zeros(4, nb)
Expand All @@ -245,11 +231,45 @@ function BuildTail()
s[2, i] = 2; s[2, i+1] = -2
push!(matrix_cnt_raw, s)
end
matrix_cnt = reduce(vcat, matrix_cnt_raw)
tensiled = (connected=RB.connect(rigdibodies, matrix_cnt),)
cnt = RB.Connectivity(numbered, indexed, tensiled)
connecting_matrix = reduce(vcat, matrix_cnt_raw)
spring_dampers = RB.connect(rigdibodies, spring_dampers;connecting_matrix)
apparatuses = TypeSortedCollection(
spring_dampers
)

numbered = RB.number(rigdibodies, apparatuses)

matrix_sharing_raw = Vector{Matrix{Int}}()
for i in 1:nb-1
s = zeros(2, nb)
if i == 1
s[1:2, 1] = 3:4
s[1:2, 2] = 1:2
elseif i in 2:2:16
s[1:2, i] = 1:2
s[1:2, i+1] = 1:2
else
s[1:2, i] = 3:4
s[1:2, i+1] = 1:2
end
push!(matrix_sharing_raw, s)
end
sharing_matrix = reduce(vcat, matrix_sharing_raw)
indexed = RB.index(rigdibodies, apparatuses; sharing_matrix)
cnt = RB.Connectivity(
numbered,
indexed,
)
st = RB.Structure(rigdibodies, apparatuses, cnt)
bot = RB.Robot(st,)
gauges = Int[]
actuators = Int[]
hub = RB.ControlHub(
st,
gauges,
actuators,
RB.Coalition(st,gauges,actuators)
)
bot = RB.Robot(st,hub)
end

"""
Expand Down Expand Up @@ -291,7 +311,7 @@ function BuildTail(type; β=1.0, μ=0.02)
function Get_apsAB(r̄, mass_locus)
ri =
rj =+ 2* [mass_locus[2], mass_locus[1]]
aps = [[0.0, 0.0], 2r̄g, [15.1, 0.0]]
aps = [[0.0, 0.0], 2, [15.1, 0.0]]
return ri, rj, aps
end

Expand Down Expand Up @@ -325,23 +345,23 @@ function BuildTail(type; β=1.0, μ=0.02)
4 => Get_apsC()
end
end
asbMid = load("STL/装配体-中间部分.STL") |> make_patch(;trans=[0.0,0,0],rot=RotZ(deg2rad(-77)))
crSec1 = load("STL/截面形状-1.STL") |> make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec2 = load("STL/截面形状-2.STL") |> make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec3 = load("STL/截面形状-3.STL") |> make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec4f = load("STL/截面形状-4-随动段.STL") |> make_patch(;trans=[40,0,0.],rot=RotZ(-π/2))
crSec5f = load("STL/截面形状-5-随动段.STL") |> make_patch(;trans=[40,0,0.],rot=RotZ(-π/2))
crSec6f = load("STL/截面形状-6-随动段.STL") |> make_patch(;trans=[30,0,0.],rot=RotZ(-π/2))
crSec7f = load("STL/截面形状-7-随动段.STL") |> make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec8f = load("STL/截面形状-8-随动段.STL") |> make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec9f = load("STL/截面形状-9-随动段.STL") |> make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec10f = load("STL/截面形状-10-随动段.STL") |> make_patch(;trans=[30,0,0.],rot=RotZ(-π/2))

asbMot = load("STL/装配体-电机.STL") |> make_patch(;trans=[45.0,0,0],rot=RotZ(π))

asbB32 = load("STL/装配体-中间梁6.0-32.STL") |> make_patch(;trans=[25.0,0,0])
asbB40 = load("STL/装配体-中间梁6.0-40.STL") |> make_patch(;trans=[25.0,0,0])
asbLF = load("STL/装配体-主动-随动.STL") |> make_patch(;trans=[55,0,0.],rot=RotZ( π/2))
asbMid = load(RB.assetpath("EWei_STL/装配体-中间部分.STL")) |> RB.make_patch(;trans=[0.0,0,0],rot=RotZ(deg2rad(-77)))
crSec1 = load(RB.assetpath("EWei_STL/截面形状-1.STL")) |> RB.make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec2 = load(RB.assetpath("EWei_STL/截面形状-2.STL")) |> RB.make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec3 = load(RB.assetpath("EWei_STL/截面形状-3.STL")) |> RB.make_patch(;trans=[0.0,-5,0]) |> (x)->merge([x,asbMid])
crSec4f = load(RB.assetpath("EWei_STL/截面形状-4-随动段.STL")) |> RB.make_patch(;trans=[40,0,0.],rot=RotZ(-π/2))
crSec5f = load(RB.assetpath("EWei_STL/截面形状-5-随动段.STL")) |> RB.make_patch(;trans=[40,0,0.],rot=RotZ(-π/2))
crSec6f = load(RB.assetpath("EWei_STL/截面形状-6-随动段.STL")) |> RB.make_patch(;trans=[30,0,0.],rot=RotZ(-π/2))
crSec7f = load(RB.assetpath("EWei_STL/截面形状-7-随动段.STL")) |> RB.make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec8f = load(RB.assetpath("EWei_STL/截面形状-8-随动段.STL")) |> RB.make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec9f = load(RB.assetpath("EWei_STL/截面形状-9-随动段.STL")) |> RB.make_patch(;trans=[25,0,0.],rot=RotZ(-π/2))
crSec10f = load(RB.assetpath("EWei_STL/截面形状-10-随动段.STL")) |> RB.make_patch(;trans=[30,0,0.],rot=RotZ(-π/2))

asbMot = load(RB.assetpath("EWei_STL/装配体-电机.STL")) |> RB.make_patch(;trans=[45.0,0,0],rot=RotZ(π))

asbB32 = load(RB.assetpath("EWei_STL/装配体-中间梁6.0-32.STL")) |> RB.make_patch(;trans=[25.0,0,0])
asbB40 = load(RB.assetpath("EWei_STL/装配体-中间梁6.0-40.STL")) |> RB.make_patch(;trans=[25.0,0,0])
asbLF = load(RB.assetpath("EWei_STL/装配体-主动-随动.STL")) |> RB.make_patch(;trans=[55,0,0.],rot=RotZ( π/2))

rds = [
RigidData(r̄gC, mC, iC, r̄lC, asbMot), #1
Expand Down Expand Up @@ -447,34 +467,18 @@ function BuildTail(type; β=1.0, μ=0.02)
)
ro = SVector{2}(ri)
if i in rigidIndex
nmcs = RB.NCF.NC2P1V(SVector{2}(ri), SVector{2}(rj), ro, α)
nmcs = RB.NCF.NC2P1V(SVector{2}(ri), SVector{2}(rj), ro, RB.rotation_matrix(α))
else
nmcs = RB.NCF.NC2D2P(SVector{2}(ri), SVector{2}(rj), ro, α)
nmcs = RB.NCF.NC2D2P(SVector{2}(ri), SVector{2}(rj), ro, RB.rotation_matrix(α))
end
state = RB.RigidBodyState(prop, nmcs, ri, α, ṙo, ω, ci, cstr_idx)
body = RB.RigidBody(prop, state, rdsi.mesh)
state = RB.RigidBodyState(prop, ri, α, ṙo, ω, )
coords = RB.NonminimalCoordinates(nmcs, ci, cstr_idx)
body = RB.RigidBody(prop, state, coords, rdsi.mesh)
end

rbs = [rigidbody(i, rds[i], r̄s[i]) for i in 1:nb]
rigdibodies = TypeSortedCollection(rbs)
numbered = RB.number(rigdibodies)
matrix_sharing_raw = Vector{Matrix{Int}}()
for i in 1:nb-1
s = zeros(2, nb)
if i == 1
s[1:2, 1] = 3:4
s[1:2, 2] = 1:2
elseif i in 2:2:16
s[1:2, i] = 1:2
s[1:2, i+1] = 1:2
else
s[1:2, i] = 3:4
s[1:2, i+1] = 1:2
end
push!(matrix_sharing_raw, s)
end
matrix_sharing = reduce(vcat, matrix_sharing_raw)
indexed = RB.index(rigdibodies, matrix_sharing)

nstrings = 8 * 4 + 8 * 2
ks = zeros(nstrings); restlens = zeros(nstrings)
for i in 1:4*8
Expand All @@ -486,15 +490,15 @@ function BuildTail(type; β=1.0, μ=0.02)
restlens[i] = 25
ks[i] = 0.3
end
cables = [RB.DistanceSpringDamper2D( restlens[i], ks[i], 0.0) for i in 1:nstrings]
spring_dampers = [RB.DistanceSpringDamper2D( restlens[i], ks[i], 0.0) for i in 1:nstrings]
@match type begin
1 => begin
lens = [44.71, 50, 50]
@show pre = [lens[i]*(1-β)*0.2 for i in 1:3]
c_section = StructArray([RB.DistanceSpringDamperSegment(i, lens[i], 0.2, prestress=pre[i]) for i in 1:3])
cs1 = RB.ClusterDistanceSpringDampers(1, 2, deepcopy(c_section); μ=μ)
cs2 = RB.ClusterDistanceSpringDampers(2, 2, deepcopy(c_section); μ=μ)
apparatuses = (cables=cables, clustercables=[cs1, cs2])
apparatuses = (spring_dampers=spring_dampers, clustercables=[cs1, cs2])
s = zeros(Int, 2, nb)
s[1, 1] = 3; s[1, 2] = 2; s[1, 4] = 2; s[1, 6] = 2
s[2, 1] = 2; s[2, 2] = 1; s[2, 4] = 1; s[2, 6] = 1
Expand All @@ -506,7 +510,7 @@ function BuildTail(type; β=1.0, μ=0.02)
c_section = StructArray([RB.DistanceSpringDamperSegment(i, lens[i], 0.2, prestress=pre[i]) for i in 1:8])
cs1 = RB.ClusterDistanceSpringDampers(1, 7, deepcopy(c_section); μ=μ)
cs2 = RB.ClusterDistanceSpringDampers(2, 7, deepcopy(c_section); μ=μ)
apparatuses = (cables=cables, clustercables=[cs1, cs2])
apparatuses = (spring_dampers=spring_dampers, clustercables=[cs1, cs2])
s = zeros(Int, 2, nb)
s[1, 1] = 3; s[2, 1] = 2
for i in 1:8
Expand All @@ -523,7 +527,7 @@ function BuildTail(type; β=1.0, μ=0.02)
c_section2 = StructArray([RB.DistanceSpringDamperSegment(i, lens2[i], 0.2, prestress=pre2[i]) for i in 1:2])
cs1 = [RB.ClusterDistanceSpringDampers(i, 1, deepcopy(c_section1); μ=μ) for i in 1:2]
cs2 = [RB.ClusterDistanceSpringDampers(i, 1, deepcopy(c_section2); μ=μ) for i in 3:8]
apparatuses = (cables=cables, clustercables=vcat(cs1, cs2))
apparatuses = (spring_dampers=spring_dampers, clustercables=vcat(cs1, cs2))
s = zeros(Int, 8, nb)
s[1, 1] = 3; s[1, 2] = 2; s[1, 4] = 2;
s[2, 1] = 2; s[2, 2] = 1; s[2, 4] = 1;
Expand All @@ -543,7 +547,7 @@ function BuildTail(type; β=1.0, μ=0.02)
c_section2 = StructArray([RB.DistanceSpringDamperSegment(i, lens2[i], 0.2, prestress=pre2[i]) for i in 1:3])
cs1 = [RB.ClusterDistanceSpringDampers(i, 2, deepcopy(c_section1); μ=μ) for i in 1:2]
cs2 = [RB.ClusterDistanceSpringDampers(i, 2, deepcopy(c_section2); μ=μ) for i in 3:6]
apparatuses = (cables=cables, clustercables=vcat(cs1, cs2))
apparatuses = (spring_dampers=spring_dampers, clustercables=vcat(cs1, cs2))
s = zeros(Int, 6, nb)
s[1, 1] = 3; s[1, 2] = 2; s[1, 4] = 2; s[1, 6] = 2
s[2, 1] = 2; s[2, 2] = 1; s[2, 4] = 1; s[2, 6] = 1
Expand Down Expand Up @@ -584,9 +588,42 @@ function BuildTail(type; β=1.0, μ=0.02)
s[2, i] = 2; s[2, i+1] = -2
push!(matrix_cnt_raw, s)
end
matrix_cnt = reduce(vcat, matrix_cnt_raw)
cc = RB.connect_and_cluster(rigdibodies, matrix_cnt, matrix_cnt2)
cnt = RB.Connectivity(numbered, indexed, cc)
connecting_matrix = reduce(vcat, matrix_cnt_raw)

cc = RB.connect_and_cluster(rigdibodies, connecting_matrix, matrix_cnt2)

matrix_sharing_raw = Vector{Matrix{Int}}()
for i in 1:nb-1
s = zeros(2, nb)
if i == 1
s[1:2, 1] = 3:4
s[1:2, 2] = 1:2
elseif i in 2:2:16
s[1:2, i] = 1:2
s[1:2, i+1] = 1:2
else
s[1:2, i] = 3:4
s[1:2, i+1] = 1:2
end
push!(matrix_sharing_raw, s)
end
matrix_sharing = reduce(vcat, matrix_sharing_raw)

numbered = RB.number(rigdibodies, apparatuses;)
indexed = RB.index(rigdibodies, apparatuses; matrix_sharing)

cnt = RB.Connectivity(numbered, indexed)

st = RB.Structure(rigdibodies, apparatuses, cnt)
bot = RB.Robot(st,)

gauges = Int[]
actuators = Int[]
hub = RB.ControlHub(
st,
gauges,
actuators,
RB.Coalition(st,gauges,actuators)
)

bot = RB.Robot(st,hub)
end
34 changes: 22 additions & 12 deletions examples/robots/Tbars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ function Tbars(;θ = 0, coordsType = RB.NCF.NC)
rbs = [base,slider1,slider2,bar]
rigdibodies = TypeSortedCollection(rbs)

j1 = RB.PrismaticJoint(1,RB.Hen2Egg(RB.Signifier(base,5,1),RB.Signifier(slider1,1,1)))
j2 = RB.PrismaticJoint(2,RB.Hen2Egg(RB.Signifier(base,5,2),RB.Signifier(slider2,1,1)))

j3 = RB.PinJoint(3,RB.Hen2Egg(RB.Signifier(bar,1,1),RB.Signifier(slider1,2,1)))
j4 = RB.PinJoint(4,RB.Hen2Egg(RB.Signifier(bar,2,1),RB.Signifier(slider2,2,1)))

js = [j1,j2,j3,j4]

ncables = 4
original_restlens = zeros(ncables)
original_restlens = zeros(ncables)
Expand All @@ -148,7 +140,7 @@ function Tbars(;θ = 0, coordsType = RB.NCF.NC)
cs = zeros(ncables)
spring_dampers = [RB.DistanceSpringDamper3D(original_restlens[i],ks[i],cs[i];slack=false) for i = 1:ncables]

cm = [
connecting_matrix = [
1 -1 0 0;
2 -1 0 0;
# 3 0 -1 0;
Expand All @@ -157,10 +149,19 @@ function Tbars(;θ = 0, coordsType = RB.NCF.NC)
7 -1 0 0;
]

cables = RB.connect(rigdibodies, spring_dampers, cm, 4)
cables = RB.connect(rigdibodies, spring_dampers; connecting_matrix,)


j1 = RB.PrismaticJoint(ncables+1,RB.Hen2Egg(RB.Signifier(base,5,1),RB.Signifier(slider1,1,1)))
j2 = RB.PrismaticJoint(ncables+2,RB.Hen2Egg(RB.Signifier(base,5,2),RB.Signifier(slider2,1,1)))

j3 = RB.PinJoint(ncables+3,RB.Hen2Egg(RB.Signifier(bar,1,1),RB.Signifier(slider1,2,1)))
j4 = RB.PinJoint(ncables+4,RB.Hen2Egg(RB.Signifier(bar,2,1),RB.Signifier(slider2,2,1)))

js = [j1,j2,j3,j4]

apparatuses = TypeSortedCollection(
vcat(js,cables)
vcat(cables,js)
)

# sm = [
Expand All @@ -173,5 +174,14 @@ function Tbars(;θ = 0, coordsType = RB.NCF.NC)
# ]
# indexed = RB.index(rigdibodies,sm)
st = RB.Structure(rigdibodies,apparatuses,)
RB.Robot(st,)
gauges = Int[]
actuators = Int[]
hub = RB.ControlHub(
st,
gauges,
actuators,
RB.Coalition(st,gauges,actuators)
)

RB.Robot(st,hub)
end
Loading

0 comments on commit 7432a13

Please sign in to comment.