00001 ''' 00002 Created on Feb 13, 2013 00003 00004 @author: dnad 00005 ''' 00006 class Speed(object): 00007 ''' 00008 The class generates speed trajectories based on configurations. 00009 ''' 00010 def __init__(self, valueList): 00011 ''' 00012 Constructor 00013 :param valueList: list of (time, value) pairs. 00014 ''' 00015 self.valueList = valueList; 00016 00017 self._timebase = 0; 00018 self._curVal = 0; 00019 self._curspeed = 0; 00020 00021 def step(self, dT): 00022 from numpy import min 00023 00024 if (self._timebase >= self.valueList[self._curVal][0]): 00025 self._curspeed = self.valueList[self._curVal][1]; 00026 self._curVal=min([(self._curVal+1),len(self.valueList)-1]); 00027 00028 self._timebase += dT; 00029 00030 return self._curspeed; 00031 00032 00033 00034