def sendMsg(self, msg) : if self.isConnected : (axis, action) = msg if axis == 0 : if action == 'CALIB' : KNI.calibrate(0) elif action == 'SETHOME' : from KNI import TMovement self.home = TMovement() KNI.getPosition(self.home.pos) self.home.transition = KNI.PTP self.home.velocity = 50 self.home.acceleration = 2 elif action == 'MOVEHOME' : if self.home != None : KNI.executeMovement(self.home) else : if action == 'STOP' : KNI.moveMot(axis, KNI.getEncoder(axis), 50, 2) elif action == 'RIGHT' : if axis in self.minusMotors : KNI.moveMot(axis, 0, 50, 2) else : KNI.moveMot(axis, 31000, 50, 2) elif action == 'LEFT' : if axis in self.minusMotors : KNI.moveMot(axis, -31000, 50, 2) else : KNI.moveMot(axis, 0, 50, 2) else : print "Port is not connected"
# PKE/JHA, 2008 ############################################################################################ """ This Skript demonstrates the use of the KNI library through the Python wrapper For API doc, read the kni_wrapper doc or the kni_wrapper.h file. """ ############################################################################################# import sys sys.path.append("../") import KNI from KNI import TMovement ############################################################################################# import KNI KNI.initKatana("../../configfiles450/katana6M90T.cfg", "192.168.1.1") KNI.calibrate(0) home = TMovement() KNI.getPosition(home.pos) home.transition = KNI.PTP home.velocity = 50 home.acceleration = 2 raw_input("Press [ENTER] to release robot.") KNI.allMotorsOff() stackname = "test" raw_input("Press [ENTER] to store first point (p2p movement).") m = TMovement() KNI.getPosition(m.pos)
def calibrate(self): """Mandatory call upon hardware switch on. Also can be use to test calibration procedure.""" # TODO: use another sequence so that the arm does not collide itself if KNI.calibrate(0) == -1: raise SpineError('failed to calibrate hardware')