/**
     * Crea una posición (objeto) y la válida. El nombre se obtiene del campo la interfaz gráfica.
     * @param fromCommand Si es para el comando "defp".
     * @return Transform
     */
    public void RecordPosition(bool fromCommand)
    {
        Transform addedTarget = null;

        InputField targetNameInput = this.targetNameInput;

        if (fromCommand)
        {
            targetNameInput = this.DefpNameInput;
        }
        stateMessageControl.NewBlock();
        // No positions recorded
        if (targetControl.Count() == 0)
        {
            CreateDefaultTarget(targetNameInput.text);
        }
        else // Already at least one point
        {
            GameObject prevSelectedObject = selectionControl.SearchContainTag("Target");

            if (prevSelectedObject != null)
            {
                prevSelectedObject = prevSelectedObject.transform.parent.gameObject;

                // Validate target
                Vector3 newPos = prevSelectedObject.transform.position;
                if (!ValidTarget(targetNameInput.text, prevSelectedObject.transform, newPos))
                {
                    return;
                }

                // Add target
                addedTarget = targetControl.Add(targetNameInput.text, newPos, robot.GetAnglesFromCopy());
                addedTarget.GetComponent <TargetModel>().SetValid(true);
                selectionControl.SetActiveAxis(addedTarget, false);
                selectionControl.SelectedObject(prevSelectedObject);

                stateMessageControl.WriteMessage("Done. Recorded position \"" + targetNameInput.text + "\"", true);

                UpdateTargets(targetControl.GetNames());
                targetNameInput.text = "";
            }
            else
            {
                CreateDefaultTarget(targetNameInput.text);
            }
        }

        stateMessageControl.UpdatePositionLog();
    }
Example #2
0
    void Start()
    {
        GameController.OnlineDel += testExe;//

        lineRenderer = GetComponent <LineRenderer>();
        // Controllers
        manualInputControl = GetComponent <ManualInputControl>();
        selectionControl   = GetComponent <SelectionControl>();
        targetControl      = GetComponent <TargetControl>();
        commandControl     = GetComponent <CommandControl>();
        panelControl       = GetComponent <PanelControl>();

        //selectionControl.SetActiveAxis(target, false);
        axisCamera.SetActive(true);


        defaultPosition = target.position;
        target.GetComponent <ClampName>().textPanel.gameObject.SetActive(false);
        target.gameObject.SetActive(false);
        // Initial target

        //Destroy(target.GetComponent<ClampName>().textPanel.gameObject);
        //Destroy(target.gameObject);
        //SetTarget(targetControl.GetTarget(0));
        //selectionControl.SetActiveAxis(targetControl.GetTarget(0), false);


        UpdateTargets(targetControl.GetNames());

        commandsDropdown.AddOptions(commandControl.GetNames());
        CommandsDropdown_IndexChanged(0);
    }
    void Start()
    {
        // Drawing tool
        lineRenderer = GetComponent <LineRenderer>();
        // Controllers
        manualInputControl  = GetComponent <ManualInputControl>();
        selectionControl    = GetComponent <SelectionControl>();
        targetControl       = GetComponent <TargetControl>();
        commandControl      = GetComponent <CommandControl>();
        panelControl        = GetComponent <PanelControl>();
        stateMessageControl = GetComponent <StateMessageControl>();
        cameraControl       = GetComponent <CameraControl>();
        backupFileControl   = GetComponent <BackUpFileControl>();
        effectorFileControl = GetComponent <EffectorFileControl>();

        // Initial config
        cameraControl.SetIsProcessing(true);//
        axisCamera.SetActive(true);

        defaultPosition = target.position;
        target.GetComponent <ClampName>().textPanel.gameObject.SetActive(false);
        target.gameObject.SetActive(false);
        SetTarget(null);
        UpdateTargets(targetControl.GetNames());

        // Get commands names
        commandsDropdown.AddOptions(commandControl.GetNames());
        CommandsDropdown_IndexChanged(0);

        byXYZPRDropdown.AddOptions(new List <string>()
        {
            "X", "Y", "Z", "P", "R"
        });

        // Ports list
        portsDropdown.AddOptions(new List <string>(controller.List_Ports()));

        // Scorbot ER IX version list
        scorbotVersionDropdown.AddOptions(new List <string>()
        {
            "Original"
        });
    }
Example #4
0
    public void RecordPosition()
    {
        Transform newTarget = Instantiate(targetPrefab).transform;

        // No points recorded
        if (targetControl.Count() == 0)
        {
            //ValidTarget(newTarget);
            if (targetNameInput.text.Equals("") || targetNameInput.text == null)
            {
                stateOutput.text = "Name required";
                Destroy(newTarget.gameObject);
                return;
            }


            Vector3 recordedPos = defaultPosition;
            newTarget.position = recordedPos;

            // Check if it's an unreachable point
            if (!robot.TargetInRange(newTarget.transform))
            {
                Destroy(newTarget.gameObject);
                stateOutput.text = "Unreachable point";
                return;
            }

            stateOutput.text = "OK";

            // Add target
            Transform addedTarget = targetControl.Add(targetNameInput.text, recordedPos, robot.GetAnglesFromCopy());
            selectionControl.SetActiveAxis(addedTarget, true);
            selectionControl.SelectedObject(addedTarget.gameObject);
            SetTarget(addedTarget);

            UpdateTargets(targetControl.GetNames());
            targetNameInput.text = "";
            //DrawTrayectory();
        }
        else // Already at least one point
        {
            GameObject prevSelectedObject = selectionControl.SearchContainTag("Target");

            if (prevSelectedObject != null)
            {
                prevSelectedObject = prevSelectedObject.transform.parent.gameObject;

                if (targetNameInput.text.Equals("") || targetNameInput.text == null)
                {
                    stateOutput.text = "Name required";
                    Destroy(newTarget.gameObject);
                    return;
                }


                Vector3 recordedPos = prevSelectedObject.transform.position;
                newTarget.position = recordedPos;

                // Check if it's an unreachable point
                if (!robot.TargetInRange(prevSelectedObject.transform))
                {
                    Destroy(newTarget.gameObject);
                    stateOutput.text = "Unreachable point";
                    return;
                }

                stateOutput.text = "OK";

                // Add target
                Transform addedTarget = targetControl.Add(targetNameInput.text, recordedPos, robot.GetAnglesFromCopy());
                selectionControl.SetActiveAxis(addedTarget, false);
                selectionControl.SelectedObject(prevSelectedObject);

                UpdateTargets(targetControl.GetNames());

                targetNameInput.text = "";

                //DrawTrayectory();
            }
        }

        Destroy(newTarget.gameObject);
    }