void setup() { stream.useNormalizer(normalize); stream.setLabelsForAllDimensions({"red", "green", "blue"}); useStream(stream); useOutputStream(oStream); // useStream(stream); pipeline.addPreProcessingModule(MovingAverageFilter(5, 3)); // use scaling, use null rejection, null rejection parameter pipeline.setClassifier(ANBC(false, !always_pick_something, null_rej)); // null rejection parameter is multiplied by the standard deviation to determine // the rejection threshold. the higher the number, the looser the filter; the // lower the number, the tighter the filter. usePipeline(pipeline); registerTuneable(always_pick_something, "Always Pick Something", "Whether to always pick (predict) one of the classes of training data, " "even if it's not a very good match. If selected, 'Color Variability' " "will not be used.", updateAlwaysPickSomething); registerTuneable(null_rej, 1.0, 25.0, "Color Variability", "How different from the training data a new color reading can be and " "still be considered the same color. The higher the number, the more " "different it can be.", updateVariability); }
void CarVoltageGet(void) { MovingAverageFilter(); g_GravityAngle =(INT16S)(Asin_to_Angle[(abs_value(Acc_X)*100)/63]*GRAVITY_ANGLE_RATIO); g_GyroscopeAngleSpeed = g_GyroX*GYROSCOPE_ANGLE_RATIO; g_CarAngle = g_GyroscopeAngleIntegral; fDeltaValue = (g_GravityAngle - g_CarAngle)/GRAVITY_ADJUST_TIME_CONSTANT; //记住INT不要和float乱加会出bug!!!!!! //积分一定要用float型,否则小于1的数都会被忽视,效果太差 g_GyroscopeAngleIntegral += (g_GyroscopeAngleSpeed +fDeltaValue)/GYROSCOPE_ANGLE_SIGMA_FREQUENCY; Kalman_Filter(g_CarAngle,g_GyroscopeAngleSpeed); g_nCarAngle = ((INT16S)(Angle*10) ); //调整车体角度 g_nCarGyroVal = (INT16S)( Angle_dot ); }