Exemplo n.º 1
0
        private void StartFromSliderChange(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (Global.loadingDone == true)
            {
                if (listBox.SelectedIndex == 0)
                {
                    movement.elbow0.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content         = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
                else if (listBox.SelectedIndex == 1)
                {
                    movement.elbow1.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content         = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
                else if (listBox.SelectedIndex == 2)
                {
                    movement.elbow2.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content         = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
                else if (listBox.SelectedIndex == 3)
                {
                    movement.baseMovemend.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
                else if (listBox.SelectedIndex == 4)
                {
                    movement.griperRotation.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
                else if (listBox.SelectedIndex == 5)
                {
                    movement.griper.startfrom = Math.Round(start.Value, 2);
                    startFrom.Content         = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                    double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                    availableD.Content = Math.Round(avalible, 2).ToString() + " °";
                }
            }
        }
Exemplo n.º 2
0
        private async void ObjectFollow(string msg)
        {
            string [] data    = msg.Split('*');
            int       speed   = Convert.ToInt32(data[2]);
            string    command = "";

            if (data[0] == "1")
            {
                command = (movement.baseMovemend.AngleInDegree - speed).ToString() + "*";
            }
            else if (data[0] == "2")
            {
                command = (movement.baseMovemend.AngleInDegree + speed).ToString() + "*";
            }
            else
            {
                command = movement.baseMovemend.AngleInDegree.ToString() + "*";
            }

            command += movement.elbow0.AngleInDegree.ToString() + "*";

            if (data[1] == "2")
            {
                if (movement.elbow2.AngleInDegree - speed < Arm.PwmToDegree(movement.elbow2.startfrom))
                {
                    command += (movement.elbow1.AngleInDegree - speed).ToString() + "*" + movement.elbow2.AngleInDegree.ToString() + "*";
                }
                else
                {
                    command += movement.elbow1.AngleInDegree.ToString() + "*" + (movement.elbow2.AngleInDegree - speed).ToString() + "*";
                }
            }
            else if (data[1] == "1")
            {
                if (movement.elbow2.AngleInDegree + speed > Arm.PwmToDegree(movement.elbow2.EndAt))
                {
                    command += (movement.elbow1.AngleInDegree + speed).ToString() + "*" + movement.elbow2.AngleInDegree.ToString() + "*";
                }
                else
                {
                    command += movement.elbow1.AngleInDegree.ToString() + "*" + (movement.elbow2.AngleInDegree + speed).ToString() + "*";
                }
            }
            else
            {
                command += movement.elbow1.AngleInDegree.ToString() + "*" + movement.elbow2.AngleInDegree.ToString() + "*";
            }

            command += movement.griperRotation.AngleInDegree.ToString() + "*" + movement.griper.AngleInDegree.ToString() + "*0*0*1.5";

            await AutoModeTemplate.ScriptDefaultMovemend(command, movement);

            SendACK();
        }
Exemplo n.º 3
0
        private void GetAngle()
        {
            angles[2, 0] = movement.elbow0.AngleInDegree;
            angles[1, 0] = movement.elbow1.AngleInDegree;
            angles[0, 0] = movement.elbow2.AngleInDegree;

            angles[2, 1] = Arm.PwmToDegree(movement.elbow0.startfrom);
            angles[1, 1] = Arm.PwmToDegree(movement.elbow1.startfrom);
            angles[0, 1] = Arm.PwmToDegree(movement.elbow2.startfrom);

            angles[2, 2] = Arm.PwmToDegree(movement.elbow0.EndAt);
            angles[1, 2] = Arm.PwmToDegree(movement.elbow1.EndAt);
            angles[0, 2] = Arm.PwmToDegree(movement.elbow2.EndAt);
        }
Exemplo n.º 4
0
        private void MotorCalibrationDisplay()
        {
            if (listBox.SelectedIndex == 0 && max != null)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.elbow0.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.elbow0.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
            else if (listBox.SelectedIndex == 1)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.elbow1.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.elbow1.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
            else if (listBox.SelectedIndex == 2)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.elbow2.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.elbow2.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
            else if (listBox.SelectedIndex == 3)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.baseMovemend.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.baseMovemend.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
            else if (listBox.SelectedIndex == 4)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.griperRotation.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.griperRotation.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
            else if (listBox.SelectedIndex == 5)
            {
                max.Maximum    = Arm.max_Pwm;
                max.Minimum    = Arm.min_Pwm;
                max.Value      = movement.griper.EndAt;
                maxUse.Content = Math.Round(Arm.PwmToDegree(max.Value), 2) + " °";

                start.Maximum     = Arm.max_Pwm;;
                start.Minimum     = Arm.min_Pwm;;
                start.Value       = movement.griper.startfrom;
                startFrom.Content = "+ " + Math.Round(Arm.PwmToDegree(start.Value), 2) + " °";

                double avalible = 180 - Arm.PwmToDegree(start.Value) - (180 - Arm.PwmToDegree(max.Value));
                availableD.Content = Math.Round(avalible, 2).ToString() + " °";
            }
        }