3D列印機_控制噴嘴 <<
Previous Next >> 3D列印機_控制高度
3D列印機_自動繪製
自動繪製正方體
3D print AutoControl cube.ttt
自動繪製圓柱體
3D print AutoControl circle.ttt
自動繪製心臟線
3D print AutoControl Cardioid.ttt
參考影片
程式參考:
1.正方體
find_Position=function()
XYZ={xp, yp, zz, step}
end
function sysCall_threadmain()
joint01=sim.getObjectHandle('X')
joint02=sim.getObjectHandle('Y')
joint03=sim.getObjectHandle('Z')
grap=sim.getObjectHandle('Graph')
set=0
set1=0
set2=0
s=0.01
step=1
xp=0
yp=0
zz=0
xstep=0
ystep=0
zstep=0
cubesize=10
t=1
while zstep<=cubesize do
while step<cubesize do --go++
while xstep<=step do
xp=xp+s
sim.setJointTargetPosition(joint01,xp)
find_Position()
print(XYZ)
xstep=xstep+1
sim.wait(t)
end
while ystep<=step do
yp=yp+s
sim.setJointTargetPosition(joint02,yp)
find_Position()
print(XYZ)
ystep=ystep+1
sim.wait(t)
end
--step=step+1
xstep=0
ystep=0
while xstep<=step do
xp=xp-s
sim.setJointTargetPosition(joint01,xp)
find_Position()
print(XYZ)
xstep=xstep+1
sim.wait(t)
end
while ystep<=step do --go--
yp=yp-s
sim.setJointTargetPosition(joint02,yp)
find_Position()
print(XYZ)
ystep=ystep+1
sim.wait(t)
end
if step < (cubesize-1) then
xp=xp-0.5*s
yp=yp-0.5*s
sim.setJointTargetPosition(joint01,xp)
sim.setJointTargetPosition(joint02,yp)
find_Position()
print(XYZ)
end
step=step+1
sim.wait(t)
xstep=0
ystep=0
end
step=1
zz=zz+s
sim.setJointTargetPosition(joint03,zz)
find_Position()
print(XYZ)
zstep=zstep+1
sim.wait(t)
xp=0
yp=0
sim.setJointTargetPosition(joint01,xp)
sim.setJointTargetPosition(joint02,yp)
find_Position()
print(XYZ)
sim.wait(t)
end
end
function sysCall_cleanup()
end
-- See the user manual or the available code snippets for additional callback functions and details
2. 圓柱體
function sysCall_threadmain()
joint01=sim.getObjectHandle('X')
joint02=sim.getObjectHandle('Y')
joint03=sim.getObjectHandle('Z')
grap=sim.getObjectHandle('Graph')
set=0
set1=0
set2=0
s=0.01
step=1
r=0.005
rset=0.01
zz=0
zstep=1
dz=0.01
rstep=1
cubesize=10
t=0.01
angle=0
angleset=2
end
function sysCall_cleanup()
while zstep<=20 do
while rstep<=5 do
while angle~=360 do
angle=angle+angleset
sim.setJointTargetPosition(joint01,r*(math.sin(angle*math.pi/180)))
sim.setJointTargetPosition(joint02,r*(math.cos(angle*math.pi/180)))
sim.wait(t)
end
rstep=rstep+1
angle=0
r=r+rset
print(rstep)
end
zz=zz+dz
zstep=zstep+1
sim.setJointTargetPosition(joint03,zz)
sim.setJointTargetPosition(joint01,0)
sim.setJointTargetPosition(joint02,0)
rstep=1
r=0.005
end
end
-- See the user manual or the available code snippets for additional callback functions and details
3. 心臟線
function sysCall_threadmain()
joint01=sim.getObjectHandle('X')
joint02=sim.getObjectHandle('Y')
joint03=sim.getObjectHandle('Z')
grap=sim.getObjectHandle('Graph')
set=0
set1=0
set2=0
s=0.01
step=1
r=0.005
rset=0.001
zz=0
zstep=1
dz=0.001
rstep=1
cubesize=10
t=0.5
angle=0
angleset=2
end
function sysCall_cleanup()
while zstep<=30 do
while rstep<=30 do
while angle~=360 do
angle=angle+angleset
sim.setJointTargetPosition(joint01,2*r*((math.cos(angle*math.pi/180))-0.5*(math.cos(2*angle*math.pi/180))))
sim.setJointTargetPosition(joint02,2*r*((math.sin(angle*math.pi/180))-0.5*(math.sin(2*angle*math.pi/180))))
sim.wait(t)
end
rstep=rstep+1
angle=0
r=r+rset
print(rstep)
end
zz=zz+dz
zstep=zstep+1
sim.setJointTargetPosition(joint03,zz)
sim.setJointTargetPosition(joint01,0)
sim.setJointTargetPosition(joint02,0)
rstep=1
r=0.005
end
end
3D列印機_控制噴嘴 <<
Previous Next >> 3D列印機_控制高度