Пример #1
0
    public override GameObject generateMovmentTypeSelectorFromStatement(MoveStatement1 moveStatement)
    {
        GameObject dropdownObject;

        dropdownObject = Instantiate(movementTypeDropdownPrefab);
        dropdownObject.TryGetComponent(out RectTransform rectTransformDropDown);
        dropdownObject.TryGetComponent(out TMP_Dropdown dropdown);
        dropdown.value = moveStatement.movementValueForCanvas;
        dropdown.RefreshShownValue();
        return(dropdownObject);
    }
Пример #2
0
 public void StartProgram()
 {
     sphereDrawer.clearTargets();
     foreach (Statement currentStatement in this.currentProgram.statements)
     {
         if (currentStatement.GetType().IsSubclassOf(typeof(MoveStatement1)))
         {
             MoveStatement1 moveStatement = (MoveStatement1)currentStatement;
             sphereDrawer.drawNewTargetSphereAtROSCoords(moveStatement.target);
         }
     }
     currentPosition = 0;
     PhysicsManager.continuePhysics();
 }
Пример #3
0
    //Commenting out CoordinateTargetSelector
    //public CoordinateTargetSelector coordinateTargetSelector;
    public override GameObject createCoordinatesSelector(MoveStatement1 moveStatement)
    {
        //Overriding createCoordinatesSelector for MOVE
        GameObject         coordinateDisplay;
        List <TextMeshPro> textFields;
        Button             button;
        Interactable       interactable;

        textFields        = new List <TextMeshPro>();
        coordinateDisplay = Instantiate(targetSelectorPrefab);
        coordinateDisplay.GetComponentsInChildren <TextMeshPro>(textFields);
        Vector4 targetInV4 = new Vector4(moveStatement.target.x, moveStatement.target.y, moveStatement.target.z, 0f);

        button       = coordinateDisplay.GetComponentInChildren <Button>();
        interactable = coordinateDisplay.GetComponentInChildren <Interactable>();
        foreach (TextMeshPro textField in textFields)
        {
            if (textField.name.Contains("TargetValue"))
            {
                textField.text = moveStatement.target.ToString();
                interactable.OnClick.AddListener(() =>
                {  /*
                    * if (coordinateTargetSelector.selectedRosTransform != null)
                    * {
                    *   Transform rosCoords = coordinateTargetSelector.selectedRosTransform;
                    *   textField.text = rosCoords.localPosition.ToString();
                    * }    */
                });

                /*
                 * button.onClick.AddListener(() =>
                 * {
                 *  if(coordinateTargetSelector.selectedRosTransform != null)
                 *  {
                 *      Transform rosCoords = coordinateTargetSelector.selectedRosTransform;
                 *      textField.text = rosCoords.localPosition.ToString();
                 *  }
                 * });
                 */
            }
        }


        return(coordinateDisplay);
    }
 public abstract GameObject generateMovmentTypeSelectorFromStatement(MoveStatement1 moveStatement);
 //NewMove command below
 private List <Statement> newMovementCommand(Vector3 target, MoveStatement1 statement, List <Statement> statements)
 {
     statement.target = target;
     statements.Add(statement);
     return(statements);
 }
Пример #6
0
    private String generateProgramStringFromProgram(Program program)
    {
        String programString = "";

        foreach (Statement statement in program.statements)
        {
            //debug
            Debug.Log("generateProgramStringFromProgram statement:" + statement);
            if (statement.GetType().IsSubclassOf(typeof(MoveStatement1)))
            {
                RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest request;
                MoveStatement1 moveStatement = (MoveStatement1)statement;
                byte           ptpMode_byte;
                byte.TryParse("" + moveStatement.movementValueForCanvas, out ptpMode_byte);
                float x = moveStatement.target.x;
                float y = moveStatement.target.y;
                float z = moveStatement.target.z;
                float r = 0f;
                request        = new RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest(ptpMode_byte, x, y, z, r, true);
                programString += $"Move({request.x} {request.y} {request.z});\n";
            }
            //below is to generate Program string from Program for BruteMove. The string generated on UI will read 'Brute'
            else if (statement.GetType().IsSubclassOf(typeof(BruteMove)))
            {
                RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest request;
                BruteMove bruteStatement = (BruteMove)statement;
                byte      ptpMode_byte;
                byte.TryParse("" + bruteStatement.movementValueForCanvas, out ptpMode_byte);
                float x = bruteStatement.target.x;
                float y = bruteStatement.target.y;
                float z = bruteStatement.target.z;
                float r = 0f;
                request        = new RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest(ptpMode_byte, x, y, z, r, true);
                programString += $"Brute({request.x} {request.y} {request.z});\n";
            }
            else
            {
                if (statement is ClawUp)
                {
                    ClawUp clawUp = (ClawUp)statement;
                    // programString += $"Claw({clawUp.isClawUp});\n";
                    if (clawUp.isClawUp == true)
                    {
                        programString += $"Claw({"up"});\n";
                    }
                    else
                    {
                        programString += $"Claw({"down"});\n";
                    }
                }

                /*
                 * if (statement is ToggleSuction)
                 * {
                 *  //  ToggleSuction toggleSuction = (ToggleSuction)statement;
                 *  //programString += $"ToggleSuction({toggleSuction.isSuctionEnabled});\n";
                 *  programString += $"Move({0} {0} {0});\n";
                 * }
                 */
            }
        }
        //debug
        Debug.Log("generateProgramStringFromProgram with co-ordinates :" + programString);
        return(programString);
    }
 public abstract GameObject createCoordinatesSelector(MoveStatement1 moveStatement);