//returns the sensor data and update it on the screen int[,] getSensorData() { int matrixSize = (currentSensor == 1 || currentSensor == 5)? 3:5; sensor.Update_Obstacles(robotMain, getMazeData(matrixSize), robotDirection); int[,] sensorReading = sensor.Get_Obstacle_Matrix(); if (currentSensor == 3) { sensorReading = Exploration.RotateSensorData(sensorReading, robotDirection); } updateUISensorData(sensorReading); return(sensorReading); }
void getNextCommand() { mazeCoverageStr = exploration.GetCoverage().ToString(); pointsScoredStr = exploration.GetPoints().ToString(); mazeCoverage = Int32.Parse(mazeCoverageStr); pointsScored = Int32.Parse(pointsScoredStr); if (checkRunTimeStatus()) { int matrixSize = (currentSensor == 1 || currentSensor == 5)? 3:5; sensor.Update_Obstacles(robotMain, getMazeData(matrixSize), robotDirection); int[,] sensorReading = sensor.Get_Obstacle_Matrix(); updateUISensorData(sensorReading); String robotCommand = exploration.GetNextCommand(sensorReading, currentSensor); moveInDirection(robotCommand); } else { CancelInvoke("getNextCommand"); isSimulationComplete = true; endTime = DateTime.Now.ToString(@"hh\:mm\:ss"); runTime = calculateRunTime(); backButton.interactable = true; Debug.Log("END TIME : " + runTime); Debug.Log("Battery Life : " + batteryLife); Debug.Log("Points : " + pointsScored); sendDateToExpDesign(); Debug.Log("Maze Coverage : " + mazeCoverage); } }
void getNextCommand() { healthBar.value = batteryLife; mazeCoverageStr = exploration.GetCoverage().ToString(); pointsScoredStr = exploration.GetPoints().ToString(); mazeCoverage = Int32.Parse(mazeCoverageStr); pointsScored = Int32.Parse(pointsScoredStr); if (checkRunTimeStatus()) { int matrixSize = (currentSensor == 1 || currentSensor == 5)? 3:5; Debug.Log(robotMain); sensor.Update_Obstacles(sensor.GetRoverObject(), getMazeData(matrixSize), robotDirection); //updateUISensorData(getMazeData(matrixSize)); int[,] sensorReading = sensor.Get_Obstacle_Matrix(); updateUISensorData(sensorReading); String robotCommand = exploration.GetNextCommand(sensorReading, currentSensor); moveInDirection(robotCommand); } else { CancelInvoke("getNextCommand"); isSimulationComplete = true; endTime = DateTime.Now.ToString(@"hh\:mm\:ss"); runTime = calculateRunTime(); //enable back button backButton.interactable = true; // calculate end time Debug.Log("END TIME : " + runTime); // store the info in DB Debug.Log("Battery Life : " + batteryLife); Debug.Log("Points : " + pointsScored); sendDateToExpDesign(); Debug.Log("Maze Coverage : " + mazeCoverage); mazeCreated = false; currentX = 1; currentY = 1; mazeCoverage = 0; batteryLife = 3600; pointsScored = 0; GameObject[] mazeObjects = arrayOfGameObjects[arrayCounter]; //Destroy UI for (int i = 0; i < mazeObjects.Length; i++) { Destroy(mazeObjects[i]); } arrayCounter++; if (expCounter < PlayerPrefs.GetInt("Iteration")) { Begin(); } else { experimentText.text = ""; statusText.text = "Trails are completed."; } } }
// Update is called once per frame void Update() { // changePosRover(); sensor.Update_Obstacles(Cube); // sensor.SetSensorType(1); // int[,] matrix = sensor.Get_Obstacle_Matrix(); // testProximityMatrix(matrix); //Debug.Log("Getting matrix of Size:"+matrix.Length); }
// Update is called once per frame void Update() { // changePosRover(); if (!algorithmsSimulation.getIsSimulationComplete()) { sensor.Update_Obstacles(Cube); } // sensor.SetSensorType(1); // int[,] matrix = sensor.Get_Obstacle_Matrix(); // testProximityMatrix(matrix); //Debug.Log("Getting matrix of Size:"+matrix.Length); }