예제 #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);
            }
        }