Esempio n. 1
0
        private void sensorDataProcessor(SignalClassifierController classifier, int sensorQty,
                                         ref IEnumerable <IEnumerable <short> > readings, string robotBodyPart)
        {
            var frame = readings;

            var processingResult = predictSingleFrame(frame, classifier, sensorQty);

            Console.WriteLine(processingResult);
            var eventArgs = new DataProcessorEventArgs();

            if (processingResult.classPercentages.All(cp => cp < 0.6) &&
                !processingResult.prediction.Contains("Strike"))
            {
                switch (robotBodyPart)
                {
                case "topHead":
                    eventArgs.predictionData = "OtherLowTopHead";
                    break;

                case "leftSideHead":
                    eventArgs.predictionData = "OtherLowLeftSideHead";
                    break;

                case "rightSideHead":
                    eventArgs.predictionData = "OtherLowRightSideHead";
                    break;

                case "rightHand":
                    eventArgs.predictionData = "OtherLowRightHand";
                    break;

                case "leftHand":
                    eventArgs.predictionData = "OtherLowLeftHand";
                    break;

                case "front":
                    eventArgs.predictionData = "OtherLowFront";
                    break;

                default:
                    eventArgs.predictionData = "OtherLowLeftSideHead";
                    break;
                }
            }
            else
            {
                eventArgs.predictionData = processingResult.prediction;
            }

            sensorDataProcessed.Invoke(this, eventArgs);

            eventArgs = null;

            readings = Enumerable.Repeat(Enumerable.Repeat <short>(0, sensorQty), 100);
        }
Esempio n. 2
0
        private SignalClassifierController.PredictionResult predictFrame(
            IEnumerable <IEnumerable <short> > frame, int frameSize, SignalClassifierController classifier, int sensorQty)
        {
            var adjustedFrame =
                Enumerable.Repeat(Enumerable.Repeat <short>(0, sensorQty), frameSize).ToArray();

            var frameArray = frame.ToArray();

            for (int i = 0; i < (frameArray.Length > frameSize ? adjustedFrame.Length : frameArray.Length); i++)
            {
                adjustedFrame[i] = frameArray[i];
            }

            string strFrameSize = "";

            if (frameSize == 100)
            {
                strFrameSize = "single";
            }
            else if (frameSize == 200)
            {
                strFrameSize = "double";
            }
            else
            {
                strFrameSize = "half";
            }

            string sensorType = "";

            if (sensorQty == 4)
            {
                sensorType = "four";
            }
            else
            {
                sensorType = "two";
            }

            return(classifier.predict(strFrameSize, sensorType, classifier.convertFrame(adjustedFrame)));
        }
Esempio n. 3
0
 private SignalClassifierController.PredictionResult predictDoubleFrame(
     IEnumerable <IEnumerable <short> > frame, SignalClassifierController classifier, int sensorQty)
 {
     return(predictFrame(frame, 200, classifier, sensorQty));
 }