Skip to content

Commit

Permalink
timer
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangh3 committed Aug 4, 2023
2 parents 8f8fb67 + 8761b82 commit 760a03f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions example/script/in.script
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
print "This is a test script"
print "This is a test script"

create body b1 pos 0 0 0 quat 0 0 0 1
create body b1 pos 0 0 0 quat 0 0 0 1 #创建一个刚体,命名b1, 质心位置0 0 0,姿态四元数0 0 0 1
create body b2 pos 1 0 0 quat 0 0 0 1
create body b3 pos 2 0 0 quat 0 0 0 1

#创建一个约束,命名j1,约束类型球铰(sphere),球铰连接b1,b2,球铰在b1质心系位置为0.5 0 0,在b1质心系位置为-0.5 0 0
create joint j1 sphere body1 b1 body2 b2 point1 0.5 0 0 point2 -0.5 0 0
create joint j2 sphere body1 b2 body2 b3 point1 0.5 0 0 point2 -0.5 0 0
#创建一个约束,命名grd,约束类型大地固连(ground),将b1固连大地
create joint grd ground body1 b1

create system s1 bodys b1 b2 b3 /bodys joints j1 j2 grd /joints dt 1E-3 gravity 0 9.8 0

#创建一个多刚体系统,系统由b1、b2、b3三个刚体和j1、j2、grd三个约束构成,时间步长取0.001s,重力方向为0 -9.8 0
create system s1 bodys b1 b2 b3 /bodys joints j1 j2 grd /joints dt 1E-3 gravity 0 -9.8 0

#求解50时间步
run s1 50

#将刚体b1的质量改成2
change body b1 mass 2
label loop
variable a loop 5
print "A = $a"
if "$a > 2" then "jump in.in break"

label loop #创建一个名为loop的标记,用于循环
variable a loop 5 #创建一个变量a,取值1-5
print "A = $a" #输出a的值
if "$a > 2" then "jump in.script break" #若a>2,跳转到标记break
#求解50时间步
run s1 50
next a
jump in.in loop
next a #取下一个a值
jump in.script loop #跳转到标记loop
label break
print "BREAK A = $a"
variable a delete

#将多刚体系统s1中的约束j2去除
change system s1 removejoint j2

#运行200步
run s1 200

print "finish"

0 comments on commit 760a03f

Please sign in to comment.