Beispiel #1
0
        /// <summary>
        /// Start lidar (at least try)
        /// </summary>
        /// <param name="mode">Scan mode</param>
        /// <returns>true if succeeded, false if not</returns>
        private bool StartLidar(ScanMode mode)
        {
            // Get health
            HealthInfo health = lidar.GetHealth();

            if (health == null)
            {
                return(false);
            }

            // Good health ?
            if (health.Status != HealthStatus.Good)
            {
                logger.LogWarning($"Health {health.Status}, error code {health.ErrorCode}.");
                return(false);
            }

            // Good health
            logger.LogInformation($"Health good.");

            // Get configuration
            Configuration config = lidar.GetConfiguration();

            if (config == null)
            {
                return(false);
            }

            // Show configuration
            logger.LogInformation("Configuration:");
            foreach (KeyValuePair <ushort, ScanModeConfiguration> modeConfig in config.Modes)
            {
                logger.LogInformation($"0x{modeConfig.Key:X4} - {modeConfig.Value}"
                                      + (config.Typical == modeConfig.Key ? " (typical)" : string.Empty));
            }

            // Start motor
            lidar.ControlMotorDtr(false);

            // Start scanning
            if (!lidar.StartScan(mode))
            {
                return(false);
            }

            // Report
            logger.LogInformation("Scanning started.");

            return(true);
        }