void Update_Sim() { if (simulation_Running)//Check if simulation is paused { Agx_Simulation.StepForward(); //Check if a button has been pressed //CheckInputs(); if (simulationTime >= 2) //Wait for robot to settle on terrain { if (!Dynamics.Control(robot, simulationTime)) //Movement { Debug.Log("wrong command"); } } robot.Update(); if (Visualization.enabled) { Update_Vis(); } simulationTime += Time.deltaTime; } //Else: //Start the canvas overlay to modify and create new modules }
void Update_Sim() { if (simulation_Running)//Check if simulation is paused { //Debug.Log(robot.modules[0].position.x+","+robot.modules[0].position.y+","+robot.modules[0].position.z); Agx_Simulation.StepForward(); //Check if a button has been pressed //CheckInputs(); if (simulationTime >= 2) //Wait for robot to settle on terrain { if (!Dynamics.Control(robot, simulationTime, dynamicVariables)) //Movement { Debug.Log("wrong command"); } } robot.Update(); //Update scene objects foreach (SceneObject so in sceneObjects) { so.Update(); } /* * //distancesensor * string distances = ""; * foreach (DistanceSensor ds in robot.sensorModules[0].distanceSensors) * { * ds.CalculateDistance(sceneObjects); * distances += ds.GetSensorDistance().ToString()+",";Debug.Log("working"); * } * * if(distances !="") * Debug.Log(distances); */ //Update visualization if (Visualization.enabled) { Update_Vis(robot); } //Debug.Log(robot.sensorModules[0].forceSensor.forceValue); simulationTime += Time.deltaTime; } //calculate distances foreach (SensorModule mod in robot.sensorModules) { foreach (DistanceSensor ds in mod.distanceSensors) { ds.CalculateDistance(sceneObjects); } } //IF Analytics checked, saveData.(if count = 10, count = 0 and saveData?) if (Analytics_Visualization.Enabled) { int result = Analytics_Visualization.SaveData(robot, Time.time); switch (result) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: Debug.Log("Read/Write error(folder not existing)"); break; case 7: Debug.Log("No Filename"); break; default: Debug.Log("Unspecified Error"); break; } } }