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"
def set_neck_rot_pos(self, rot_xyz=None, pos_xyz=None): """Absolute orentation and position using KNI IK""" if not self._motors_on or (rot_xyz == pos_xyz == None): LOG.info('motors are %s [rot: %s\t pos: %s]', self._motors_on, rot_xyz, pos_xyz) return False tp = KNI.TPos() KNI.getPosition(tp) if rot_xyz: tp.phy, tp.theta, tp.psi = rot_xyz if pos_xyz: tp.X, tp.Y, tp.Z = pos_xyz ret = KNI.moveToPos(tp, self._speed, self._accel) KNI.getPosition(tp) if ret == -1: raise SpineError('failed to reach rotation/position') return True
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) m.transition = KNI.PTP m.velocity = 50 m.acceleration = 2