#!/usr/bin/python3
#---------------------------------------------------------------------------
# VISMACH 5 axis rotating/tilting spindle router simulation
# Rudy du Preez, SA-CNC-CLUB, 3/2014
#---------------------------------------------------------------------------
from vismach import *
import hal
import math
import sys
# give endpoint Z values and radii
# resulting cylinder is on the Z axis
class HalToolCylinder(CylinderZ):
def __init__(self, comp, *args):
CylinderZ.__init__(self, *args)
self.comp = comp
def coords(self):
return self.comp.tool_length, 3, 0, 3
c = hal.component("sptiltgui")
c.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("joint3", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("joint4", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("joint5", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("tool_length", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("pivot_length", hal.HAL_FLOAT, hal.HAL_IN)
c.ready()
pivot_len = 50
tool_len = 40
Lt = pivot_len + tool_len
for setting in sys.argv[1:]: exec setting
tooltip = Capture()
tool = Collection([tooltip,
HalToolCylinder(c,"tool_length"),
CylinderZ(tool_len, 30, Lt+70, 30)
])
baxis = CylinderY(-65,10,65,10)
baxis = Translate([baxis],0,0,Lt)
baxis = Collection([tool,
baxis,
])
baxis = Color([1,0,0.5,1],[baxis])
baxis = Translate([baxis],0,0,-Lt)
baxis = HalRotate([baxis],c,"joint4",1,0,1,0)
baxis = Translate([baxis],-130,0,Lt)
yoke = Collection([Box(-30,-32,0, 30,-52,-90),
Box(-30, 32,0, 30, 52,-90),
CylinderZ(0, 56,-15,56)
])
yoke = Translate([yoke],-130,0,Lt+90)
yoke = Color([1,0.5,0,1],[yoke])
caxis = Collection([baxis,
yoke,
])
caxis = Translate([caxis],130,0,0)
caxis = HalRotate([caxis],c,"joint5",1,0,0,1)
caxis = Translate([caxis],-130,0,0)
bmotor = CylinderZ(0,25,60,25)
bmotor = Translate([bmotor],20,30,0)
cmotor = CylinderZ(0,25,60,25)
cmotor = Translate([cmotor],20,-30,0)
zaxis = Collection([cmotor,bmotor,
CylinderZ(15,60,0,60),
Box(50,-60,-50, 80,60,60),
Box(0,-60,15, 50,60,0)
])
zaxis = Translate([zaxis],-130,0,Lt+90)
zaxis = Color([0,1,1,1],[zaxis])
zaxis = Collection([caxis,zaxis,
])
zaxis = Translate([zaxis], 0,0,-150)
zaxis = HalTranslate([zaxis],c,"joint2",0,0,1)
zmotor = CylinderZ(150,25,90,25)
zmotor = Translate([zmotor],10,0,0)
saddle = Collection([zaxis,zmotor,
Box(-10,-50,-100, -50,50,150)
])
saddle = HalTranslate([saddle],c,"joint1",0,1,0)
ybridge = Collection([
Box(-60,255,-350, 60,285,0),
Box(-60,-255,-350, 60,-285,0),
Box(-30,-280,-100, 30,280,0),
Box(-70,255,-350, 70,295,-320),
Box(-70,-255,-350, 70,-295,-320),
])
ybridge = Color([0,1,0,1],[ybridge])
ybridge = Collection([saddle,ybridge])
ybridge = HalTranslate([ybridge],c,"joint0",1,0,0)
xaxes = Collection([
Box(-500,-300,-400, 500, -250,-350),
Box(-500, 300,-400, 500, 250,-350)
])
xaxes = Color([0,0,1,1],[xaxes])
router = Collection([xaxes,ybridge])
work = Capture()
table = Collection([
work,
Box(-500,-250,-320, 500,250,-365)
])
model = Collection([router, table])
main(model, tooltip, work, 1500)
