private void Button_CornerT1_Click(object sender, RoutedEventArgs e) { RefBoxMessage msg = new RefBoxMessage(); msg.command = RefBoxCommand.CORNER; msg.targetTeam = TeamIpAddress; msg.robotID = 0; OnRefereeBoxReceivedCommand(msg); }
private void Button_PlayRightT2_Click(object sender, RoutedEventArgs e) { RefBoxMessage msg = new RefBoxMessage(); msg.command = RefBoxCommand.PLAYRIGHT; msg.targetTeam = TeamIpAddress; msg.robotID = 0; OnRefereeBoxReceivedCommand(msg); }
private void Button_KickOffT2_Click(object sender, RoutedEventArgs e) { RefBoxMessage msg = new RefBoxMessage(); msg.command = RefBoxCommand.KICKOFF; msg.targetTeam = OpponentTeamIpAddress; msg.robotID = 0; OnRefereeBoxReceivedCommand(msg); }
public virtual void OnRefBoxMessage(RefBoxMessage refBoxMessage) { var handler = OnRefBoxMessageEvent; if (handler != null) { handler(this, new RefBoxMessageArgs { refBoxMsg = refBoxMessage }); } }
private void LocalWorldMapDisplay2_OnCtrlClickOnHeatMapEvent(object sender, PositionArgs e) { RefBoxMessage msg = new RefBoxMessage(); msg.command = RefBoxCommand.GOTO; msg.targetTeam = TeamIpAddress; msg.robotID = (int)TeamId.Team1 + (int)RobotId.Robot2; msg.posX = e.X; msg.posY = e.Y; msg.posTheta = 0; OnRefereeBoxReceivedCommand(msg); }
private void Button_m1_0_Click(object sender, RoutedEventArgs e) { RefBoxMessage msg = new RefBoxMessage(); msg.command = RefBoxCommand.GOTO; msg.targetTeam = TeamIpAddress; msg.robotID = 10; msg.posX = -1; msg.posY = 0; msg.posTheta = Math.PI; OnRefereeBoxReceivedCommand(msg); }
private void OnRefereeBoxReceivedCommand(RefBoxMessage rbMsg) { var msg = ZeroFormatterSerializer.Serialize <ZeroFormatterMsg>(rbMsg); OnMulticastSendRefBoxCommand(msg); }
public void OnMulticastDataReceived(object sender, EventArgsLibrary.DataReceivedArgs e) { lock (e.Data) { var deserialization = ZeroFormatterSerializer.Deserialize <ZeroFormatterMsg>(e.Data); switch (deserialization.Type) { case ZeroFormatterMsgType.LocalWM: LocalWorldMap lwm = (LocalWorldMap)deserialization; //if (Id == lwm.RobotId) { OnLocalWorldMap(lwm); //UdpMonitor.LWMReceived(e.Data.Length); } break; case ZeroFormatterMsgType.GlobalWM: GlobalWorldMap gwm = (GlobalWorldMap)deserialization; //UdpMonitor.GWMReceived(e.Data.Length); OnGlobalWorldMap(gwm); break; case ZeroFormatterMsgType.RefBoxMsg: RefBoxMessage refBoxMsg = (RefBoxMessage)deserialization; OnRefBoxMessage(refBoxMsg); break; default: break; } //var compressedData = e.Data; //Console.WriteLine(string.Format("Received bytes: {0}", compressedData.Length)); //string uncompressedTextData = "";// Zip.UnzipText(compressedData); // //Console.WriteLine(string.Format("Decompressed bytes: {0}", uncompressedTextData.Length)); //JObject obj = JObject.Parse(Encoding.Default.GetString(e.Data)); //try //{ // switch ((int)obj["Type"]) // { // case (int)WorldMapType.LocalWM: // LocalWorldMap lwm = obj.ToObject<LocalWorldMap>(); // OnLocalWorldMap(lwm); // break; // case (int)WorldMapType.GlobalWM: // GlobalWorldMap gwm = obj.ToObject<GlobalWorldMap>(); // OnGlobalWorldMap(gwm); // break; // default: // break; // } //} //catch //{ // Console.WriteLine("Exception Message non décodable en json : UdpMulticastInterpreter"); //} } }
public virtual void OnRefereeBoxReceivedCommand(RefBoxMessage msg) { OnRefereeBoxCommandEvent?.Invoke(this, new RefBoxMessageArgs { refBoxMsg = msg }); }
void TaskThreadProcess() { while (true) { if (timeStamp.ElapsedMilliseconds < 99999) { switch (state) { case TaskStrategyState.Attente: break; case TaskStrategyState.InitialPositioning: //Le positionnement initial est manuel de manière à pouvoir coller deux robots très proches sans mouvement parasite parentStrategyManager.OnEnableMotors(false); //Le jack force le retour à cet état //parentStrategyManager.taskDistributeur.Init(); RefBoxMessage message = new RefBoxMessage(); message.command = RefBoxCommand.STOP; message.targetTeam = "224.16.32.79"; message.robotID = 0; parentStrategyManager.OnRefereeBoxReceivedCommand(message); indexPrise = 0; state = TaskStrategyState.InitialPositioningEnCours; break; case TaskStrategyState.InitialPositioningEnCours: if (!Jack) { parentStrategyManager.taskBrasDroit.Init(); parentStrategyManager.taskBrasGauche.Init(); parentStrategyManager.taskBrasCentre.Init(); parentStrategyManager.taskBrasDrapeau.Init(); parentStrategyManager.taskPhare.Init(); parentStrategyManager.taskWindFlag.Init(); parentStrategyManager.taskBalade.Init(); parentStrategyManager.taskDepose.Init(); parentStrategyManager.taskFinDeMatch.Init(); parentStrategyManager.OnEnableMotors(true); message = new RefBoxMessage(); message.command = RefBoxCommand.START; message.targetTeam = "224.16.32.79"; message.robotID = 0; parentStrategyManager.OnRefereeBoxReceivedCommand(message); parentStrategyManager.OnCollision(parentStrategyManager.robotId, parentStrategyManager.robotCurentLocation); //On génère artificellement une collision pour resetter Kalman et le reste autour de la position courante. state = TaskStrategyState.Phare; if (isFirstRun) { isFirstRun = false; StartSw(); } } break; case TaskStrategyState.PushFlags: parentStrategyManager.taskWindFlag.Start(); state = TaskStrategyState.PushFlagsEnCours; break; case TaskStrategyState.PushFlagsEnCours: if (parentStrategyManager.taskWindFlag.isFinished) { state = TaskStrategyState.Distributeurs; } break; case TaskStrategyState.Phare: parentStrategyManager.taskPhare.Start(); state = TaskStrategyState.PhareEnCours; break; case TaskStrategyState.PhareEnCours: if (parentStrategyManager.taskPhare.isFinished) { state = TaskStrategyState.PushFlags; } break; case TaskStrategyState.Distributeurs: if (parentStrategyManager.Team == Equipe.Jaune) { if (indexPrise < locsPoseJaune.Count && indexPrise < locsPriseJaune.Count) { parentStrategyManager.taskDistributeur.Start(locsPriseJaune[indexPrise], locsPoseJaune[indexPrise]); indexPrise++; state = TaskStrategyState.DistributeursEnCours; } else { state = TaskStrategyState.Attente; } } else if (parentStrategyManager.Team == Equipe.Bleue) { if (indexPrise < locsPoseBleue.Count && indexPrise < locsPriseBleue.Count) { parentStrategyManager.taskDistributeur.Start(locsPriseBleue[indexPrise], locsPoseBleue[indexPrise]); indexPrise++; state = TaskStrategyState.DistributeursEnCours; } else { state = TaskStrategyState.InitialPositioningEnCours; } } break; case TaskStrategyState.DistributeursEnCours: if (parentStrategyManager.taskDistributeur.isFinished) { state = TaskStrategyState.Distributeurs; } break; default: state = TaskStrategyState.Phare; break; } } else { Init(); if (!isStoped) { parentStrategyManager.taskFinDeMatch.Start(); timeStamp.Stop(); } isStoped = true; } Thread.Sleep(1); } }