Exemplo n.º 1
0
        public void MovePosition(float goal_x, float goal_y, float goal_z, float rotation, float speed, float acceleration, int interpolation, int move_mode)
        {
            int ret = robot1.set_position_move(goal_x, goal_y, goal_z, rotation, speed, acceleration, interpolation, move_mode);

            if (ret != 1)
            {
                DisplayMessage(robot1.get_card_num().ToString() + "调用set_position_move失败,返回值 = " + ret.ToString());
            }
        }
Exemplo n.º 2
0
        private async void circleButton_Click(object sender, EventArgs e)
        {
            if (!looping3)
            {
                if (task3 != null)
                {
                    // Wait for any existing task to end.
                    await task3;
                }

                SetManualControls(false);

                looping3            = true;
                cancellationSource3 = new CancellationTokenSource();

                debugTextbox.AppendText("Circle started\r\n");

                task3 = Task.Factory.StartNew(async(cancellationToken) =>
                {
                    CancellationToken token = (CancellationToken)cancellationToken;

                    int[][] coords = new int[][]
                    {
                        // x, y, z, rotation, speed, accel, interpolation, move mode
                        new int[] { 50, -50, zAxisHeight, wristAngleDeg, angularSpeed, 50, 1, 2 },
                        new int[] { 50, -100, zAxisHeight, wristAngleDeg, angularSpeed, 50, 1, 2 },
                        new int[] { 100, -100, zAxisHeight, wristAngleDeg, angularSpeed, 50, 1, 2 },
                        new int[] { 100, -50, zAxisHeight, wristAngleDeg, angularSpeed, 50, 1, 2 },
                    };

                    while (true)
                    {
                        foreach (int[] coord in coords)
                        {
                            robot.set_position_move(coord[0], coord[1], coord[2], coord[3], coord[4], coord[5], coord[6], coord[7]);

                            while (!robot.is_robot_goto_target())
                            {
                                if (token.IsCancellationRequested)
                                {
                                    return;
                                }

                                robot.get_scara_param();

                                SetTrackbar(wristTrackbar, wristTextbox, (int)robot.rotation);
                                SetTrackbar(elbowTrackbar, elbowTextbox, (int)robot.angle2);
                                SetTrackbar(shoulderTrackBar, shoulderTextbox, (int)robot.angle1);
                                SetTrackbar(zAxisTrackbar, zAxisTextbox, (int)robot.z);

                                await Task.Delay(50);
                            }
                        }
                    }
                }, cancellationSource3.Token);
            }
            else
            {
                looping3 = false;
                cancellationSource3.Cancel(false);
                debugTextbox.AppendText("Circling stopped\r\n");
                SetManualControls(true);
            }
        }