Esempio n. 1
0
        private async Task Initialze()
        {
            if (LightningProvider.IsLightningEnabled)
            {
                LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
            }
            else
            {
                throw new Exception("Lightning drivers not enabled. Please enable Lightning drivers.");
            }

            _camera = new Camera();
            await _camera.Initialize();
            
            SpeedSensor.Initialize();
            SpeedSensor.Start();

            SpeechSynthesis.Initialze();

            await AudioPlayerController.Initialize();

            _accelerometerSensor = new AccelerometerGyroscopeSensor();
            await _accelerometerSensor.Initialize();
            _accelerometerSensor.Start();

            _automaticSpeakController = new AutomaticSpeakController(_accelerometerSensor);

            _motorController = new MotorController();
            await _motorController.Initialize(_automaticSpeakController);

            _servoController = new ServoController();
            await _servoController.Initialize();

            _distanceMeasurementSensor = new DistanceMeasurementSensor();
            await _distanceMeasurementSensor.Initialize(I2C_ADDRESS_SERVO);

            _automaticDrive = new AutomaticDrive(_motorController, _servoController, _distanceMeasurementSensor);

            _speechRecognation = new SpeechRecognition();
            await _speechRecognation.Initialze(_motorController, _servoController, _automaticDrive);
            _speechRecognation.Start();

            _gamepadController = new GamepadController(_motorController, _servoController, _automaticDrive, _accelerometerSensor);

            _camera.Start();

            _httpServerController = new HttpServerController(_motorController, _servoController, _automaticDrive, _camera);

            SystemController.Initialize(_accelerometerSensor, _automaticSpeakController, _motorController, _servoController, _automaticDrive, _camera, _httpServerController, _speechRecognation, _gamepadController);

            await SystemController.SetAudioRenderVolume(AUDIO_RENDER_VOLUME, true);
            await SystemController.SetAudioCaptureVolume(AUDIO_CAPTURE_VOLUME, true);
            
            await AudioPlayerController.PlayAndWaitAsync(AudioName.Welcome);

            _automaticSpeakController.Start();
        }
Esempio n. 2
0
        public HttpServer(MotorController motorController,
                          ServoController servoController,
                          AutomaticDrive automaticDrive,
                          Camera camera)
        {
            _motorController = motorController;
            _servoController = servoController;
            _automaticDrive  = automaticDrive;
            _camera          = camera;

            _listener = GetStreamSocketListener();
        }
Esempio n. 3
0
        public GamepadController(MotorController motorController,
                                 ServoController servoController,
                                 AutomaticDrive automaticDrive,
                                 AccelerometerGyroscopeSensor acceleratorSensor)
        {
            if (_shutdown)
            {
                return;
            }

            _motorController   = motorController;
            _servoController   = servoController;
            _automaticDrive    = automaticDrive;
            _acceleratorSensor = acceleratorSensor;

            Gamepad.GamepadAdded   += GamepadAdded;
            Gamepad.GamepadRemoved += GamepadRemoved;
        }
Esempio n. 4
0
        public async Task Initialze(MotorController motorController,
                                    ServoController servoController,
                                    AutomaticDrive automaticDrive)
        {
            _motorController = motorController;
            _servoController = servoController;
            _automaticDrive  = automaticDrive;

            _speechRecognizer = new SpeechRecognizer(new Language("de-DE"));

            var grammerFile = await Package.Current.InstalledLocation.GetFileAsync(@"Audio\SpeechRecognizerGrammer.xml");

            var grammarConstraint = new SpeechRecognitionGrammarFileConstraint(grammerFile);

            _speechRecognizer.Constraints.Add(grammarConstraint);
            var compilationResult = await _speechRecognizer.CompileConstraintsAsync();

            _speechRecognizer.ContinuousRecognitionSession.ResultGenerated += RecognationResult;
            _speechRecognizer.ContinuousRecognitionSession.Completed       += ContinuousRecognitionSession_Completed;
        }
Esempio n. 5
0
 public HttpServerController(MotorController motorController,
                             ServoController servoController,
                             AutomaticDrive automaticDrive,
                             Camera camera)
 {
     Task.Factory.StartNew(() =>
     {
         _httpServer = new HttpServer(motorController,
                                      servoController,
                                      automaticDrive,
                                      camera);
         _httpServer.Start();
     }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)
     .AsAsyncAction()
     .AsTask()
     .ContinueWith((t) =>
     {
         Logger.Write(nameof(HttpServerController), t.Exception).Wait();
         SystemController.ShutdownApplication(true).Wait();
     }, TaskContinuationOptions.OnlyOnFaulted);
 }
Esempio n. 6
0
        public static void Initialize(AccelerometerGyroscopeSensor accelerometerSensor,
                                      AutomaticSpeakController automaticSpeakController,
                                      MotorController motorController,
                                      ServoController servoController,
                                      AutomaticDrive automaticDrive,
                                      Camera camera,
                                      HttpServerController httpServerController,
                                      SpeechRecognition speechRecognation,
                                      GamepadController gamepadController)
        {
            _accelerometerSensor      = accelerometerSensor;
            _automaticSpeakController = automaticSpeakController;
            _motorController          = motorController;
            _servoController          = servoController;
            _automaticDrive           = automaticDrive;
            _camera = camera;
            _httpServerController = httpServerController;
            _speechRecognation    = speechRecognation;
            _gamepadController    = gamepadController;

            _initialized = true;
        }