def _play(self, animation, fps, name): if not self._acquireChannel(name): rospy.logerr("Unable to play %s. Anopther animation is running.") return try: #start = time() dt = 1.0 / float(fps) t = time() for f in animation.frames(self._last_postions): for m in f: if m in self._cmders: msg = self._cmders[m].msg_fracDist(f[m]) self._pub(msg) else: if m in self._motors: self._cmders[m] = MotorCmder(self._motors[m]) msg = self._cmders[m].msg_fracDist(f[m]) self._pub(msg) self._last_postions[m] = f[m] # Exclude execution for more accurate timing t2 = time() i = dt - t2 + t if i > 0: sleep(i) t = time() except: rospy.logerr("Error play animation {}".format(animation)) finally: self._releaseChannel(name)
def __init__(self, motors_yaml): motor_commanders = [] for motor_entry in motors_yaml: try: motor_commanders.append(MotorCmder(motor_entry)) except: print "Failed to create motor Entry {}".format(motor_entry) self.motor_commanders = motor_commanders
def __init__(self, motors_yaml): motor_commanders = [] for motor_entry in motors_yaml: motor_commanders.append(MotorCmder(motor_entry)) self.motor_commanders = motor_commanders
def __init__(self, expr_entry, motor_yaml): # Create MotorCmder objects. cmders = [] for motorname in expr_entry: cmders.append(MotorCmder(motor_yaml[motorname], expr_entry[motorname])) self.motor_commanders = cmders