public LocalWorldMapManager(int robotId, int teamId, bool bypassMulticast)
 {
     localWorldMap = new LocalWorldMap();
     localWorldMap.Init();
     localWorldMap.RobotId = robotId;
     localWorldMap.TeamId  = teamId;
     bypassMulticastUdp    = bypassMulticast;
 }
コード例 #2
0
        static void Main(string[] args)
        {
            ConsoleFormat.InitMainConsole();


            /// Enregistrement de la license SciChart en début de code

            SciChartSurface.SetRuntimeLicenseKey(ConstVar.SCICHART_RUNTIME_KEY);
            ConsoleFormat.SetupScichartLicenceKey();

            /// Initialisation des modules utilisés dans le robot
            int robotId = (int)RobotId.Robot1;
            int teamId  = (int)TeamId.Team1;

            usbDriver    = new USBVendor();
            msgDecoder   = new MsgDecoder();
            msgEncoder   = new MsgEncoder();
            msgGenerator = new MsgGenerator();
            msgProcessor = new MsgProcessor(robotId, competition);
            ConsoleFormat.SetupAllCommunication();

            xBoxManette = new XBoxController(robotId);
            ConsoleFormat.SetupXboxController();

            logRecorder = new LogRecorder();
            logReplay   = new LogReplay();

            strategyManager = new StrategyEurobot(robotId, teamId, "224.16.32.79");

            #region Communication to Low Lvl
            /// Création des liens entre module, sauf depuis et vers l'interface graphique
            usbDriver.OnUSBuffReceivedEvent             += msgDecoder.BuffReceived;                        // Transmission des messages reçus par l'USB au Message Decoder
            msgDecoder.OnCorrectMessageReceivedEvent    += msgProcessor.ProcessRobotDecodedMessage;        // Transmission les messages décodés par le Message Decoder au Message Processor
            msgGenerator.OnMessageToRobotGeneratedEvent += msgEncoder.EncodeAndSendMessage;                // Envoi des messages du générateur de message à l'encoder
            msgEncoder.OnSendMessageEvent += usbDriver.SendUSBMessage;                                     // Envoi des messages en USB depuis le message encoder
            #endregion

            #region Console
            // Control:
            bool hex_viewer       = false;
            bool hex_sender       = false;
            bool hex_viewer_error = true;
            bool hex_sender_error = true;
            bool hex_processor    = false;
            bool hex_generator    = false;
            #region USB Vendor
            usbDriver.OnDeviceAddedEvent       += ConsoleFormat.PrintNewDeviceAdded;
            usbDriver.OnDeviceRemovedEvent     += ConsoleFormat.PrintDeviceRemoved;
            usbDriver.OnUsbVendorExeptionEvent += ConsoleFormat.PrintUsbErrorExeption;
            #endregion

            #region Hex Viewer
            if (hex_viewer)
            {
                msgDecoder.OnUnknowByteEvent                   += ConsoleFormat.PrintUnknowByte;
                msgDecoder.OnSOFByteReceivedEvent              += ConsoleFormat.PrintSOF;
                msgDecoder.OnFunctionMSBByteReceivedEvent      += ConsoleFormat.PrintFunctionMSB;
                msgDecoder.OnFunctionLSBByteReceivedEvent      += ConsoleFormat.PrintFunctionLSB;
                msgDecoder.OnPayloadLenghtMSBByteReceivedEvent += ConsoleFormat.PrintLenghtMSB;
                msgDecoder.OnPayloadLenghtLSBByteReceivedEvent += ConsoleFormat.PrintLenghtLSB;
                msgDecoder.OnPayloadByteReceivedEvent          += ConsoleFormat.PrintPayloadByte;
                msgDecoder.OnCorrectMessageReceivedEvent       += ConsoleFormat.PrintCorrectChecksum;
                msgDecoder.OnErrorMessageReceivedEvent         += ConsoleFormat.PrintWrongChecksum;
            }
            #endregion

            #region Hex Viewer Error
            if (hex_viewer_error)
            {
                msgDecoder.OnOverLenghtMessageEvent   += ConsoleFormat.PrintOverLenghtWarning;
                msgDecoder.OnUnknowFunctionEvent      += ConsoleFormat.PrintUnknowFunctionReceived;
                msgDecoder.OnWrongLenghtFunctionEvent += ConsoleFormat.PrintWrongFonctionLenghtReceived;
            }
            #endregion

            #region Hex Sender
            if (hex_sender)
            {
                msgEncoder.OnSendMessageByteEvent += ConsoleFormat.PrintSendMsg;
            }

            #endregion

            #region Hex Sender Error
            if (hex_sender_error)
            {
                msgEncoder.OnSerialDisconnectedEvent  += ConsoleFormat.PrintOnSerialDisconnectedError;
                msgEncoder.OnUnknownFunctionSentEvent += ConsoleFormat.PrintUnknowFunctionSent;
                msgEncoder.OnWrongPayloadSentEvent    += ConsoleFormat.PrintWrongFunctionLenghtSent;
            }
            #endregion
            #endregion



            #region Lidar
            lidar        = new SickLidar(17422959); // 18110177
            lidarProcess = new LidarProcess(robotId, teamId);

            lidar.OnLidarDeviceConnectedEvent += lidarProcess.OnNewLidarConnected;
            lidar.OnLidarDeviceConnectedEvent += ConsoleFormat.NewLidarDeviceConnected;
            lidar.PointsAvailable             += lidarProcess.OnRawPointAvailable;

            lidar.Start();
            #endregion

            lidarProcess.OnRawLidarDataEvent += logRecorder.OnRawLidarDataReceived;
            msgProcessor.OnSpeedPolarOdometryFromRobotEvent += logRecorder.OnPolarSpeedDataReceived;

            #region Local World Map
            localWorldMap = new LocalWorldMap(robotId, teamId);
            localWorldMap.OnUpdateRobotLocationEvent += lidarProcess.OnRobotLocation;


            lidarProcess.OnRawLidarPointPolarEvent      += localWorldMap.OnLidarRawPointReceived;
            lidarProcess.OnProcessLidarPolarDataEvent   += localWorldMap.OnLidarProcessedPointReceived;
            lidarProcess.OnProcessLidarLineDataEvent    += localWorldMap.OnLidarProcessedLineReceived;
            lidarProcess.OnProcessLidarCupDataEvent     += localWorldMap.OnLidarProcessedCupReceived;
            lidarProcess.OnLidarSetupRobotLocationEvent += localWorldMap.OnRobotLocation;

            //lidarProcess.OnProcessLidarObjectsDataEvent += localWorldMap.OnLidarProcesObjectsReceived;

            localWorldMap.OnLocalWorldMapEvent += strategyManager.OnLocalWorldMapReceived;

            localWorldMap.Init();
            #endregion

            #region Position2Wheels
            positioning2Wheels = new Positioning2Wheels(robotId);

            msgProcessor.OnSpeedPolarOdometryFromRobotEvent += positioning2Wheels.OnOdometryRobotSpeedReceived;
            positioning2Wheels.OnCalculatedLocationEvent    += localWorldMap.OnRobotLocationArgs;
            #endregion

            #region TrajectoryPlanner
            trajectoryPlanner = new TrajectoryPlanner(robotId);

            trajectoryPlanner.OnNewGhostLocationEvent   += localWorldMap.OnGhostLocation;
            trajectoryPlanner.OnNewRobotLocationEvent   += localWorldMap.OnRobotLocation;
            trajectoryPlanner.OnDestinationReachedEvent += strategyManager.OnGhostLocationReached;

            #endregion

            #region Strategy /!\Need to be Last /! \
            strategyManager.On2WheelsToPolarMatrixSetupEvent += msgGenerator.GenerateMessage2WheelsToPolarMatrixSet;   //Transmission des messages de set-up de la matrice de transformation moteurindepeandt -> polaire en embarqué
            strategyManager.On2WheelsAngleSetupEvent         += msgGenerator.GenerateMessage2WheelsAngleSet;           //Transmission des messages de set-up de la config angulaire des roues en embarqué
            strategyManager.OnOdometryPointToMeterSetupEvent += msgGenerator.GenerateMessageOdometryPointToMeter;      //Transmission des messages de set-up du coeff pointToMeter en embarqué
            strategyManager.OnSetAsservissementModeEvent     += msgGenerator.GenerateMessageSetAsservissementMode;

            strategyManager.OnDestinationReachedEvent += localWorldMap.OnDestinationReached;
            strategyManager.OnWaypointsReachedEvent   += localWorldMap.OnWaypointReached;

            strategyManager.OnSetActualLocationEvent     += trajectoryPlanner.OnUpdateActualLocation;
            strategyManager.OnSetWantedLocationEvent     += trajectoryPlanner.OnUpdateWantedDestination;
            strategyManager.OnGhostCalculationBeginEvent += trajectoryPlanner.OnLaunchCalculation;

            strategyManager.OnSetNewWaypointEvent    += localWorldMap.AddNewWaypointsEvent;
            strategyManager.OnSetNewDestinationEvent += localWorldMap.SetDestinationLocationEvent;

            strategyManager.OnUpdateGhostCalculationOrderEvent += trajectoryPlanner.OnCalculateGhostMovement;

            ConsoleFormat.PrintStrategyBoot();
            strategyManager.InitStrategy(); //à faire après avoir abonné les events !
            #endregion

            if (usingMatchDisplay)
            {
                StartMatchInterface();
            }
            else
            {
                StartRobotInterface();
            }

            ConsoleFormat.EndMainBootSequence();

            while (!exitSystem)
            {
                Thread.Sleep(500);
            }
        }