// Update is called once per frame void FixedUpdate() { /*if (path.Count > 0) * { * Vector3 position = path.Pop(); * if (this.transform.position != position) * { * Debug.Log("Position = " + position); * controller.GoToPoint(position); * } * }*/ controller.GoToPoint(new Vector3(50, 5, 50)); List <byte[]> messageToSend = new List <byte[]>(); byte[] message; foreach (Message m in targets) { message = DataToByte(m.position, m.tag); messageToSend.Add(message); } List <GameObject> robots = wifi.getRobotAround(); foreach (GameObject g in robots) { Debug.Log("I am " + this.tag + " rover, I detect " + g.tag + " rover"); foreach (byte[] m in messageToSend) { wifi.Send(g, m); Debug.Log("I will send him a target pos " + ByteToData(m).position); } } byte[] messageReceived; if (wifi.isWaiting()) { messageReceived = wifi.getMessage(); Message m = ByteToData(messageReceived); if (m.tag == this.tag) { Debug.Log("I am " + this.tag + ", Another robot send me this message " + m.position); } } }
// Update is called once per frame void FixedUpdate() { /*if (targetList != null) { target = FindTarget(targetList); Vector3 targetPos = GetPosition(target); Debug.Log("I am " + this.tag + " rover, I detect this target " + targetPos); if (obstaclesList != null) { Vector2[] obst = GetObstacleVect(obstaclesList); robotPosX = this.transform.position.x; robotPosY = this.transform.position.z; targetPosX = targetPos.x; targetPosY = targetPos.z; Vector2 p = potentialField(robotPosX, robotPosY, targetPosX, targetPosY, obst); GoTo(p); } else { GoTo(GetPosition(target)); } } else { controller.ChangeMotorSpeed(1.0f, -1.0f); } data = lidarRotative.GetData(); /*targetList.Union(FindTargets(data)); obstaclesList.Union(FindObstacles(data));*/ Vector3 pos; List<byte[]> messageToSend = new List<byte[]>(); byte[] message; foreach (Triple t in objectList) { pos = GetPosition(t); message = DataToByte(pos, t.Tag); messageToSend.Add(message); } List<GameObject> robots = wifi.getRobotAround(); foreach(GameObject g in robots) { Debug.Log("I am " + this.tag + " rover, I detect " + g.tag + " rover"); foreach(byte[] m in messageToSend) { wifi.Send(g, m); Debug.Log("I will send him a target pos " + ByteToData(m).position); } } byte[] messageReceived; if (wifi.isWaiting()) { messageReceived = wifi.getMessage(); Message m = ByteToData(messageReceived); if (m.tag == this.tag) { Debug.Log("I am " + this.tag + " rover, Another robot send me this message " + m); targetPosList.Add(m.position); } } objectList = FindObjects(data); }