summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhoekstar <hoekstar@cb376a5e-1013-0410-a455-b6b1f9ac8223>2009-02-21 20:34:57 +0000
committerhoekstar <hoekstar@cb376a5e-1013-0410-a455-b6b1f9ac8223>2009-02-21 20:34:57 +0000
commit1efde586b582c732262055b66fcea300208e1a80 (patch)
tree25be2d74832a22b140e5e0cf8a404139cfa033f0
parent4da776602857773b21ec1b032fc81538df210934 (diff)
downloadreprap-backup-1efde586b582c732262055b66fcea300208e1a80.tar.gz
reprap-backup-1efde586b582c732262055b66fcea300208e1a80.zip
script is looking pretty good now.
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@2580 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rwxr-xr-xtrunk/users/hoeken/pythagoras/make_bot.py274
1 files changed, 148 insertions, 126 deletions
diff --git a/trunk/users/hoeken/pythagoras/make_bot.py b/trunk/users/hoeken/pythagoras/make_bot.py
index 44eb59e1..5a7986fe 100755
--- a/trunk/users/hoeken/pythagoras/make_bot.py
+++ b/trunk/users/hoeken/pythagoras/make_bot.py
@@ -72,125 +72,129 @@ class CartesianFrame:
def main(argv):
- global x, y, z, feedrate, nutHeight, washerHeight, rodSize, blockSize, useThreadLocker, useNutStarter, useWashers
-
- xRods = 4
- yRods = 4
- zRods = 4
- xyRods = 2
- xzRods = 4
- yzRods = 4
- totalRods = xRods + yRods + zRods + xyRods + xzRods + yzRods
-
- nutsPerKebab = 4
- totalNuts = totalRods * nutsPerKebab
-
- washersPerKebab = 4
- totalWashers = totalRods * washersPerKebab
-
- try:
- opts, args = getopt.getopt(argv, "h", ["help", "x=", "y=", "z=", "feedrate=", "nut-height=", "washer-height=", "rod-size=", "block-size=", "use-thread-locker", "use-nut-starter", "no-washers"])
- except getopt.GetoptError:
- usage()
- sys.exit(2)
-
- for opt, arg in opts:
- if opt in ("-h", "--help"):
- usage()
- sys.exit()
- elif opt == "--x":
- x = float(arg)
- elif opt == "--y":
- y = float(arg)
- elif opt == "--z":
- z = float(arg)
- elif opt == "--feedrate":
- feedrate = float(arg)
- elif opt == "--nut-height":
- nutHeight = float(arg)
- elif opt == "--washer-height":
- washerHeight = float(arg)
- elif opt == "--block-size":
- blockSize = float(arg)
- elif opt == "--rod-size":
- rodSize = float(arg)
- elif opt == "--use-thread-locker":
- useThreadLocker = True
- elif opt == "--use-nut-starter":
- useNutStarter = True
- elif opt == "--no-washers":
- useWashers = False
- else:
- print "(Huh? %s:%s)" % (opt,arg)
-
- bot = CartesianFrame(x, y, z)
-
- print "(Generated by make_bot.py)"
- print "(Required Rod Lengths:)"
- print "( X Rods: 4 * %6.2fmm)" % (x)
- print "( Y Rods: 4 * %6.2fmm)" % (y)
- print "( Z Rods: 4 * %6.2fmm)" % (z)
- print "(XZ Rods: 4 * %6.2fmm)" % (bot.getXZ())
- print "(YZ Rods: 4 * %6.2fmm)" % (bot.getYZ())
- print "(XY Rods: 2 * %6.2fmm)" % (bot.getXY())
- print "(Total Volume: %6.2fm^3)" % (bot.getVolume())
- print "(Total kebabs: %d)" % (totalRods)
- print "(Total nuts required: %d)" % (totalNuts)
- if useWashers:
- print "(Total washers required: %d)" % (totalNuts)
- #TODO: print the total number of whole rods required.
- print "(GCODE STARTS BELOW)"
- print "G90 (Absolute Mode)"
- print "G21 (Metric Units)"
-
- print "M00 (Starting X kebabs)"
- for i in range(0, xRods):
- build_frame_kebab(x)
-
- print "M00 (Starting Y kebabs)"
- for i in range(0, yRods):
- build_frame_kebab(y)
-
- print "M00 (Starting Z kebabs)"
- for i in range(0, zRods):
- build_frame_kebab(z)
-
- print "M00 (Starting XY kebabs)"
- for i in range(0, xyRods):
- build_diagonal_kebab(bot.getXY())
-
- print "M00 (Starting XZ kebabs)"
- for i in range(0, xzRods):
- build_diagonal_kebab(bot.getXZ())
+ global x, y, z, feedrate, nutHeight, washerHeight, rodSize, blockSize, useThreadLocker, useNutStarter, useWashers
+
+ try:
+ opts, args = getopt.getopt(argv, "h", ["help", "x=", "y=", "z=", "feedrate=", "nut-height=", "washer-height=", "rod-size=", "block-size=", "use-thread-locker", "use-nut-starter", "no-washers"])
+ except getopt.GetoptError:
+ usage()
+ sys.exit(2)
+
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit()
+ elif opt == "--x":
+ x = float(arg)
+ elif opt == "--y":
+ y = float(arg)
+ elif opt == "--z":
+ z = float(arg)
+ elif opt == "--feedrate":
+ feedrate = float(arg)
+ elif opt == "--nut-height":
+ nutHeight = float(arg)
+ elif opt == "--washer-height":
+ washerHeight = float(arg)
+ elif opt == "--block-size":
+ blockSize = float(arg)
+ elif opt == "--rod-size":
+ rodSize = float(arg)
+ elif opt == "--use-thread-locker":
+ useThreadLocker = True
+ elif opt == "--use-nut-starter":
+ useNutStarter = True
+ elif opt == "--no-washers":
+ useWashers = False
+ else:
+ print "(Huh? %s:%s)" % (opt,arg)
+
+ bot = CartesianFrame(x, y, z)
+
+ xRods = 4
+ yRods = 4
+ zRods = 4
+ xyRods = 2
+ xzRods = 4
+ yzRods = 4
+ totalRods = xRods + yRods + zRods + xyRods + xzRods + yzRods
+
+ nutsPerKebab = 4
+ totalNuts = totalRods * nutsPerKebab
- print "M00 (Starting YZ kebabs)"
- for i in range(0, yzRods):
- build_diagonal_kebab(bot.getYZ())
+ if useWashers:
+ washersPerKebab = 4
+ totalWashers = totalRods * washersPerKebab
+ else:
+ washersPerKebab = 0
+ totalWashers = 0
+
+ print "(Generated by make_bot.py)"
+ print "(Required Rod Lengths:)"
+ print "( X Rods: 4 * %6.2fmm)" % (x)
+ print "( Y Rods: 4 * %6.2fmm)" % (y)
+ print "( Z Rods: 4 * %6.2fmm)" % (z)
+ print "(XZ Rods: 4 * %6.2fmm)" % (bot.getXZ())
+ print "(YZ Rods: 4 * %6.2fmm)" % (bot.getYZ())
+ print "(XY Rods: 2 * %6.2fmm)" % (bot.getXY())
+ print "(Total Volume: %6.2fm^3)" % (bot.getVolume())
+ print "(Total kebabs: %d)" % (totalRods)
+ print "(Total nuts required: %d)" % (totalNuts)
+ print "(Total washers required: %d)" % (totalWashers)
+ #TODO: print the total number of whole rods required.
+ print "(GCODE STARTS BELOW)"
+ print "G90 (Absolute Mode)"
+ print "G21 (Metric Units)"
+
+ print "M00 (Starting X kebabs)"
+ for i in range(0, xRods):
+ build_frame_kebab(x)
+
+ print "M00 (Starting Y kebabs)"
+ for i in range(0, yRods):
+ build_frame_kebab(y)
+
+ print "M00 (Starting Z kebabs)"
+ for i in range(0, zRods):
+ build_frame_kebab(z)
+
+ print "M00 (Starting XY kebabs)"
+ for i in range(0, xyRods):
+ build_diagonal_kebab(bot.getXY())
+
+ print "M00 (Starting XZ kebabs)"
+ for i in range(0, xzRods):
+ build_diagonal_kebab(bot.getXZ())
+
+ print "M00 (Starting YZ kebabs)"
+ for i in range(0, yzRods):
+ build_diagonal_kebab(bot.getYZ())
def build_frame_kebab(length):
+ "Function to output the GCode to build a frame kebab of a certain length."
- #user prompt for raw materials
+ #user prompt for raw materials
if useWashers:
- print "M00 (Grab a %6.2fmm rod, 4 nuts, 4 washers, and 2 frame brackets)" % (length)
+ print "M00 (Grab a %6.2fmm rod, 4 nuts, 4 washers, and 2 frame brackets)" % (length)
else:
- print "M00 (Grab a %6.2fmm rod, 4 nuts, and 2 frame brackets)" % (length)
+ print "M00 (Grab a %6.2fmm rod, 4 nuts, and 2 frame brackets)" % (length)
#the first nut on the rod.
nutPosition = length - nutHeight - nutHeight
if useWashers:
- nutPosition = nutPosition - washerHeight - rodSize - blockSize
+ nutPosition = nutPosition - washerHeight - rodSize - blockSize - blockSize + washerHeight + nutHeight
else:
- nutPosition = nutPosition - rodSize - blockSize
+ nutPosition = nutPosition - rodSize - blockSize - blockSize + nutHeight
thread_nut(nutPosition)
#prompt the user for assembly
if useWashers:
- print "M00 (Slide on a washer / frame bracket / washer sandwich)"
+ print "M00 (Slide on a washer / frame bracket / washer sandwich)"
else:
print "M00 (Slide on a frame bracket)"
- #the second nut on the rod
+ #the second nut on the rod
if useWashers:
nutPosition = nutPosition - nutHeight - washerHeight - blockSize - washerHeight
else:
@@ -200,9 +204,9 @@ def build_frame_kebab(length):
#the 3rd nut on the rod
if useWashers:
- nutPosition = washerHeight + rodSize + blockSize + nutHeight + washerHeight + blockSize + washerHeight + nutHeight
+ nutPosition = washerHeight + rodSize + blockSize + blockSize + blockSize + washerHeight + nutHeight
else:
- nutPosition = rodSize + blockSize + nutHeight + blockSize + nutHeight
+ nutPosition = rodSize + blockSize + blockSize + blockSize + nutHeight
thread_nut(nutPosition)
#prompt the user for assembly
@@ -210,35 +214,53 @@ def build_frame_kebab(length):
#the 4th nut on the rod
if useWashers:
- nutPosition = washerHeight + rodSize + blockSize + nutHeight
+ nutPosition = nutPosition - nutHeight - washerHeight - blockSize - washerHeight
else:
- nutPosition = rodSize + blockSize + nutHeight
+ nutPosition = nutPosition - nutHeight - blockSize
thread_nut(nutPosition)
- print "M00 (Tighten them together.)"
+
+ #how far should the blocks be spaced?
+ if useWashers:
+ blockDistanceFar = length - nutHeight - washerHeight - rodSize - blockSize - blockSize
+ blockDistanceNear = nutHeight + washerHeight + rodSize + blockSize + blockSize
+ else:
+ blockDistanceFar = length - nutHeight - rodSize - blockSize - blockSize
+ blockDistanceNear = nutHeight + rodSize + blockSize + blockSize
+
+ #have them check it.
+ totalDistance = blockDistanceFar - blockDistanceNear
+ print "M00 (Double check the distance between the outside edges of the blocks. It should be: %6.2f. Hand tighten the nuts.)" % (totalDistance)
+
+ #okay, remove the rod
+ print "M00 (Firmly grasp the rod. We're going to remove it from the winder.)"
+ print "G1 Z%6.2f F%6.2f" % (-nutHeight * 1.5, feedrate * 0.5)
+ print "G92 Z0"
def build_diagonal_kebab(length):
- print "(TODO: make diagonal rod)"
-
+ "Function to output the GCode to build a diagonal kebab of a certain length."
+
+ print "(TODO: make diagonal rod)"
+
def thread_nut(position):
- "Thread the front of a nut to a position on the rod"
- print "M00 (Thread a nut on the rod)"
-
- #do we wanna use our nut starting device?
- if useNutStarter:
- print "G1 Z10 F%6.2f" % (feedrate)
-
- #zero us out.
- print "G92 Z0"
-
- #do we wanna use thread locking compound?
- if useThreadLocker:
- print "G1 Z%6.2f F%6.2f" % (position-nutHeight, feedrate)
- print "M00 (Apply thread locker just in front of the nut.)"
-
- print "G1 Z%6.2f F%6.2f" % (position, feedrate)
-
+ "Thread the front of a nut to a position on the rod"
+ print "M00 (Thread a nut on the rod)"
+
+ #do we wanna use our nut starting device?
+ if useNutStarter:
+ print "G1 Z10 F%6.2f" % (feedrate)
+
+ #zero us out.
+ print "G92 Z0"
+
+ #do we wanna use thread locking compound?
+ if useThreadLocker:
+ print "G1 Z%6.2f F%6.2f" % (position-nutHeight, feedrate)
+ print "M00 (Apply thread locker just in front of the nut.)"
+
+ print "G1 Z%6.2f F%6.2f" % (position, feedrate)
+
def usage():
- print __doc__
+ print __doc__
if __name__ == "__main__":
- main(sys.argv[1:])
+ main(sys.argv[1:])