コード例 #1
0
        //bool replayModeActivated = false;


        public PerceptionManager(int id, GameMode compet)
        {
            robotId        = id;
            competition    = compet;
            globalWorldMap = new GlobalWorldMap();

            robotPerception    = new Perception();
            physicalObjectList = new List <LocationExtended>();

            //Chainage des modules composant le Perception Manager
            absolutePositionEstimator = new AbsolutePositionEstimator(robotId);

            lidarProcessor = new LidarProcessor.LidarProcessor(robotId, competition);
            lidarProcessor.OnLidarBalisesListExtractedEvent    += absolutePositionEstimator.OnLidarBalisesListExtractedEvent;
            lidarProcessor.OnLidarBalisePointListForDebugEvent += OnLidarBalisePointListForDebugReceived;
            lidarProcessor.OnLidarObjectProcessedEvent         += OnLidarObjectsReceived;
            lidarProcessor.OnLidarProcessedEvent += OnLidarProcessedData;

            absolutePositionEstimator.OnAbsolutePositionCalculatedEvent += OnAbsolutePositionCalculatedEvent;

            PerceptionMonitor.swPerception.Start();
        }
コード例 #2
0
ファイル: Robot.cs プロジェクト: FloRide1/RoboCup2020
        static void Main(string[] args)
        {
            SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);

            // Set this code once in App.xaml.cs or application startup
            SciChartSurface.SetRuntimeLicenseKey("wsCOsvBlAs2dax4o8qBefxMi4Qe5BVWax7TGOMLcwzWFYRNCa/f1rA5VA1ITvLHSULvhDMKVTc+niao6URAUXmGZ9W8jv/4jtziBzFZ6Z15ek6SLU49eIqJxGoQEFWvjANJqzp0asw+zvLV0HMirjannvDRj4i/WoELfYDubEGO1O+oAToiJlgD/e2lVqg3F8JREvC0iqBbNrmfeUCQdhHt6SKS2QpdmOoGbvtCossAezGNxv92oUbog6YIhtpSyGikCEwwKSDrlKlAab6302LLyFsITqogZychLYrVXJTFvFVnDfnkQ9cDi7017vT5flesZwIzeH497lzGp3B8fKWFQyZemD2RzlQkvj5GUWBwxiKAHrYMnQjJ/PsfojF1idPEEconVsh1LoYofNk2v/Up8AzXEAvxWUEcgzANeQggaUNy+OFet8b/yACa/bgYG7QYzFQZzgdng8IK4vCPdtg4/x7g5EdovN2PI9vB76coMuKnNVPnZN60kSjtd/24N8A==");

            switch (robotMode)
            {
            case RobotMode.Standard:
                usingLidar     = true;
                usingCamera    = true;
                usingLogging   = false;
                usingLogReplay = false;
                break;

            case RobotMode.Acquisition:
                usingLidar     = true;
                usingCamera    = true;
                usingLogging   = true;
                usingLogReplay = false;
                break;

            case RobotMode.Replay:
                usingLidar     = false;
                usingCamera    = false;
                usingLogging   = false;
                usingLogReplay = true;
                break;

            case RobotMode.Nolidar:
                usingLidar     = false;
                usingCamera    = true;
                usingLogging   = false;
                usingLogReplay = false;
                break;

            case RobotMode.NoCamera:
                usingLidar     = true;
                usingCamera    = false;
                usingLogging   = false;
                usingLogReplay = false;
                break;
            }


            int robotId = (int)TeamId.Team1 + (int)RobotId.Robot1;
            int teamId  = (int)TeamId.Team1;

            serialPort1       = new ReliableSerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
            msgDecoder        = new MsgDecoder();
            msgEncoder        = new MsgEncoder();
            robotMsgGenerator = new MsgGenerator();
            robotMsgProcessor = new MsgProcessor(robotId, GameMode.RoboCup);

            robotPilot        = new RobotPilot.RobotPilot(robotId);
            strategyManager   = new StrategyRoboCup(robotId, teamId, "224.16.32.79");
            waypointGenerator = new WaypointGenerator(robotId, GameMode.RoboCup);
            trajectoryPlanner = new TrajectoryGeneratorHolonome(robotId, GameMode.RoboCup);
            kalmanPositioning = new KalmanPositioning.KalmanPositioning(robotId, 50, 0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.02);

            localWorldMapManager = new LocalWorldMapManager(robotId, teamId, bypassMulticast: false);
            perceptionManager    = new PerceptionManager(robotId, GameMode.RoboCup);
            imuProcessor         = new ImuProcessor.ImuProcessor(robotId);

            if (usingYolo)
            {
                yoloDetector = new YoloObjectDetector.YoloObjectDetector(false);            //Instancie un detecteur avec un Wrappeur Yolo utilisant le GPU
            }

            if (usingLidar)
            {
                lidar_OMD60M_TCP = new LidaRxR2000();
            }

            if (usingLidar || usingLogReplay)
            {
                lidarProcessor = new LidarProcessor.LidarProcessor(robotId, GameMode.RoboCup);
            }

            xBoxManette = new XBoxControllerNS.XBoxController(robotId);

            if (usingCamera || usingLogReplay)
            {
                imageProcessingPositionFromOmniCamera = new ImageProcessingPositionFromOmniCamera();
                absolutePositionEstimator             = new AbsolutePositionEstimator(robotId);
            }

            if (usingCamera)
            {
                omniCamera = new BaslerCameraAdapter();
                omniCamera.CameraInit();
                //omniCamera.BitmapPanoramaImageEvent += absolutePositionEstimator.AbsolutePositionEvaluation;
            }

            if (usingImageExtractor && usingCamera)
            {
                imgSaver = new ImageSaver.ImageSaver();
                omniCamera.BitmapPanoramaImageEvent += imgSaver.OnSaveBitmapImage;
            }



            //Démarrage des interface de visualisation
            if (usingRobotInterface)
            {
                StartRobotInterface();
            }
            if (usingCameraInterface)
            {
                StartCameraInterface();
            }

            //Démarrage du logger si besoin
            if (usingLogging)
            {
                logRecorder = new LogRecorder.LogRecorder();
            }

            //Démarrage du log replay si l'interface est utilisée et existe ou si elle n'est pas utilisée, sinon on bloque
            if (usingLogReplay)
            {
                logReplay = new LogReplay.LogReplay();
            }

            //Liens entre modules
            strategyManager.OnDestinationEvent     += waypointGenerator.OnDestinationReceived;
            strategyManager.OnHeatMapStrategyEvent += waypointGenerator.OnStrategyHeatMapReceived;
            waypointGenerator.OnWaypointEvent      += trajectoryPlanner.OnWaypointReceived;


            //Filtre de Kalman perceptionManager.OnAbsolutePositionEvent += kalmanPositioning.OnAbsolutePositionCalculatedEvent;
            robotMsgProcessor.OnPolarOdometrySpeedFromRobotEvent += kalmanPositioning.OnOdometryRobotSpeedReceived;
            imuProcessor.OnGyroSpeedEvent           += kalmanPositioning.OnGyroRobotSpeedReceived;
            kalmanPositioning.OnKalmanLocationEvent += trajectoryPlanner.OnPhysicalPositionReceived;
            kalmanPositioning.OnKalmanLocationEvent += perceptionManager.OnPhysicalRobotPositionReceived;
            //kalmanPositioning.OnKalmanLocationEvent += strategyManager.OnPositionRobotReceived;

            //L'envoi des commandes dépend du fait qu'on soit en mode manette ou pas.
            //Il faut donc enregistrer les évènement ou pas en fonction de l'activation
            //C'est fait plus bas dans le code avec la fonction que l'on appelle
            ConfigControlEvents(useXBoxController: true);

            //Gestion des messages envoyé par le robot
            robotMsgGenerator.OnMessageToRobotGeneratedEvent += msgEncoder.EncodeMessageToRobot;
            msgEncoder.OnMessageEncodedEvent += serialPort1.SendMessage;

            //Gestion des messages reçu par le robot
            serialPort1.OnDataReceivedEvent  += msgDecoder.DecodeMsgReceived;
            msgDecoder.OnMessageDecodedEvent += robotMsgProcessor.ProcessRobotDecodedMessage;
            robotMsgProcessor.OnIMURawDataFromRobotGeneratedEvent += imuProcessor.OnIMURawDataReceived;

            //physicalSimulator.OnPhysicalRobotLocationEvent += trajectoryPlanner.OnPhysicalPositionReceived;
            //physicalSimulator.OnPhysicicalObjectListLocationEvent += perceptionSimulator.OnPhysicalObjectListLocationReceived;
            //physicalSimulator.OnPhysicalRobotLocationEvent += perceptionSimulator.OnPhysicalRobotPositionReceived;
            //physicalSimulator.OnPhysicalBallPositionEvent += perceptionSimulator.OnPhysicalBallPositionReceived;

            perceptionManager.OnPerceptionEvent    += localWorldMapManager.OnPerceptionReceived;
            strategyManager.OnDestinationEvent     += localWorldMapManager.OnDestinationReceived;
            waypointGenerator.OnWaypointEvent      += localWorldMapManager.OnWaypointReceived;
            strategyManager.OnHeatMapStrategyEvent += localWorldMapManager.OnHeatMapStrategyReceived;

            //if (usingLidar)
            //{
            //    lidar_OMD60M_TCP.OnLidarDecodedFrameEvent += lidarProcessor.OnRawLidarDataReceived;
            //    //lidar_OMD60M.OnLidarDecodedFrameEvent += absolutePositionEstimator.OnRawLidarDataReceived;
            //    lidar_OMD60M_TCP.OnLidarDecodedFrameEvent += localWorldMapManager.OnRawLidarDataReceived;
            //    lidarProcessor.OnLidarObjectProcessedEvent += localWorldMapManager.OnLidarObjectsReceived;
            //}
            if (usingLidar)
            {
                lidar_OMD60M_TCP.OnLidarDecodedFrameEvent += perceptionManager.OnRawLidarDataReceived;
                //lidar_OMD60M_TCP.OnLidarDecodedFrameEvent += localWorldMapManager.OnLidarDataReceived;
                lidarProcessor.OnLidarProcessedEvent += localWorldMapManager.OnLidarDataReceived;
            }

            //Events de recording
            if (usingLogging)
            {
                //lidar_OMD60M_UDP.OnLidarDecodedFrameEvent += logRecorder.OnRawLidarDataReceived;
                lidar_OMD60M_TCP.OnLidarDecodedFrameEvent            += logRecorder.OnRawLidarDataReceived;
                omniCamera.BitmapFishEyeImageEvent                   += logRecorder.OnBitmapImageReceived;
                imuProcessor.OnIMUProcessedDataGeneratedEvent        += logRecorder.OnIMURawDataReceived;
                robotMsgProcessor.OnPolarOdometrySpeedFromRobotEvent += logRecorder.OnPolarSpeedDataReceived;
                //omniCamera.OpenCvMatImageEvent += logRecorder.OnOpenCVMatImageReceived;
            }

            if (usingLogReplay)
            {
                logReplay.OnLidarEvent += perceptionManager.OnRawLidarDataReceived;
                //logReplay.OnCameraImageEvent += imageProcessingPositionFromOmniCamera.ProcessOpenCvMatImage;
                //logReplay.OnCameraImageEvent += absolutePositionEstimator.AbsolutePositionEvaluation;
                //lidarProcessor.OnLidarObjectProcessedEvent += localWorldMapManager.OnLidarObjectsReceived;
            }

            lock (ExitLock)
            {
                // Do whatever setup code you need here
                // once we are done wait
                Monitor.Wait(ExitLock);
            }
        }