コード例 #1
0
        private void JoystickCheckButton()
        {
            if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button9) == true)
            {
                labelDegeri = "select";
                if (moder == true)
                {
                    moder = false;
                }
            }
            if (m_CJoy.IsUp(Ojw.CJoystick.PadKey.Button9) == true)
            {
                if (moder == false)
                {
                    Moder();
                    moder = true;
                }
            }
            if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button10) == true)
            {
                labelDegeri = "start";
                if (visibility == true)
                {
                    visibility = false;
                }
            }
            if (m_CJoy.IsUp(Ojw.CJoystick.PadKey.Button10) == true)
            {
                if (visibility == false)
                {
                    Visibility();
                    visibility = true;
                }
            }
            if (mouseMod == true)
            {
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.POVLeft) == true)
                {
                    labelDegeri = "← ";
                    SendKeys.Send("{LEFT}");
                }
                else if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.POVRight) == true)
                {
                    labelDegeri = "→ ";
                    SendKeys.Send("{RIGHT}");
                }
                else
                {
                    labelDegeri = "";
                }

                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.POVUp) == true)
                {
                    labelDegeri += "↑";
                    SendKeys.Send("{UP}");
                }
                else if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.POVDown) == true)
                {
                    labelDegeri += "↓";
                    SendKeys.Send("{DOWN}");
                }

                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button4) == true)
                {
                    labelDegeri = "Y";
                    SendKeys.Send("%{LEFT}");//alt-left, undo
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button3) == true)
                {
                    labelDegeri = "X";
                    SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr)APPCOMMAND_VOLUME_DOWN);
                    //volume-down
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button2) == true)
                {
                    labelDegeri = "B";
                    SendKeys.Send("%{RIGHT}");//alt-right, redo
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button1) == true)
                {
                    labelDegeri = "A";
                    SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr)APPCOMMAND_VOLUME_UP);
                    //vol-up
                }

                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button5) == true)
                {
                    labelDegeri = "L1";
                    SendKeys.Send("{TAB}");
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button6) == true)
                {
                    labelDegeri = "R1";
                    SendKeys.Send("{ENTER}");
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button7) == true)
                {
                    labelDegeri = "L2";
                    SendKeys.Send("{ESC}");
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button8) == true)
                {
                    labelDegeri = "R2";
                    SendKeys.Send("{ENTER}");
                }

                //Fare tıklamasını tek seferlik hale getiren kod bloğu
                label1.Text = labelDegeri;
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button11) == true)
                {
                    if (mouseLeftClicked == true)
                    {
                        mouse_event(MOUSEEVENT_LEFTDOWN, 0, 0, 0, 0);
                        mouseLeftClicked = false;
                    }
                }
                if (m_CJoy.IsUp(Ojw.CJoystick.PadKey.Button11) == true)
                {
                    if (mouseLeftClicked == false)
                    {
                        mouse_event(MOUSEEVENT_LEFTUP, 0, 0, 0, 0);
                        mouseLeftClicked = true;
                    }
                }
                if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button12) == true)
                {
                    if (mouseRightClicked == true)
                    {
                        mouse_event(MOUSEEVENT_RIGHTDOWN, 0, 0, 0, 0);
                        mouseRightClicked = false;
                    }
                }
                if (m_CJoy.IsUp(Ojw.CJoystick.PadKey.Button12) == true)
                {
                    if (mouseRightClicked == false)
                    {
                        mouse_event(MOUSEEVENT_RIGHTUP, 0, 0, 0, 0);
                        mouseRightClicked = true;
                    }
                }
            }
        }
コード例 #2
0
        private void Joystick_Check_Data()
        {
            if (HMController.IsDown(Ojw.CJoystick.PadKey.POVLeft) == true)
            {
                DpadSpanish = "Izquierda ";
                DpadEnglish = "Left ";
            }
            else if (HMController.IsDown(Ojw.CJoystick.PadKey.POVRight) == true)
            {
                DpadSpanish = "Derecha ";
                DpadEnglish = "Right ";
            }
            else
            {
                DpadSpanish = "";
                DpadEnglish = "";
            }
            if (HMController.IsDown(Ojw.CJoystick.PadKey.POVUp) == true)
            {
                DpadSpanish += "Arriba";
                DpadEnglish += "Up";
            }
            else if (HMController.IsDown(Ojw.CJoystick.PadKey.POVDown) == true)
            {
                DpadSpanish += "Abajo";
                DpadEnglish += "Down";
            }
            if (DpadSpanish == "")
            {
                DpadSpanish = "Sin presionar";
                DpadEnglish = "Not pressed";
            }

            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button4) == true)
            {
                lblY.ForeColor = Color.Red;
            }
            else
            {
                lblY.ForeColor = Color.Black;
            }
            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button3) == true)
            {
                lblX.ForeColor = Color.Red;
            }
            else
            {
                lblX.ForeColor = Color.Black;
            }
            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button2) == true)
            {
                lblB.ForeColor = Color.Red;
            }
            else
            {
                lblB.ForeColor = Color.Black;
            }
            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button1) == true)
            {
                lblA.ForeColor = Color.Red;
            }
            else
            {
                lblA.ForeColor = Color.Black;
            }

            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button5) == true)
            {
                lblLeft.ForeColor = Color.Red;
            }
            else
            {
                lblLeft.ForeColor = Color.Black;
            }
            if (HMController.IsDown(Ojw.CJoystick.PadKey.Button6) == true)
            {
                lblRight.ForeColor = Color.Red;
            }
            else
            {
                lblRight.ForeColor = Color.Black;
            }
            //Formula para mapear 0 -> 1 a -1 -> +1
            //  Y= 2x - 1
            double Vx1 = (2 * HMController.dX0 - (1)),
                   Vx2 = (2 * HMController.dX1 - (1)),
                   Vy1 = (2 * HMController.dY0 - (1)),
                   Vy2 = (2 * HMController.dY1 - (1));

            label1.Text           = DpadSpanish + "\r\n" + DpadEnglish;
            radioButton1.Location = new Point((int)(x1 * 1.8 * HMController.dX0), (int)(y1 * 1.8 * HMController.dY0));
            radioButton2.Location = new Point((int)(x2 * 1.8 * HMController.dX1), (int)(y2 * 1.8 * HMController.dY1));
            textBox1.Text         = Convert.ToString("X = " + Vx1 + "\r\nY = " + Vy1);
            textBox2.Text         = Convert.ToString("X = " + Vx2 + "\r\nY = " + Vy2);
            radioButton3.Location = new Point((int)(168 - HMController.Slide * 168), 10);
        }
コード例 #3
0
        private void pad_check_data()
        {
            double mecFB  = 0;
            double mecRL  = 0;
            double mecT   = 0;
            int    inside = 0;

            if (mecanumMode == true)//메카넘모드일때
            {
                if (pad.dY1 > 0.52 | pad.dY1 < 0.48)
                {
                    mecFB = -(pad.dY1 - 0.5) * mecanumSpeed * mecanumAdd;
                }
                if (pad.dX1 > 0.52 | pad.dX1 < 0.48)
                {
                    mecRL = (pad.dX1 - 0.5) * mecanumSpeed * mecanumAdd;
                }

                /*if (pad.dX0 > 0.55 | pad.dX0 < 0.45)
                 * {
                 *  mecT = (pad.dX0 - 0.5) * mecanumSpeed * mecanumAdd;
                 *  light = true;
                 * }*/
                if (pad.Slide > 0.52 | pad.Slide < 0.48)
                {
                    mecT = -(pad.Slide - 0.5) * mecanumSpeed * mecanumAdd;
                }
                if (pad.dX0 > 0.52 | pad.dX0 <0.48 | pad.dY0> 0.52 | pad.dY0 < 0.48)
                {
                    mecFB = -(pad.dY0 - 0.5) * mecanumSpeed * mecanumAdd2;
                    mecT  = (pad.dX0 - 0.5) * mecanumSpeed * mecanumAdd2;

                    /*if (mecFB < 0)
                     * {
                     *  mecT = -mecT;
                     * }*/
                }

                if (pad.IsDown(Ojw.CJoystick.PadKey.Button1) == true)
                {
                    // A   보정 기능
                    inside = 100;
                }

                if (pad.IsDown(Ojw.CJoystick.PadKey.POVUp) == true) //위 버튼
                {
                    mecFB = mecanumSpeed;
                }
                else if (pad.IsDown(Ojw.CJoystick.PadKey.POVDown) == true) //아래 버튼
                {
                    mecFB = -mecanumSpeed;
                }
                if (pad.IsDown(Ojw.CJoystick.PadKey.POVRight) == true)
                {
                    mecRL = mecanumSpeed;
                }
                else if (pad.IsDown(Ojw.CJoystick.PadKey.POVLeft) == true)
                {
                    mecRL = -mecanumSpeed;
                }

                motor.Set_Turn(30, (int)(-mecFB + mecRL + mecT - inside));
                motor.Set_Turn(31, (int)(-mecFB - mecRL + mecT + (2 * inside)));
                motor.Set_Turn(32, (int)(mecFB - mecRL + mecT - (2 * inside)));
                motor.Set_Turn(33, (int)(mecFB + mecRL + mecT + inside));

                motor.Send_Motor(10);
                motor.Wait(10);
            }
            else//걷기모드일때
            {
                if (!walking) //걷고있지 않을때
                {
                    if (pad.IsDown_Event(Ojw.CJoystick.PadKey.POVUp) == true) //위 버튼
                    {
                        btnWalkFront_Click(null, null);
                    }
                    else if (pad.IsDown_Event(Ojw.CJoystick.PadKey.POVDown) == true) //아래 버튼
                    {
                        btnWalkBack_Click(null, null);
                    }
                    else if (pad.IsDown_Event(Ojw.CJoystick.PadKey.POVRight) == true)
                    {
                        btnWalkTurnRight_Click(null, null);
                    }
                    else if (pad.IsDown_Event(Ojw.CJoystick.PadKey.POVLeft) == true)
                    {
                        btnWalkTurnLeft_Click(null, null);
                    }
                    //X버튼
                    if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button3) == true)
                    {
                        btnStairLeft_Click(null, null);
                    }
                    if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button4) == true)
                    {
                        btnStairRight_Click(null, null);
                    }
                }
                //B 버튼
                if (pad.IsDown(Ojw.CJoystick.PadKey.Button2) == true)
                {
                    btnWalkStop_Click(null, null);
                }
            }
            //왼쪽 트리거 버튼
            if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button5) == true) // 보행 모드
            {
                if (mecanumMode == true)                                //메카넘 모드일때
                {
                    btnTransformToWalk_Click(null, null);
                }
                else
                {
                    btnStandPose_Click(null, null);
                }
            }
            //오른쪽 트리거 버튼
            if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button6) == true) // 메카넘 모드 버튼
            {
                if (mecanumMode == false)                               //보행 모드일때
                {
                    btnTransformToMecanum_Click(null, null);
                }
                else
                {
                    btnMecanumPose_Click(null, null);
                }
            }
            if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button7) == true)
            {
                // BACK
                motor.SetTorq(false);
            }
            if (pad.IsDown_Event(Ojw.CJoystick.PadKey.Button8) == true)
            {
                // START
                motor.SetTorq(true);
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Einsbon/Manipulator_v2
        private void FJoystick_Check_Data()
        {
            double cjy = m_CJoy.dX0;
            double cjx = m_CJoy.dY0;
            double cjz = m_CJoy.dY1;


            if (cjy > 0.53 | cjy < 0.47)
            {
                y -= (int)((cjy - 0.5) * joystickSpd);
                txtWarning.Text = "";
                if (posOK(x, y, z) == false)
                {
                    txtWarning.Text = "범위 이상의 모터 각도";
                    y += (int)((cjy - 0.5) * joystickSpd);
                }
            }

            if (cjx > 0.53 | cjx < 0.47)
            {
                x -= (int)((cjx - 0.5) * joystickSpd);
                txtWarning.Text = "";
                if (posOK(x, y, z) == false)
                {
                    txtWarning.Text = "범위 이상의 모터 각도";
                    x += (int)((cjx - 0.5) * joystickSpd);
                }
            }
            if (cjz > 0.53 | cjz < 0.47)
            {
                z -= (int)((cjz - 0.5) * joystickSpd);
                txtWarning.Text = "";
                if (posOK(x, y, z) == false)
                {
                    txtWarning.Text = "범위 이상의 모터 각도";
                    z += (int)((cjz - 0.5) * joystickSpd);
                }
            }

            if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button2) == true)
            {
                lblB.ForeColor = Color.Red;
                grabOK2        = false;
            }
            else
            {
                lblB.ForeColor = Color.Black;
            }
            if (m_CJoy.IsDown(Ojw.CJoystick.PadKey.Button1) == true)
            {
                lblA.ForeColor = Color.Red;
                grabOK2        = true;
            }
            else
            {
                lblA.ForeColor = Color.Black;
            }
            if (grabOK2)
            {
                m.Set_Angle(5, gripperGrab);
                m.Send_Motor(500);
            }
            else
            {
                m.Set_Angle(5, gripperUngrab);
                m.Send_Motor(500);
            }

            txtGamepadDisp.Text = "X = " + m_CJoy.dX0 + "\r\nY = " + m_CJoy.dY0 + "\r\nZ = " + m_CJoy.dY1;

            radioButton1.Location = new Point((int)(187 * m_CJoy.dX0), (int)(187 * m_CJoy.dY0));
            radioButton2.Location = new Point(10, (int)(186 * m_CJoy.dY1));

            InverseKinematicsMove(x, y, z, 300, 0);
        }