private void UpdateRoboticArm(RoboticArm ra)
 {
     if (PropertyChanged != null)
     {
         PropertyChanged(this, new PropertyChangedEventArgs("RoboticArm"));
     }
 }
Beispiel #2
0
    int iter;              // Which iteration of training are we on

    // Use this for initialization
    void Awake()
    {
        DontDestroyOnLoad(this);          // Dont delete when resetting the scene
        if (FindObjectsOfType(GetType()).Length > 1)
        {
            Destroy(gameObject);
        }
        server = GameObject.FindObjectOfType <TCPServer>();
        arm    = GameObject.FindObjectOfType <RoboticArm>();

        iter = 1;
    }
        private void MakeRoboticArm()
        {
            RoboticArm arm = DataContext as RoboticArm;

            arm.Clear();

            var parameters = GetMDHParameters();

            foreach (var parameter in parameters)
            {
                arm.AddLink(new Link(parameter));
            }

            var tipPose = RoboticMath.GetPositionVector(RoboticMath.GetTransformMatrix(arm.GetParameters()));

            tipPosition.Text = String.Format("{0:0.00}; {1:0.00}; {2:0.00};", tipPose[0], tipPose[1], tipPose[2]);
        }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        if (arm == null)
        {
            arm = GameObject.FindObjectOfType <RoboticArm> ();
            if (arm == null)
            {
                print("ARM STILL NULL");
                return;
            }
        }

        print("Iteration " + iter + ", tick " + arm.tick);

        if (arm.next_iter == true)
        {
            iter++;
            print("RESETTING SCENE FOR NEXT ITERATION...");
            SceneManager.LoadScene("RobotBoxScene");
            server = GameObject.FindObjectOfType <TCPServer>();
            arm    = GameObject.FindObjectOfType <RoboticArm>();
        }
    }
    // Update is called once per frame
    void Update()
    {
        // if user paused the iteration
        if (!Pause)
        {
            // Unfreeze arms
            if (!playAnimation)
            {
                population[0].StopTween();
                foreach (RoboticArm arm in population)
                {
                    arm.freeze = false;
                    arm.gameObject.SetActive(true);
                }
                playAnimation = true;
            }

            // update the scene with the defined intervals
            if (!updateScene)
            {
                return;
            }

            updateScene = false;

            // TODO: stop optimization when reached at the target!
            if (generationCounter < numOfGenerations)
            {
                //Debug.Log("Generation: " + generationCounter);
                NewGeneration();
                generationCounter++;
            }
            else // This is to update only if we want to show the final result of the optimization!
            {
                //foreach (RoboticArm p in population)
                //{
                //    p.freeze = false;
                //}
            }
            //Current Gen and Fittest Text
            UIcurrentGeneration.text = "Current Generation: " + generationCounter;
        }
        else
        {
            if (playAnimation)
            {
                playAnimation = false;
                foreach (RoboticArm arm in population)
                {
                    arm.freeze = true;
                    arm.gameObject.SetActive(false);
                }
                population = population.OrderBy(o => o.fitness).ToList();
                population.Reverse();
                RoboticArm currentFittest = population[0];
                Vector3[]  jointAngles    = new Vector3[currentFittest.Joints.Length];
                for (int i = 0; i < jointAngles.Length; i++)
                {
                    jointAngles[i] = currentFittest.Joints[i].transform.rotation.eulerAngles;
                }
                foreach (GameObject joint in currentFittest.Joints)
                {
                    joint.transform.rotation = Quaternion.identity;
                }

                currentFittest.gameObject.SetActive(true);
                //jointAngles.Reverse();
                currentFittest.JointsRotationalVector = jointAngles;
                currentFittest.PlayTween();
            }
        }
    }
 public RoboticArmViewModel()
 {
     roboticArm = StatusUpdater.Instance.RoverStatus.RoboArm;
     StatusUpdater.Instance.RoboticArmUpdated += new StatusUpdater.RoboticArmUpdatedDelegate(UpdateRoboticArm);
 }