Corollary: the 1/30 second limit also means that apanx's FBS.py uses an unnecessarily low tick interval. It should be able to be increased from 0.001 to 0.0333 with no loss in performance, thus decreasing lag.
#Measure RPM if (self.GetMotorAngle(self.motorID) > math.pi/3 or self.GetMotorAngle(self.motorID) < 0) and self.measuring == 0: self.revolution += self.tickInterval self.measuring = 1 if self.measuring == 1: self.revolution += self.tickInterval if 0 < self.GetMotorAngle(self.motorID) < math.pi/3 and self.measuring == 1: self.RPM = 50 / self.revolution self.revolution = 0 if self.display != 0: self.RPMhist.append(self.RPM) if self.RPM > self.max_RPM: self.max_RPM = self.RPM self.measuring = 0
Code: [Select]self.revolution += plus.AI.__getattr__tickInterval__(self)
self.revolution += plus.AI.__getattr__tickInterval__(self)
self.revolution += self.tickInterval
*downloads*I'm going to try and implement a RPM-measuring thing in Omni.pyEdit: lol it already is in NAR AI :P
Quote from: apanx on September 21, 2010, 12:43:13 PMCode: [Select]self.revolution += plus.AI.__getattr__tickInterval__(self)Why would you do such a horrible thing? Provided self is actually a plus.AI instance:Code: [Select]self.revolution += self.tickInterval
Used the old code because the tickInterval attribute did not show up when doing a dir() on plus.AI.
#Measure RPM if (self.GetMotorAngle(self.motorID) > math.pi/3 or self.GetMotorAngle(self.motorID) < 0) and self.measuring == 0: self.revolution = 0 self.measuring = 1 if self.measuring == 1: self.revolution += self.tickInterval if 0 < self.GetMotorAngle(self.motorID) < math.pi/3 and self.measuring == 1: self.RPM = 50/self.revolution if self.display != 0: self.RPMhist.append(self.RPM) if self.RPM > self.max_RPM: self.max_RPM = self.RPM self.measuring = 0
#Measure RPM #looping timer for RPM calculation self.measuring += 1 if self.measuring > 1: self.measuring = 0 if self.measuring == 1: self.angle2 = self.GetMotorAngle(self.motorID) #correct for pi/-pi transition area if self.angle1 > 0 and self.angle2 < 0 and self.spindir == 1: self.angle2 += math.pi*2 if self.angle1 < 0 and self.angle2 > 0 and self.spindir == 0: self.angle1 += math.pi*2 self.RPM = (abs(self.angle2 - self.angle1)/(math.pi*2))*(60/self.tickInterval) if self.display != 0: self.RPMhist.append(self.RPM) if self.RPM > self.max_RPM: self.max_RPM = self.RPM if self.measuring == 0: self.angle1 = self.GetMotorAngle(self.motorID)
-Rev reducer (in case of loss of weapon/stability)
Quote from: Madiaba on October 04, 2010, 12:46:42 AM-Rev reducer (in case of loss of weapon/stability)Great idea! I already have a stall checker, but I didn't think of this.Oh wait... that would actually be possible to do without the RPM calculator. Just use an analog and tell it to input at half power when it loses weapons or something. Still a good idea though.
To get a higher resolution time delta:http://docs.python.org/library/time.html#time.clock"The resolution is typically better than one microsecond."
I too agree, this code is pretty revolutionary. I can see this being used in the following ways: If bot with implemented code loses more than half of its weapons, slow down RPM in order to save battery life.If bot with implemented code loses more than half of its weapons, slow down RPM in order to prevent it from spinning offbalance.I think, if possible, that this could be applied to other bot types as well. If flipper loses all "weapons" on its motors used for flipping, ignore trying to flip when enemy touches its smartzone and resort to trying to pin. Saving battery.If popup loses the "flipping components", ignore those motors and only use the weapons. Vise versa for the "weapon components".Though I do believe that the later might not be possible atm.