def __init__(self, high_button, low_button, magnitude=1.0, lmagnitude=None, name=None, minpos=-1.0, maxpos=1.0): """ Create ButtonAxis where pressing high_button sets the axis position to magnitude. Pressing low_button sets the position to negative magnitude. Both or neither button sets the position to 0.0. """ if name == None: name = "ButtonAxis from %s and %s" % (high_button.name, low_button.name) else: name = name if lmagnitude is None: lmagnitude = magnitude Axis.__init__(self, name, minpos, maxpos) self.high_button = high_button self.low_button = low_button self.magnitude = magnitude self.lmagnitude = lmagnitude self.cb = MethodCallback(self.callback) high_button.addCallback(self.cb) low_button.addCallback(self.cb)
def __init__(self, roller): """ """ Roller.__init__(self, "EchoRoller for %s" % roller.name) self.roller = roller self.parents = (roller, ) self.cb = MethodCallback(self.move) roller.addCallback(self.cb)
def __init__(self, *buttons): """ Constructs ButtonChooser from a list of possible Buttons and other ButtonChoosers. """ Chooser.__init__(self, *buttons) self.cb = MethodCallback(self.callback) for n, b in enumerate(self): b.addCallback(self.cb, n, b)
def __init__(self, *buttonamounts): """ Constructor takes any number of 2-tuples: (Button, amount). """ Roller.__init__(self, "NotchRoller") self.buttonamounts = buttonamounts self.cb = MethodCallback(self.callback) for buttonamount in buttonamounts: buttonamount[0].addCallback(self.cb, buttonamount[1])
def __init__(self, *rollers): """ Create JointRoller based on rollers. """ Roller.__init__(self, "JointRoller") self.rollers = rollers self.parents = rollers self.cb = MethodCallback(self.move) for roller in rollers: roller.addCallback(self.cb)
def __init__(self, *axes): """ Constructs AxisChooser from a list of possible Axes and other AxisChoosers. """ Chooser.__init__(self, *axes) self.extrema = [] self.cb = MethodCallback(self.callback) for n, a in enumerate(self): a.addCallback(self.cb, n, a) self.extrema.append([0, 0])
def __init__(self, *rollers): """ Constructs RollerChooser from a list of possible Rollers and other RollerChoosers. """ Chooser.__init__(self, *rollers) self.totals = [] self.cb = MethodCallback(self.callback) for n, r in enumerate(self): r.addCallback(self.cb, n, r) self.totals.append(0.0)
def __init__(self, *set): """ Create EitherButton. Arguments of buttons to be included in the set. """ Button.__init__(self, "Button set (OR)") self.state = [] self.set = set self.cb = MethodCallback(self.callback) for n, button in enumerate(set): button.addCallback(self.cb, n) self.state.append(button.isPressed())
def __init__(self, *combo): """ Create ButtonCombo. Arguments of buttons to be included in the combination. """ Button.__init__(self, "Button combination (AND)") self.state = [] self.combo = combo self.cb = MethodCallback(self.callback) for n, button in enumerate(combo): button.addCallback(self.cb, n) self.state.append(button.isPressed())
def __init__(self, *axes): """ Arguments are taken as source axes. """ Axis.__init__(self, "JointAxis", min(map(getPosMin, axes)), max(map(getPosMax, axes))) self.axes = axes self.cb = MethodCallback(self.callback) self.positions = [] for n, axis in enumerate(axes): axis.addCallback(self.cb, n) self.positions.append(0.0) self.parents = axes self.sum = 0.0
def __init__(self, axis1, axis2, name=None): """ """ if name == None: name = "AxisScaledAxis (%s * %s)" % (axis1, axis2) else: name = name Axis.__init__(self, name, axis1.posmin * axis2.posmin, axis1.posmax * axis2.posmax) self.axis1 = axis1 self.axis2 = axis2 self.cb = MethodCallback(self.callback) axis1.addCallback(self.cb) axis2.addCallback(self.cb) self.parents = (axis1, axis2)
def __init__(self, axis, low=0.9, high=1.0, name=None): """ Create AxisButton from axis such that this Button is considered pressed when the position of axis falls between low and high. """ if name == None: name = "AxisButton from %s" % (axis.name) else: name = name Button.__init__(self, name) self.axis = axis self.low = low self.high = high self.cb = MethodCallback(self.callback) axis.addCallback(self.cb)
def __init__(self, roller, axis, factor=1.0, name=None): """ Create AxisScaledRoller. """ if name == None: name = "AxisScaledRoller (%s * %s * %f)" % (roller.name, axis.name, factor) else: name = name Roller.__init__(self, name) self.roller = roller self.parents = [roller] self.axis = axis self.factor = factor self.cb = MethodCallback(self.callback) roller.addCallback(self.cb)
def __init__(self, axis, maxVel=None, maxAccel=None, name=None): """ """ if name == None: name = "ThrottledAxis from %s" % axis.name else: name = name Axis.__init__(self, name, axis.posmin, axis.posmax) self.axis = axis self.lasttime = timing.now() self.lastpos = axis.getPosition() self.lastspeed = 0.0 self.maxVel = maxVel self.maxAccel = maxAccel self.cb = MethodCallback(self.callback) axis.addCallback(self.cb) self.parents = (axis, )
def __init__(self, roller, min=-1.0, max=1.0, start=0.0, name=None): """ Create RollerAxis from roller. min, max, and start may be used to specify minimum position, maximum position, and starting position, respectively. """ if name == None: name = "RollerAxis from %s" % roller.name else: name = name Axis.__init__(self, name, min, max) self.roller = roller self.min = min self.max = max self.setPosition(start) self.cb = MethodCallback(self.callback) roller.addCallback(self.cb)
def __init__(self, axis, scale, rscale=None, name=None): """ Create ScaledAxis based on axis with specified scale. """ if name == None: name = "ScaledAxis (%s * %f)" % (axis.name, scale) else: name = name if rscale is None: rscale = scale Axis.__init__(self, name, axis.posmin * scale, axis.posmax * scale) self.axis = axis self.scale = scale self.rscale = rscale self.cb = MethodCallback(self.callback) axis.addCallback(self.cb) self.parents = (axis, )
def __init__(self, roller, scale, reverse_scale=None, name=None): """ Create ScaledRoller with 'scale' and optionally different 'reverse_scale'. """ if name == None: name = "ScaledRoller from %s" % roller.name else: name = name Roller.__init__(self, name) if reverse_scale == None: self.reverse_scale = scale else: self.reverse_scale = reverse_scale self.forward_scale = scale self.roller = roller self.parents = [roller] self.cb = MethodCallback(self.callback) roller.addCallback(self.cb)
def __init__(self, roller, maxAccel=None, maxVel=None, name=None): """ Create a ThrottledRoller with maxAccel roller units per millisecond per millisecond maximum acceleration and maxVel roller units per millisecond maximum velocity. None for either of those values means that the constraint will not be applied. """ if name == None: name = "ThrottledRoller from %s" % roller.name else: name = name Roller.__init__(self, name) self.roller = roller self.parents = [roller] self.maxAccel = maxAccel self.maxVel = maxVel self.accum = 0.0 self.lastvelocity = 0.0 self.lasttime = timing.now() self.cb = MethodCallback(self.callback) roller.addCallback(self.cb)