Exemple #1
0
 private void Front_ObstacleDetection_ObstacleDetected(Sensor.ObstacleDetection.DetectionState arg1, double arg2)
 {
     // If AvoideObstacle is set, check for the detection state
     if (AvoidObstacle == true)
     {
         // Verify detection state and current driving state, if matched, stop robot
         if (arg1 == Sensor.ObstacleDetection.DetectionState.Detected && MotorDriver.CurrentState == MotorDriver.State.MovingForward)
         {
             MotorDriver.Stop();
             Debug.WriteLine("Robot stopped! (Obstacle Detected)");
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Fires when MyRecognizer successfully parses a speech
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void MyRecognizer_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args)
        {
            // Write Debug Information
            Debug.WriteLine(args.Result.Text);

            // Drive robot on recognized speech
            switch (args.Result.Text)
            {
            case "move forward":
                MotorDriver.MoveForward();
                break;

            case "move reverse":
                MotorDriver.MoveReverse();
                break;

            case "turn right":
                MotorDriver.TurnRight();
                break;

            case "turn left":
                MotorDriver.TurnLeft();
                break;

            case "stop":
                MotorDriver.Stop();
                break;

            case "engage obstacle detection":
                AvoidObstacle = true;
                break;

            case "disengage obstacle detection":
                AvoidObstacle = false;
                break;

            default:
                break;
            }

            // Turn on/off obstacle detection
        }