예제 #1
0
 public Servo(DynamixelController controler, byte id)
 {
     // Create controller.
     this.controler = controler;
     // Current ID.
     this.id = id;
 }
예제 #2
0
        /// <summary>
        /// Make the robot to do the move.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMakeMove_Click(object sender, EventArgs e)
        {
            try
            {
                int comIndex = Convert.ToInt32(this.robotSerialPortName.Replace("COM", ""));
                Robotis.DynamixelController controlr = new Robotis.DynamixelController(comIndex, 1);
                this.playerRobot = new NineMansMorrisPlayer(controlr, this.jointIDs);

                ArtifitialInteligence.MoveType   type            = this.NewMove.GetMoveType();
                ArtifitialInteligence.BoardIndex startPosition   = this.NewMove.GetStartPosition();
                ArtifitialInteligence.BoardIndex endPosition     = this.NewMove.GetEndPosition();
                ArtifitialInteligence.BoardIndex capturePosition = this.NewMove.GetCapturePosition();

                switch (type)
                {
                case ArtifitialInteligence.MoveType.Drop:
                    // TODO: Get figure from the shop and drop it on to EndPosition of the move object.

                    // Update UI.
                    lblDesition.Text = String.Format("Робота взема фигура и я поставя на позиция {0}.", endPosition.ToString());

                    // Commands for the robot.
                    if (enableSending)
                    {
                        playerRobot.GetFigureFromShop();
                        playerRobot.DropFigureOnBoard((int)endPosition);
                    }
                    // END
                    break;

                case ArtifitialInteligence.MoveType.DropAndCapture:
                    // TODO: See the coment below (Drop and capture)

                    /*
                     * If the end position == drop position then
                     *  Remove the figure from the board and throw it to thecaptured figures shop.
                     * Get figure from the shop and drop it on to EndPosition of the move objec.
                     */

                    // Update UI.
                    lblDesition.Text = String.Format("Робота взема фигура и я поставя на позиция {0} от игралното поле\nи взема фигура на опонента си от {1}", endPosition.ToString(), capturePosition.ToString());

                    //Commands for the robot.
                    if (this.enableSending)
                    {
                        playerRobot.GetFigureFromShop();
                        playerRobot.DropFigureOnBoard((int)endPosition);
                        playerRobot.GetFigureFromBoard((int)capturePosition);
                        playerRobot.DropFigureToTheCaptureShop();
                    }
                    // END
                    break;

                case ArtifitialInteligence.MoveType.Move:
                    // TODO: Get the figure of the start position of the move objet and drop it to the end position.

                    // Update UI.
                    lblDesition.Text = String.Format("Робота взема фигура и я мести по дъската от позиция {0}.", endPosition.ToString());

                    //Commands for the robot.
                    if (this.enableSending)
                    {
                        playerRobot.GetFigureFromBoard((int)startPosition);
                        playerRobot.DropFigureOnBoard((int)endPosition);
                    }
                    // END
                    break;

                case ArtifitialInteligence.MoveType.MoveAndCapture:
                    // TODO: Get figure frm start position, move it to the end position. Get the figure from capture position and drop it to the capture shop.

                    // Update UI.
                    lblDesition.Text = String.Format("Робота взема фигура и я мести по дъската от позиция {0}.", endPosition.ToString());

                    //Commands for the robot.
                    if (this.enableSending)
                    {
                        playerRobot.GetFigureFromBoard((int)startPosition);
                        playerRobot.DropFigureOnBoard((int)endPosition);
                        playerRobot.GetFigureFromBoard((int)capturePosition);
                        playerRobot.DropFigureToTheCaptureShop();
                    }
                    break;
                }

                // Upadate UI
                tsslblStatusProces.Text = "Last action: generating command.";
            }
            catch (Exception exception)
            {
                tsslblStatusProces.Text = String.Format("Exception: {0}", exception.Message);
                Loging.Log.CreateRecord("MainForm.btnMakeMove_Click", String.Format("Exception: {0}", exception.Message), Loging.LogMessageTypes.Error);
            }
        }
예제 #3
0
 /// <summary>
 /// Write byte.
 /// </summary>
 /// <param name="id">ID of the servo.</param>
 /// <param name="opCode">Operation code.</param>
 /// <param name="data">Argument date.</param>
 internal void WriteByte(int id, int opCode, int data)
 {
     DynamixelController.dxl_write_byte(id, opCode, data);
 }
예제 #4
0
 /// <summary>
 /// Read byte.
 /// </summary>
 /// <param name="id">ID of the servo.</param>
 /// <param name="opCode">Operation code.</param>
 internal int ReadByte(int id, int opCode)
 {
     return(DynamixelController.dxl_read_byte(id, opCode));
 }
예제 #5
0
 /// <summary>
 /// Write word.
 /// </summary>
 /// <param name="id">ID of the servo.</param>
 /// <param name="opCode">Operation code.</param>
 /// <param name="data">Argument date.</param>
 internal void WriteWord(int id, int opCode, int data)
 {
     DynamixelController.dxl_write_word(id, opCode, data);
 }
예제 #6
0
 /// <summary>
 /// Read word.
 /// </summary>
 /// <param name="id">ID of the servo.</param>
 /// <param name="opCode">Operation code.</param>
 internal int ReadWord(int id, int opCode)
 {
     return(DynamixelController.dxl_read_word(id, opCode));
 }