Beispiel #1
0
    //design this blocking untill the statement is actually completed
    private void executeStatement(Statement currentStatement)
    {
        semaphor_dobot_is_ready = false;
        if (connector == null)
        {
            throw new ArgumentException("The Connector instance has to be set");
        }


        RosSocket rosSocket =
            connector.RosSocket;

        if (currentStatement.GetType().IsSubclassOf(typeof(MoveStatement)))
        {
            MoveStatement moveStatement = (MoveStatement)currentStatement;
            //sphereDrawer.drawSphereAtROSCoords(moveStatement.target);
            RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest req =
                moveStatement.SendCommandToRos();

            String x = rosSocket.CallService <RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest,
                                              RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdResponse>
                           ("/SetPTPCmds", ResponseHandler, req);
        }
        else
        {
            if (currentStatement is ToggleSuction)
            {
                ToggleSuction toggleSuction = (ToggleSuction)currentStatement;

                setEndeffectorSuctionCup.setEndEffectorSuctionCup(toggleSuction.isSuctionEnabled);
            }
        }
        semaphor_dobot_is_ready = false;
    }
Beispiel #2
0
    public override GameObject createCoordinatesSelector(MoveStatement moveStatement)
    {
        GameObject                     coordinateDisplay;
        List <TMP_Dropdown>            dropdownFields;
        List <TMP_Dropdown.OptionData> options;

        coordinateDisplay = Instantiate(singleCoordinateDropdownPrefab);
        dropdownFields    = new List <TMP_Dropdown>();
        coordinateDisplay.GetComponentsInChildren <TMP_Dropdown>(dropdownFields);
        int     currentObject;
        Vector4 parsedDropdown = Vector4.zero;

        Vector4 targetInV4 = new Vector4(moveStatement.target.x, moveStatement.target.y, moveStatement.target.z, 0f);

        foreach (TMP_Dropdown dropdownCoordinate in dropdownFields)
        {
            options       = dropdownCoordinate.options;
            currentObject = 0;
            foreach (TMP_Dropdown.OptionData optionData in options)
            {
                parsedDropdown = parseDropdownText(optionData.text);


                if (parsedDropdown.Equals(targetInV4))
                {
                    dropdownCoordinate.value = currentObject;
                }
                currentObject += 1;
            }
        }
        return(coordinateDisplay);
    }
    private String generateProgramStringFromProgram(Program program)
    {
        String programString = "";

        foreach (Statement statement in program.statements)
        {
            if (statement.GetType().IsSubclassOf(typeof(MoveStatement)))
            {
                RosSharp.RosBridgeClient.MessageTypes.Dobot.SetPTPCmdRequest request;
                MoveStatement moveStatement = (MoveStatement)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";
            }
            else
            {
                if (statement is ToggleSuction)
                {
                    ToggleSuction toggleSuction = (ToggleSuction)statement;
                    programString += $"ToggleSuction({toggleSuction.isSuctionEnabled});\n";
                }
            }
        }
        return(programString);
    }
Beispiel #4
0
        public override Object Visit(MoveStatement node, Object obj)
        {
            this.printIndentation(Convert.ToInt32(obj));

            if (node.LeftExp.IndexOfSSA != -1)
            {
                this.output.Write("{0}{1}", node.LeftExp.Identifier, node.LeftExp.IndexOfSSA);
            }
            else
            {
                this.output.Write("{0}", node.LeftExp.Identifier);
            }

            this.output.Write(" ({0})", printType(node.LeftExp.ExpressionType));
            this.output.Write(" <-- ");

            if (node.RightExp.IndexOfSSA != -1)
            {
                this.output.Write("{0}{1}", node.RightExp.Identifier, node.RightExp.IndexOfSSA);
            }
            else
            {
                this.output.Write("{0}", node.RightExp.Identifier);
            }

            this.output.WriteLine(" ({0})", printType(node.RightExp.ExpressionType));

            if (node.MoveStat != null)
            {
                node.MoveStat.Accept(this, obj);
            }
            return(null);
        }
 public override object Visit(MoveStatement node, object obj)
 {
     if (node.Location == ((AstNode)obj).Location || found)
     {
         found = true;
         return(this.table);
     }
     return(base.Visit(node, obj));
 }
Beispiel #6
0
        public override Object Visit(MoveStatement node, Object obj)
        {
            MoveStatement clonedMoveStatement = new MoveStatement((SingleIdentifierExpression)node.LeftExp.Accept(this, obj), (SingleIdentifierExpression)node.RightExp.Accept(this, obj), node.Location.FileName, node.Location.Line);

            if (node.MoveStat != null)
            {
                clonedMoveStatement.MoveStat = (MoveStatement)node.MoveStat.Accept(this, obj);
            }
            return(clonedMoveStatement);
        }
Beispiel #7
0
    public override GameObject generateMovmentTypeSelectorFromStatement(MoveStatement 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);
    }
Beispiel #8
0
        public override Object Visit(MoveStatement node, Object obj)
        {
            node.LeftExp.Accept(this, obj);
            node.RightExp.Accept(this, obj);

            if (node.MoveStat != null)
            {
                node.MoveStat.Accept(this, obj);
            }

            return(null);
        }
Beispiel #9
0
    public override GameObject createCoordinatesSelector(MoveStatement moveStatement)
    {
        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 (useROSCoordinates)
                    {
                        if (coordinateTargetSelector.selectedRosTransform != null)
                        {
                            Transform rosCoords = coordinateTargetSelector.selectedRosTransform;
                            textField.text      = rosCoords.localPosition.ToString();
                        }
                    }
                    else
                    {
                        Transform ownCoords = GameObject.Find("RealTargetSphere").transform;//   coordinateTargetSelector.selectedOwnTransform;
                        textField.text      = ownCoords.localPosition.ToString();
                    }
                });

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


        return(coordinateDisplay);
    }
Beispiel #10
0
 public void StartProgram()
 {
     sphereDrawer.clearTargets();
     foreach (Statement currentStatement in this.currentProgram.statements)
     {
         if (currentStatement.GetType().IsSubclassOf(typeof(MoveStatement)))
         {
             MoveStatement moveStatement = (MoveStatement)currentStatement;
             sphereDrawer.drawNewTargetSphereAtROSCoords(moveStatement.target);
         }
     }
     currentPosition = 0;
     PhysicsManager.continuePhysics();
 }
Beispiel #11
0
        public override Object Visit(MoveStatement node, Object obj)
        {
            SSAMap mapX;
            SSAMap mapY;

            if (obj is SSAInfo)
            {
                if ((mapX = ((SSAInfo)obj).FirstOperandToMove) != null)
                {
                    if (mapX.Search(node.LeftExp.Identifier) != -1) // <-- Modified
                    {
                        if ((mapY = ((SSAInfo)obj).SecondOperandToMove) != null)
                        {
                            if (node.LeftExp.IndexOfSSA == mapX.Search(node.LeftExp.Identifier))
                            {
                                node.MoveStat = createMoveStatement(node.LeftExp.Identifier, mapX, mapY, node.Location.FileName, node.Location.Line);
                            }
                        }
                        else
                        {
                            if (node.LeftExp.IndexOfSSA == mapX.Search(node.LeftExp.Identifier) - 1)
                            {
                                node.MoveStat = createMoveStatement(node.LeftExp.Identifier, mapX, node.Location.FileName, node.Location.Line);
                            }
                        }
                    }
                }
            }
            node.RightExp.Accept(this, obj);

            if (node.MoveStat != null)
            {
                node.MoveStat.Accept(this, obj);
            }

            return(null);
        }
Beispiel #12
0
 public virtual void OnMoveStatement(MoveStatement stmt)
 {
     Enter(new Move(stmt), stmt);
     Exit();
 }
 private List <Statement> newMovementCommand(Vector3 target, MoveStatement statement, List <Statement> statements)
 {
     statement.target = target;
     statements.Add(statement);
     return(statements);
 }
 public abstract Object Visit(MoveStatement node, Object obj);
 public abstract GameObject createCoordinatesSelector(MoveStatement moveStatement);
Beispiel #16
0
 public abstract GameObject generateMovmentTypeSelectorFromStatement(MoveStatement moveStatement);