示例#1
0
        [STAThread] //à ajouter au projet initial

        static void Main(string[] args)
        {
            SciChartSurface.SetRuntimeLicenseKey(@"<LicenseContract>
  <Customer>University of  Toulon</Customer>
  <OrderId>EDUCATIONAL-USE-0109</OrderId>
  <LicenseCount>1</LicenseCount>
  <IsTrialLicense>false</IsTrialLicense>
  <SupportExpires>11/04/2019 00:00:00</SupportExpires>
  <ProductCode>SC-WPF-SDK-PRO-SITE</ProductCode>
  <KeyCode>lwABAQEAAABZVzOfQ0zVAQEAewBDdXN0b21lcj1Vbml2ZXJzaXR5IG9mICBUb3Vsb247T3JkZXJJZD1FRFVDQVRJT05BTC1VU0UtMDEwOTtTdWJzY3JpcHRpb25WYWxpZFRvPTA0LU5vdi0yMDE5O1Byb2R1Y3RDb2RlPVNDLVdQRi1TREstUFJPLVNJVEWDf0QgB8GnCQXI6yAqNM2njjnGbUt2KsujTDzeE+k69K1XYVF1s1x1Hb/i/E3GHaU=</KeyCode>
</LicenseContract>");

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

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

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

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

            ethernetTeamNetworkAdapter = new EthernetTeamNetworkAdapter();
            serialPort1       = new ReliableSerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
            msgDecoder        = new MsgDecoder();
            msgEncoder        = new MsgEncoder();
            robotMsgGenerator = new RobotMsgGenerator();
            robotMsgProcessor = new RobotMsgProcessor();

            physicalSimulator = new PhysicalSimulator.PhysicalSimulator();

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

            physicalSimulator.RegisterRobot(robotId, 0, 0);

            robotPilot           = new RobotPilot.RobotPilot(robotId);
            refBoxAdapter        = new RefereeBoxAdapter.RefereeBoxAdapter();
            trajectoryPlanner    = new TrajectoryPlanner(robotId);
            waypointGenerator    = new WaypointGenerator(robotId);
            strategyManager      = new StrategyManager.StrategyManager(robotId);
            localWorldMapManager = new LocalWorldMapManager(robotId, teamId);
            lidarSimulator       = new LidarSimulator.LidarSimulator(robotId);
            perceptionSimulator  = new PerceptionSimulator(robotId);

            if (usingLidar)
            {
                lidar_OMD60M   = new Lidar_OMD60M(robotId);
                lidarProcessor = new LidarProcessor.LidarProcessor(robotId);
            }

            xBoxManette = new XBoxController.XBoxController(robotId);

            if (!usingSimulatedCamera)
            {
                omniCamera = new BaslerCameraAdapter();
            }
            else
            {
                omniCameraSimulator = new SimulatedCamera.SimulatedCamera();
            }

            imageProcessingPositionFromOmniCamera = new ImageProcessingPositionFromOmniCamera();

            //Démarrage des interface de visualisation
            StartInterfaces();

            //Démarrage du logging
            if (usingLogging)
            {
                logRecorder = new LogRecorder.LogRecorder();
            }
            if (usingLogReplay)
            {
                logReplay      = new LogReplay.LogReplay();
                lidarProcessor = new LidarProcessor.LidarProcessor(robotId);
            }

            //Liens entre modules
            strategyManager.OnDestinationEvent += waypointGenerator.OnDestinationReceived;
            strategyManager.OnHeatMapEvent     += waypointGenerator.OnStrategyHeatMapReceived;
            waypointGenerator.OnWaypointEvent  += trajectoryPlanner.OnWaypointReceived;
            if (!usingXBoxController)
            {
                trajectoryPlanner.OnSpeedConsigneEvent += physicalSimulator.SetRobotSpeed;
                robotPilot.OnSpeedConsigneEvent        += robotMsgGenerator.GenerateMessageSetSpeedConsigneToRobot;
            }
            else
            {
                //Sur evenement xx              -->>        Action a effectuer
                xBoxManette.OnSpeedConsigneEvent += physicalSimulator.SetRobotSpeed;
                xBoxManette.OnSpeedConsigneEvent += robotMsgGenerator.GenerateMessageSetSpeedConsigneToRobot;
                xBoxManette.OnPriseBalleEvent    += robotMsgGenerator.GenerateMessageSetSpeedConsigneToMotor;
                xBoxManette.OnMoveTirUpEvent     += robotMsgGenerator.GenerateMessageMoveTirUp;
                xBoxManette.OnMoveTirDownEvent   += robotMsgGenerator.GenerateMessageMoveTirDown;
                xBoxManette.OnTirEvent           += robotMsgGenerator.GenerateMessageTir;
            }
            robotMsgGenerator.OnMessageToRobotGeneratedEvent += msgEncoder.EncodeMessageToRobot;
            msgEncoder.OnMessageEncodedEvent += serialPort1.SendMessage;
            serialPort1.OnDataReceivedEvent  += msgDecoder.DecodeMsgReceived;
            msgDecoder.OnMessageDecodedEvent += robotMsgProcessor.ProcessRobotDecodedMessage;

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

            perceptionSimulator.OnPerceptionEvent += localWorldMapManager.OnPerceptionReceived;
            //lidarSimulator.OnSimulatedLidarEvent += localWorldMapManager.OnRawLidarDataReceived;
            strategyManager.OnDestinationEvent += localWorldMapManager.OnDestinationReceived;
            waypointGenerator.OnWaypointEvent  += localWorldMapManager.OnWaypointReceived;
            strategyManager.OnHeatMapEvent     += localWorldMapManager.OnHeatMapReceived;
            //waypointGenerator.OnHeatMapEvent += localWorldMapManager.OnHeatMapReceived;

            if (usingLidar)
            {
                lidar_OMD60M.OnLidarEvent            += lidarProcessor.OnRawLidarDataReceived;
                lidarProcessor.OnLidarProcessedEvent += localWorldMapManager.OnRawLidarDataReceived;
            }

            //Event de recording
            if (usingLogging)
            {
                lidar_OMD60M.OnLidarEvent += logRecorder.OnRawLidarDataReceived;
            }

            //Event de replay
            if (usingLogReplay)
            {
                logReplay.OnLidarEvent += lidarProcessor.OnRawLidarDataReceived;
                lidarProcessor.OnLidarProcessedEvent       += localWorldMapManager.OnRawLidarDataReceived;
                lidarProcessor.OnLidarObjectProcessedEvent += localWorldMapManager.OnLidarObjectsReceived;
            }

            //Timer de stratégie
            timerStrategie       = new HighFreqTimer(0.5);
            timerStrategie.Tick += TimerStrategie_Tick;
            timerStrategie.Start();

            lock (ExitLock)
            {
                // Do whatever setup code you need here
                // once we are done wait
                Monitor.Wait(ExitLock);
            }
        }
示例#2
0
        [STAThread] //à ajouter au projet initial

        static void Main(string[] args)
        {
            SciChartSurface.SetRuntimeLicenseKey(@"<LicenseContract>
            <Customer>Universite De Toulon</Customer>
            <OrderId>EDUCATIONAL-USE-0128</OrderId>
            <LicenseCount>1</LicenseCount>
            <IsTrialLicense>false</IsTrialLicense>
            <SupportExpires>02/17/2020 00:00:00</SupportExpires>
            <ProductCode>SC-WPF-2D-PRO-SITE</ProductCode>
            <KeyCode>lwAAAQEAAACS9FAFUqnVAXkAQ3VzdG9tZXI9VW5pdmVyc2l0ZSBEZSBUb3Vsb247T3JkZXJJZD1FRFVDQVRJT05BTC1VU0UtMDEyODtTdWJzY3JpcHRpb25WYWxpZFRvPTE3LUZlYi0yMDIwO1Byb2R1Y3RDb2RlPVNDLVdQRi0yRC1QUk8tU0lURYcbnXYui4rna7TqbkEmUz1V7oD1EwrO3FhU179M9GNhkL/nkD/SUjwJ/46hJZ31CQ==</KeyCode>
            </LicenseContract>");


            //TODO : Créer un projet World...

            ethernetTeamNetworkAdapter = new EthernetTeamNetworkAdapter();
            serialPort1       = new ReliableSerialPort("FTDI", 230400 /*115200*/, Parity.None, 8, StopBits.One);
            msgDecoder        = new MsgDecoder();
            msgEncoder        = new MsgEncoder();
            robotMsgGenerator = new RobotMsgGenerator();
            robotMsgProcessor = new RobotMsgProcessor();

            physicalSimulator = new PhysicalSimulator.PhysicalSimulator();

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

            physicalSimulator.RegisterRobot(robotId, 0, 0);

            robotPilot           = new RobotPilot.RobotPilot(robotId);
            refBoxAdapter        = new RefereeBoxAdapter.RefereeBoxAdapter();
            trajectoryPlanner    = new TrajectoryPlanner(robotId);
            waypointGenerator    = new WaypointGenerator(robotId);
            strategyManager      = new StrategyManager.StrategyManager(robotId);
            localWorldMapManager = new LocalWorldMapManager(robotId, teamId);
            lidarSimulator       = new LidarSimulator.LidarSimulator(robotId);
            perceptionSimulator  = new PerceptionSimulator(robotId);

            if (usingLidar)
            {
                lidar_OMD60M = new Lidar_OMD60M(robotId);
            }

            xBoxManette = new XBoxController.XBoxController(robotId);

            if (!usingSimulatedCamera)
            {
                omniCamera = new BaslerCameraAdapter();
            }
            else
            {
                omniCameraSimulator = new SimulatedCamera.SimulatedCamera();
            }

            imageProcessingPositionFromOmniCamera = new ImageProcessingPositionFromOmniCamera();

            StartInterfaces();

            //Liens entre modules

            strategyManager.OnDestinationEvent += waypointGenerator.OnDestinationReceived;
            strategyManager.OnHeatMapEvent     += waypointGenerator.OnStrategyHeatMapReceived;
            waypointGenerator.OnWaypointEvent  += trajectoryPlanner.OnWaypointReceived;
            if (!usingXBoxController)
            {
                trajectoryPlanner.OnSpeedConsigneEvent += physicalSimulator.SetRobotSpeed;
                robotPilot.OnSpeedConsigneEvent        += robotMsgGenerator.GenerateMessageSetSpeedConsigneToRobot;
            }
            else
            {
                //Sur evenement xx              -->>        Action a effectuer
                xBoxManette.OnSpeedConsigneEvent += physicalSimulator.SetRobotSpeed;
                xBoxManette.OnSpeedConsigneEvent += robotMsgGenerator.GenerateMessageSetSpeedConsigneToRobot;
                xBoxManette.OnPriseBalleEvent    += robotMsgGenerator.GenerateMessageSetSpeedConsigneToMotor;
                xBoxManette.OnMoveTirUpEvent     += robotMsgGenerator.GenerateMessageMoveTirUp;
                xBoxManette.OnMoveTirDownEvent   += robotMsgGenerator.GenerateMessageMoveTirDown;
                xBoxManette.OnTirEvent           += robotMsgGenerator.GenerateMessageTir;
            }
            robotMsgGenerator.OnMessageToRobotGeneratedEvent += msgEncoder.EncodeMessageToRobot;
            msgEncoder.OnMessageEncodedEvent += serialPort1.SendMessage;
            serialPort1.OnDataReceivedEvent  += msgDecoder.DecodeMsgReceived;
            msgDecoder.OnMessageDecodedEvent += robotMsgProcessor.ProcessRobotDecodedMessage;

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

            perceptionSimulator.OnPerceptionEvent += localWorldMapManager.OnPerceptionReceived;
            //lidarSimulator.OnSimulatedLidarEvent += localWorldMapManager.OnRawLidarDataReceived;
            strategyManager.OnDestinationEvent += localWorldMapManager.OnDestinationReceived;
            waypointGenerator.OnWaypointEvent  += localWorldMapManager.OnWaypointReceived;
            strategyManager.OnHeatMapEvent     += localWorldMapManager.OnHeatMapReceived;
            //waypointGenerator.OnHeatMapEvent += localWorldMapManager.OnHeatMapReceived;

            if (usingLidar)
            {
                lidar_OMD60M.OnLidarEvent += localWorldMapManager.OnRawLidarDataReceived;
            }

            //Timer de stratégie
            timerStrategie       = new HighFreqTimer(0.5);
            timerStrategie.Tick += TimerStrategie_Tick;
            timerStrategie.Start();

            lock (ExitLock)
            {
                // Do whatever setup code you need here
                // once we are done wait
                Monitor.Wait(ExitLock);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            // Set this code once in App.xaml.cs or application startup
            SciChartSurface.SetRuntimeLicenseKey("RJWA77RbaJDdCRJpg4Iunl5Or6/FPX1xT+Gzu495Eaa0ZahxWi3jkNFDjUb/w70cHXyv7viRTjiNRrYqnqGA+Dc/yzIIzTJlf1s4DJvmQc8TCSrH7MBeQ2ON5lMs/vO0p6rBlkaG+wwnJk7cp4PbOKCfEQ4NsMb8cT9nckfdcWmaKdOQNhHsrw+y1oMR7rIH+rGes0jGGttRDhTOBxwUJK2rBA9Z9PDz2pGOkPjy9fwQ4YY2V4WPeeqM+6eYxnDZ068mnSCPbEnBxpwAldwXTyeWdXv8sn3Dikkwt3yqphQxvs0h6a8Dd6K/9UYni3o8pRkTed6SWodQwICcewfHTyGKQowz3afARj07et2h+becxowq3cRHL+76RyukbIXMfAqLYoT2UzDJNsZqcPPq/kxeXujuhT4SrNF3444MU1GaZZ205KYEMFlz7x/aEnjM6p3BuM6ZuO3Fjf0A0Ki/NBfS6n20E07CTGRtI6AsM2m59orPpI8+24GFlJ9xGTjoRA==");

            //On ajoute un gestionnaire d'évènement pour détecter la fermeture de l'application
            _handler += new EventHandler(Handler);
            SetConsoleCtrlHandler(_handler, true);

            //serialPort1 = new ReliableSerialPort(cfgSerialPort.CommName, cfgSerialPort.ComBaudrate, cfgSerialPort.Parity, cfgSerialPort.DataByte, cfgSerialPort.StopByte);
            //serialPort1 = new ReliableSerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
            int teamId  = (int)TeamId.Team1;
            int robotId = (int)RobotId.Robot1 + teamId;

            usbDriver         = new USBVendor.USBVendor();
            msgDecoder        = new MsgDecoder();
            msgEncoder        = new MsgEncoder();
            robotMsgGenerator = new MsgGenerator();
            robotMsgProcessor = new MsgProcessor(robotId, competition);

            imuProcessor = new ImuProcessor.ImuProcessor(robotId);
            if (usingLidar)
            {
                lidar_OMD60M_TCP = new LidaRxR2000(50, R2000SamplingRate._72kHz);
            }
            perceptionManager = new PerceptionManager(robotId, competition);
            kalmanPositioning = new KalmanPositioning.KalmanPositioning(robotId, 50, 0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.02);
            trajectoryPlanner = new TrajectoryPlanner(robotId, competition);

            localWorldMapManager  = new LocalWorldMapManager(robotId, teamId, bypassMulticast: false);
            globalWorldMapManager = new GlobalWorldMapManager(robotId);
            strategyManager       = new StrategyManagerNS.StrategyManager(robotId, teamId, "224.16.32.79", competition);

            robotUdpMulticastSender      = new UDPMulticastSender(robotId, "224.16.32.79");
            robotUdpMulticastReceiver    = new UDPMulticastReceiver(robotId, "224.16.32.79");
            robotUdpMulticastInterpreter = new UDPMulticastInterpreter(robotId);

            herkulexManager = new HerkulexManager();
            herkulexManager.AddServo(ServoId.BrasCentral, HerkulexDescription.JOG_MODE.positionControlJOG);
            herkulexManager.AddServo(ServoId.BrasDroit, HerkulexDescription.JOG_MODE.positionControlJOG);
            herkulexManager.AddServo(ServoId.BrasGauche, HerkulexDescription.JOG_MODE.positionControlJOG);
            herkulexManager.AddServo(ServoId.PorteDrapeau, HerkulexDescription.JOG_MODE.positionControlJOG);

            xBoxManette = new XBoxController.XBoxController(robotId);

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

            //if (usingLogReplay)
            //    StartReplayNavigatorInterface();

            //Initialisation du logger
            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
            logReplay = new LogReplay.LogReplay();

            //Liens entre modules
            //strategyManager.strategy.OnRefereeBoxCommandEvent += globalWorldMapManager.OnRefereeBoxCommandReceived;
            strategyManager.strategy.OnGameStateChangedEvent += trajectoryPlanner.OnGameStateChangeReceived;
            strategyManager.strategy.OnWaypointEvent         += trajectoryPlanner.OnWaypointReceived;

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

            //Update des données de la localWorldMap
            perceptionManager.OnPerceptionEvent             += localWorldMapManager.OnPerceptionReceived;
            strategyManager.strategy.OnDestinationEvent     += localWorldMapManager.OnDestinationReceived;
            strategyManager.strategy.OnRoleEvent            += localWorldMapManager.OnRoleReceived;           //Utile pour l'affichage
            strategyManager.strategy.OnMessageDisplayEvent  += localWorldMapManager.OnMessageDisplayReceived; //Utile pour l'affichage
            strategyManager.strategy.OnHeatMapStrategyEvent += localWorldMapManager.OnHeatMapStrategyReceived;
            strategyManager.strategy.OnWaypointEvent        += localWorldMapManager.OnWaypointReceived;
            strategyManager.strategy.OnHeatMapWayPointEvent += localWorldMapManager.OnHeatMapWaypointReceived;
            trajectoryPlanner.OnGhostLocationEvent          += localWorldMapManager.OnGhostLocationReceived;


            //Gestion des events liés à une détection de collision soft
            trajectoryPlanner.OnCollisionEvent += kalmanPositioning.OnCollisionReceived;
            //trajectoryPlanner.OnSpeedConsigneEvent += robotMsgGenerator.GenerateMessageSetSpeedConsigneToRobot;


            if (usingLidar)
            {
                strategyManager.strategy.OnMessageEvent += lidar_OMD60M_TCP.OnMessageReceivedEvent;
            }


            strategyManager.strategy.OnSetRobotSpeedPolarPIDEvent       += robotMsgGenerator.GenerateMessageSetupSpeedPolarPIDToRobot;
            strategyManager.strategy.OnSetRobotSpeedIndependantPIDEvent += robotMsgGenerator.GenerateMessageSetupSpeedIndependantPIDToRobot;
            strategyManager.strategy.OnSetAsservissementModeEvent       += robotMsgGenerator.GenerateMessageSetAsservissementMode;
            //  strategyEurobot.OnHerkulexPositionRequestEvent += herkulexManager.OnHerkulexPositionRequestEvent;
            strategyManager.strategy.OnSetSpeedConsigneToMotor            += robotMsgGenerator.GenerateMessageSetSpeedConsigneToMotor;
            strategyManager.strategy.OnEnableDisableMotorCurrentDataEvent += robotMsgGenerator.GenerateMessageEnableMotorCurrentData;
            herkulexManager.OnHerkulexSendToSerialEvent += robotMsgGenerator.GenerateMessageForwardHerkulex;


            if (usingLidar)
            {
                lidar_OMD60M_TCP.OnLidarDecodedFrameEvent   += perceptionManager.OnRawLidarDataReceived;
                perceptionManager.OnLidarRawDataEvent       += localWorldMapManager.OnRawLidarDataReceived;
                perceptionManager.OnLidarProcessedDataEvent += localWorldMapManager.OnProcessedLidarDataReceived;
            }

            //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(usingXBoxController);

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

            //Gestion des messages reçu par le robot
            //serialPort1.OnDataReceivedEvent += msgDecoder.DecodeMsgReceived;
            usbDriver.OnUSBDataReceivedEvent += msgDecoder.DecodeMsgReceived;
            msgDecoder.OnMessageDecodedEvent += robotMsgProcessor.ProcessRobotDecodedMessage;
            robotMsgProcessor.OnIMURawDataFromRobotGeneratedEvent += imuProcessor.OnIMURawDataReceived;
            robotMsgProcessor.OnIOValuesFromRobotGeneratedEvent   += strategyManager.strategy.OnIOValuesFromRobotEvent;
            robotMsgProcessor.OnIOValuesFromRobotGeneratedEvent   += perceptionManager.OnIOValuesFromRobotEvent;


            //  robotMsgProcessor.OnMotorsCurrentsFromRobotGeneratedEvent += strategyManager.OnMotorCurrentReceive;


            //Le local Manager n'est là que pour assurer le stockage de ma local world map avant affichage et transmission des infos, il ne doit pas calculer quoique ce soit,
            //c'est le perception manager qui le fait.
            trajectoryPlanner.OnPidSpeedResetEvent += robotMsgGenerator.GenerateMessageResetSpeedPid;

            ////Event d'interprétation d'une globalWorldMap à sa réception dans le robot
            robotUdpMulticastInterpreter.OnRefBoxMessageEvent  += strategyManager.strategy.OnRefBoxMsgReceived;
            robotUdpMulticastInterpreter.OnGlobalWorldMapEvent += strategyManager.strategy.OnGlobalWorldMapReceived;
            robotUdpMulticastInterpreter.OnLocalWorldMapEvent  += globalWorldMapManager.OnLocalWorldMapReceived;

            globalWorldMapManager.OnMulticastSendGlobalWorldMapEvent += robotUdpMulticastSender.OnMulticastMessageToSendReceived;

            ////Event de Transmission des Local World Map du robot vers le multicast
            localWorldMapManager.OnMulticastSendLocalWorldMapEvent += robotUdpMulticastSender.OnMulticastMessageToSendReceived;
            //Event de Réception de data Multicast sur le robot
            robotUdpMulticastReceiver.OnDataReceivedEvent += robotUdpMulticastInterpreter.OnMulticastDataReceived;

            /// LOGGER related events
            perceptionManager.OnLidarRawDataEvent += logRecorder.OnRawLidarDataReceived;
            robotMsgProcessor.OnIMURawDataFromRobotGeneratedEvent += logRecorder.OnIMURawDataReceived;
            robotMsgProcessor.OnSpeedPolarOdometryFromRobotEvent  += logRecorder.OnPolarSpeedDataReceived;

            //omniCamera.OpenCvMatImageEvent += logRecorder.OnOpenCVMatImageReceived;

            //strategyManagerDictionary.Add(robotId, strategyManager);
            trajectoryPlanner.InitRobotPosition(0, 0, 0);

            strategyManager.strategy.InitStrategy(robotId, teamId);
            while (!exitSystem)
            {
                Thread.Sleep(500);
            }
        }
示例#4
0
        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 StrategyManager(robotId, teamId, "224.16.32.79", GameMode.RoboCup);
            waypointGenerator = new WaypointGenerator(robotId, GameMode.RoboCup);
            trajectoryPlanner = new TrajectoryPlanner(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);
            //lidarSimulator = new LidarSimulator.LidarSimulator(robotId);
            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 XBoxController.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();
            }
            //if (usingLogReplay)
            //    StartReplayNavigatorInterface();

            //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.strategy.OnDestinationEvent     += waypointGenerator.OnDestinationReceived;
            strategyManager.strategy.OnHeatMapStrategyEvent += waypointGenerator.OnStrategyHeatMapReceived;
            waypointGenerator.OnWaypointEvent += trajectoryPlanner.OnWaypointReceived;


            //Filtre de Kalman perceptionManager.OnAbsolutePositionEvent += kalmanPositioning.OnAbsolutePositionCalculatedEvent;
            robotMsgProcessor.OnSpeedPolarOdometryFromRobotEvent += 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.strategy.OnDestinationEvent     += localWorldMapManager.OnDestinationReceived;
            waypointGenerator.OnWaypointEvent               += localWorldMapManager.OnWaypointReceived;
            strategyManager.strategy.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.OnRawLidarDataReceived;
                lidarProcessor.OnLidarProcessedEvent      += localWorldMapManager.OnProcessedLidarDataReceived;
            }

            //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.OnSpeedPolarOdometryFromRobotEvent += logRecorder.OnPolarSpeedDataReceived;
                //omniCamera.OpenCvMatImageEvent += logRecorder.OnOpenCVMatImageReceived;
            }

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

            //Timer de stratégie
            timerStrategie       = new HighFreqTimer(0.5);
            timerStrategie.Tick += TimerStrategie_Tick;
            timerStrategie.Start();

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