Skip to content

Commit

Permalink
rename get_time_mids to get_mid_times;
Browse files Browse the repository at this point in the history
remove `has_joint` and `has_force` fields from `Apparatus`;
add `force` to `PrototypeJoint` constructors as forced `Apparatus`;
add notebooks;
  • Loading branch information
jacobleft committed Dec 23, 2023
1 parent 65b5bb4 commit f70c7a3
Show file tree
Hide file tree
Showing 34 changed files with 3,492 additions and 657 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ result/
*.agx
*.csv
.DS_Store
*.pdf
49 changes: 9 additions & 40 deletions examples/robots/slider_crank.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function slider_crank(;θ = 0, coordsType = RB.NCF.NC)
ω0 = [
150.0,
-75.0,
]./20
]./100
b = 0.05
a = 0.025
d = 0.05
Expand Down Expand Up @@ -219,48 +219,17 @@ function slider_crank(;θ = 0, coordsType = RB.NCF.NC)
slider1 = make_slider(4;ro = p3)
rbs = [base,link1,link2,slider1,]
rigdibodies = TypeSortedCollection(rbs)
numbered = RB.number(rigdibodies)
indexed = RB.index(rigdibodies,)
force_elements_angular_stiffness = 5.0
ss = [
RB.RotationalSpringDamper3D(
1,
[0.0,0,0],
Int[],
0.0,
),
RB.RotationalSpringDamper3D(
2,
[0.0,0,0],
[3],
force_elements_angular_stiffness,
),
RB.RotationalSpringDamper3D(
3,
[0.0,0,0],
[3],
force_elements_angular_stiffness,
),
RB.RotationalSpringDamper3D(
4,
[0.0,0,0],
[3],
force_elements_angular_stiffness,
)
]
apparatuses = (spring_dampers = ss, cables = Int[])
connected = RB.connect(rbs,zeros(Int,0,0))
tensioned = @eponymtuple(connected,)

j1 = RB.FixedBodyConstraint(1,indexed,base)
j2 = RB.RevoluteJoint(2,indexed,RB.Hen2Egg(RB.ID(base ,1,1),RB.ID(link1,1,1)))
j3 = RB.RevoluteJoint(3,indexed,RB.Hen2Egg(RB.ID(link1,2,2),RB.ID(link2,1,1)))
j4 = RB.RevoluteJoint(4,indexed,RB.Hen2Egg(RB.ID(link2,2,2),RB.ID(slider1,5,5)))
j1 = RB.FixedBodyConstraint(1,base)
j2 = RB.RevoluteJoint(2,RB.Hen2Egg(RB.ID(base ,1,1),RB.ID(link1,1,1)))
j3 = RB.RevoluteJoint(3,RB.Hen2Egg(RB.ID(link1,2,2),RB.ID(link2,1,1)))
j4 = RB.RevoluteJoint(4,RB.Hen2Egg(RB.ID(link2,2,2),RB.ID(slider1,5,5)))

js = [j1,j2,j3,j4]
apparatuses = TypeSortedCollection([j1,j2,j3,j4])

jointed = RB.join(js,indexed)
cnt = RB.Connectivity(numbered,indexed,tensioned,jointed)
numbered = RB.number(rigdibodies,apparatuses)
indexed = RB.index(rigdibodies,apparatuses)
cnt = RB.Connectivity(numbered,indexed)
st = RB.Structure(rigdibodies,apparatuses,cnt)
RB.Robot(st,)
end
103 changes: 48 additions & 55 deletions examples/robots/woodpecker.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
function woodpecker(;coordsType = RB.NCF.NC)
function woodpecker(;
coordsType = RB.NCF.NC,
case=2,
frictional_coefficient = 0.3
)
SVo3 = SVector{3}([0.0,0.0,0.0])
pole_radius = 0.0025e3#mm
sleeve_radius = 0.0031e3 #mm
half_sleeve_height = 0.0058e3 #mm
distance_spring_COM_sleeve = 0.0100e3 #mm
distance_spring_COM_woodpecker = 0.0150e3 #mm
distance_beak_COM_woodpecker_z = 0.0200e3 #mm
distance_beak_COM_woodpecker_y = 0.0201e3 #mm
pole_radius = 0.0025#m
sleeve_radius = 0.0031 #m
half_sleeve_height = 0.0058 #m
distance_spring_COM_sleeve = 0.0100 #m
distance_spring_COM_woodpecker = 0.0150 #m
distance_beak_COM_woodpecker_z = 0.0200 #m
distance_beak_COM_woodpecker_y = 0.0201 #m
# inertial_properties
sleeve_mass = 0.0003e3 #g
woodpecker_mass = 0.0045e3 #g
sleeve_moment_of_inertia = 5.0e-9*(1e9) #g*mm2
woodpecker_moment_of_inertia = 7.0e-7*(1e9) #g*mm2
force_elements_angular_stiffness = 0.0056e9 #(gmm/s^2)mm/rad
gravity = 9.81e3 #mm/s2
sleeve_mass = 0.0003*(1e3) #g
woodpecker_mass = 0.0045*(1e3) #g
sleeve_moment_of_inertia = 5.0e-9*(1e3) #g*m2
woodpecker_moment_of_inertia = 7.0e-7*(1e3) #g*m2
force_elements_angular_stiffness = 0.0056*(1e3) #(gm/s^2)m/rad
gravity = 9.81 #m/s2
# contact_parameters
COR_in_normal_direction = 0.5
COR_in_normal_direction = 0.5
COR_in_tangential_direction = 0
frictional_coefficient = 0.3
# initial conditions
sleeve_angular_position = -0.1036 #rad
woodpecker_angular_position = -0.2788 #rad
sleeve_vertical_velocity = -0.3411e3 #mm/s
sleeve_vertical_velocity = -0.3411 #m/s
sleeve_angular_velocity = 0.0 #rad/s
woodpecker_angular_velocity = -7.4583 #rad/s
sleeve_position_X = 0 #mm
sleeve_position_X = 0 #m

function make_sleeve(i;
ro=SVo3,
Expand All @@ -35,20 +38,21 @@ function woodpecker(;coordsType = RB.NCF.NC)
contactable = true
visible = true
r̄g = SVo3
# r̄p1 = SVector(0.0,-sleeve_radius,-half_sleeve_height)
r̄p1 = SVector(0.0,-sleeve_radius,-half_sleeve_height)
r̄p2 = SVector(0.0, sleeve_radius,-half_sleeve_height)
r̄p3 = SVector(0.0, sleeve_radius, half_sleeve_height)
# r̄p4 = SVector(0.0,-sleeve_radius, half_sleeve_height)
r̄p4 = SVector(0.0,-sleeve_radius, half_sleeve_height)
r̄p5 = SVector(0.0, distance_spring_COM_sleeve, 0)
loci_positions = [r̄p2,r̄p3,r̄p5]
loci_positions = ifelse(
case==2,
[r̄p2,r̄p3,r̄p5],
[r̄p1,r̄p2,r̄p3,r̄p4,r̄p5]
)
num_of_loci = length(loci_positions)
axes_normals = [
SVector{3}([1.0,0.0,0.0]),
axes_normals = fill(
SVector{3}([1.0,0.0,0.0]),
SVector{3}([1.0,0.0,0.0]),
# SVector{3}([1.0,0.0,0.0]),
# SVector{3}([1.0,0.0,0.0]),
]
num_of_loci
)
m = sleeve_mass
= SMatrix{3,3}(
[
Expand Down Expand Up @@ -128,7 +132,7 @@ function woodpecker(;coordsType = RB.NCF.NC)
if coordsType isa Type{RB.NCF.NC}
nmcs = RB.NCF.NC1P3V(ri, ro, R)
pres_idx = Int[]
cstr_idx = collect(1:6)
cstr_idx = collect(1:6)
coords = RB.NonminimalCoordinates(nmcs, pres_idx, cstr_idx)
else
qcs = RB.QCF.QC(m,Ī)
Expand Down Expand Up @@ -156,44 +160,33 @@ function woodpecker(;coordsType = RB.NCF.NC)
end
# pole = make_pole(1)
sleeve1 = make_sleeve(1;)
spring_position = sleeve1.state.loci_states[3].frame.position
spring_velocity = sleeve1.state.loci_states[3].frame.velocity
spring_loci_id = ifelse(case==2,3,5)
spring_position = sleeve1.state.loci_states[spring_loci_id].frame.position
spring_velocity = sleeve1.state.loci_states[spring_loci_id].frame.velocity
link1 = make_link(2;spring_position,spring_velocity)
@show spring_velocity
rbs = [sleeve1,link1]
rigdibodies = TypeSortedCollection(rbs)
q_sleeve1,_ = RB.body_state2coords_state(sleeve1)
cstr_idx = [1,2,5,6]
A_linearjoint = zeros(length(cstr_idx),12)
for (i,j) in enumerate(cstr_idx)
A_linearjoint[i,j] = 1
if case == 2
cstr_idx = [1,2,5,6]
else
cstr_idx = [1,5,6]
end
js = [
RB.RevoluteJoint(1,RB.Hen2Egg(RB.ID(sleeve1,3,1),RB.ID(link1,1,1))),
RB.LinearJoint(2,sleeve1,A_linearjoint,q_sleeve1[cstr_idx]),
# RB.FixedBodyConstraint(2,indexed,sleeve1)
]
jointed = RB.join(js,)
ss = [
j1 = RB.RevoluteJoint(
1,
RB.Hen2Egg(RB.ID(sleeve1,spring_loci_id,1),RB.ID(link1,1,1)),
RB.RotationalSpringDamper3D(
1,
[0.0,0,0],
[3],
force_elements_angular_stiffness,
),
RB.RotationalSpringDamper3D(
2,
[0.0,0,0],
Int[],
force_elements_angular_stiffness,
)
]
apparatuses = (spring_dampers = ss, cables = Int[])
connected = RB.connect(rbs,zeros(Int,0,0))
tensioned = @eponymtuple(connected,)
indexed = RB.index(rigdibodies,jointed)
numbered = RB.number(rigdibodies)
cnt = RB.Connectivity(jointed,tensioned,indexed,numbered)
)
j2 = RB.FixedIndicesConstraint(2,sleeve1,cstr_idx,q_sleeve1[cstr_idx])
apparatuses = TypeSortedCollection([j1,j2])
indexed = RB.index(rigdibodies,apparatuses)
numbered = RB.number(rigdibodies,apparatuses)
cnt = RB.Connectivity(indexed,numbered)
st = RB.Structure(rigdibodies,apparatuses,cnt)
RB.Robot(st,)
end
626 changes: 626 additions & 0 deletions notebooks/meteor_hammer.ipynb

Large diffs are not rendered by default.

101 changes: 78 additions & 23 deletions notebooks/pointmass.ipynb

Large diffs are not rendered by default.

898 changes: 898 additions & 0 deletions notebooks/spinning_top.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit f70c7a3

Please sign in to comment.