Exemple #1
0
    UnityEngine.Vector3 AgxHelper(AgX_Interface.Vector3 vec)
    {
        var vector = new UnityEngine.Vector3();

        vector.x = (float)vec.x;
        vector.y = (float)vec.y;
        vector.z = (float)vec.z;

        return(vector);
    }
Exemple #2
0
 public void ChangeInitPos(AgX_Interface.Vector3 pos)
 {
     if (!simulation_Running)
     {
         AgX_Assembly.SetPosition(pos);
         robot.Update();
         Update_Vis(robot);
         RobotStartPosition = pos;
     }
 }
Exemple #3
0
    AgX_Interface.Vector3[] AgxHelper(UnityEngine.Vector3[] vec)//THESE?? wrong?
    {
        var vectors = new AgX_Interface.Vector3[vec.Length];

        for (int i = 0; i < vec.Length; i++)
        {
            vectors[i].x = vec[i].x;
            vectors[i].y = vec[i].y;
            vectors[i].z = vec[i].z;
        }
        return(vectors);
    }
Exemple #4
0
 public void SetOptimizationTarget(AgX_Interface.Vector3 pos)
 {
     Robot_Optimization.targetPosition = pos;
 }
Exemple #5
0
 public void SetAxisWeighting(AgX_Interface.Vector3 axis)
 {
     Robot_Optimization.AxisWeight = axis;
 }
Exemple #6
0
    void Start()
    {
        //Start simulation:
        Agx_Simulation.Start(0.01);

        //Setting position and rotations:
        var pos    = new AgX_Interface.Vector3(0, 0, 0);
        var u_quat = UnityEngine.Quaternion.Euler(0, 90, 0);

        AgX_Interface.Quaternion frame_rot = new AgX_Interface.Quaternion(u_quat.x, u_quat.y, u_quat.z, u_quat.w);

        //Create Frames:
        Frame[] frames = new Frame[2];
        for (int i = 0; i < 2; i++)
        {
            frames[i] = new Frame()
            {
                guid         = Guid.NewGuid(),
                position     = pos,
                scale        = 10,
                quatRotation = frame_rot,
                //rotation = rot,
                mass         = 10,
                isStatic     = false,
                materialName = "Plastic"
            };
        }

        //download mesh obj file:
        loadmesh();

        //Set mesh of frames:
        frames[0].SetMesh(AgxHelper(leftmesh.vertices), AgxHelper(leftmesh.uv), leftmesh.triangles);
        frames[1].SetMesh(AgxHelper(rightmesh.vertices), AgxHelper(rightmesh.uv), rightmesh.triangles);

        //Create Joint:
        Simulation_Core.Joint joint = new Simulation_Core.Joint()
        {
            guid            = Guid.NewGuid(),
            leftFrameGuid   = frames[0].guid,
            rightFrameGuid  = frames[1].guid,
            type            = "Hinge",
            lowerRangeLimit = -Math.PI / 2,
            upperRangeLimit = Math.PI / 2,
            max_vel         = Math.PI / 6,
            Kp = 3
        };

        //Create Module:
        var module = new Module();

        module.Create(frames[0], joint, frames[1]);

        //Add module to robot:
        robot.Add_Module(module);

        //Add second module to robot:
        //robot.Add_Module(module2,new Simulation_Core.Joint());

        //Initialize robot:
        robot.Initialize();

        //Scene object:
        sceneobj = new SceneObject()
        {
            guid         = Guid.NewGuid(),
            shape        = "Box",
            size         = new AgX_Interface.Vector3(5, 1, 10),
            position     = new AgX_Interface.Vector3(0, -2, 0),
            quatRotation = new AgX_Interface.Quaternion(0, 0, 0, 1),
            materialName = "Rock",
            mass         = 10,
            isStatic     = true
        };
        sceneobj.Initialize();

        //Load vis from mesh and robot + scene object:
        Load_Vis();

        //Start sim update loop:
        InvokeRepeating("Update_Sim", 0.01f, 0.01f);
    }