Exemplo n.º 1
0
    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
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update_Sim()
 {
     //Update physics:
     Agx_Simulation.StepForward();
     //Update the robot:
     robot.Update();
     //Update the visualization:
     {
         //Frames:
         FrameDemoVis[0].transform.position = AgxHelper(robot.modules[0].frames[0].position);
         FrameDemoVis[0].transform.rotation = (AgxHelper(robot.modules[0].frames[0].quatRotation));
         FrameDemoVis[1].transform.position = AgxHelper(robot.modules[0].frames[1].position);
         FrameDemoVis[1].transform.rotation = (AgxHelper(robot.modules[0].frames[1].quatRotation));
         //Scene object:
         sceneobjvis.transform.position = AgxHelper(sceneobj.position);
     }
     robot.modules[0].joint.SetAngle(2);
 }
Exemplo n.º 3
0
    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;
            }
        }
    }