Exemple #1
0
        public async Task Start()
        {
            // wait for start button press.
            while (!this.buttonController.GetButtonPressed())
            {
                await Task.Delay(1);
            }

            var laps          = 0;
            var previousValue = false;

            while (laps <= 3)
            {
                while (true)
                {
                    var nearestTrafficcone = await FaceNearestTrafficCone();
                    await ApproachNearestVisibleTrafficCone(nearestTrafficcone);

                    if (!previousValue && this.objectDetectionController.GetNearestDetectedTrafficConeHorizontal() != null)
                    {
                        // rising edge - seeing it first in this round
                        previousValue = true;
                        break;
                    }

                    if (previousValue && this.objectDetectionController.GetNearestDetectedTrafficConeHorizontal() == null)
                    {
                        previousValue = false;
                        // driving past - do nothing except setting previous false
                    }
                }

                laps++;
            }

            motorController.Stop();
        }