Beispiel #1
0
        /*
#if (FRAME_CONFIG == QUAD_FRAME)
        MAV_TYPE_QUADROTOR,
#elif (FRAME_CONFIG == TRI_FRAME)
        MAV_TYPE_TRICOPTER,
#elif (FRAME_CONFIG == HEXA_FRAME || FRAME_CONFIG == Y6_FRAME)
        MAV_TYPE_HEXAROTOR,
#elif (FRAME_CONFIG == OCTA_FRAME || FRAME_CONFIG == OCTA_QUAD_FRAME)
        MAV_TYPE_OCTOROTOR,
#elif (FRAME_CONFIG == HELI_FRAME)
        MAV_TYPE_HELICOPTER,
#elif (FRAME_CONFIG == SINGLE_FRAME)  //because mavlink did not define a singlecopter, we use a rocket
        MAV_TYPE_ROCKET,
#elif (FRAME_CONFIG == COAX_FRAME)  //because mavlink did not define a singlecopter, we use a rocket
        MAV_TYPE_ROCKET,
#else
  #error Unrecognised frame type
#endif*/

        public void Activate()
        {
            int x = 20;
            int y = 40;

            int motormax = 8;

            if (!MainV2.comPort.MAV.param.ContainsKey("FRAME"))
            {
                this.Enabled = false;
                return;
            }

            HIL.Motor[] motors = new HIL.Motor[0];

            if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.TRICOPTER)
            {
                motormax = 4;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.TRICOPTER, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.QUADROTOR)
            {
                motormax = 4;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.QUADROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.HEXAROTOR)
            {
                motormax = 6;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.HEXAROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.OCTOROTOR)
            {
                motormax = 8;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.OCTOROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.HELICOPTER)
            {
                motormax = 0;
            }

            for (int a = 1; a <= motormax; a++)
            {

                MyButton but = new MyButton();
                but.Text = "Test motor " + (char)((a-1) + 'A');
                but.Location = new Point(x,y);
                but.Click += but_Click;
                but.Tag = a;

                this.Controls.Add(but);

                y += 25;
            }
        }
        /*
         #if (FRAME_CONFIG == QUAD_FRAME)
         * MAV_TYPE_QUADROTOR,
         #elif (FRAME_CONFIG == TRI_FRAME)
         * MAV_TYPE_TRICOPTER,
         #elif (FRAME_CONFIG == HEXA_FRAME || FRAME_CONFIG == Y6_FRAME)
         * MAV_TYPE_HEXAROTOR,
         #elif (FRAME_CONFIG == OCTA_FRAME || FRAME_CONFIG == OCTA_QUAD_FRAME)
         * MAV_TYPE_OCTOROTOR,
         #elif (FRAME_CONFIG == HELI_FRAME)
         * MAV_TYPE_HELICOPTER,
         #elif (FRAME_CONFIG == SINGLE_FRAME)  //because mavlink did not define a singlecopter, we use a rocket
         * MAV_TYPE_ROCKET,
         #elif (FRAME_CONFIG == COAX_FRAME)  //because mavlink did not define a singlecopter, we use a rocket
         * MAV_TYPE_ROCKET,
         #else
         #error Unrecognised frame type
         #endif*/

        public void Activate()
        {
            int x = 20;
            int y = 40;

            int motormax = 8;

            if (!MainV2.comPort.MAV.param.ContainsKey("FRAME"))
            {
                this.Enabled = false;
                return;
            }

            HIL.Motor[] motors = new HIL.Motor[0];

            if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.TRICOPTER)
            {
                motormax = 3;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.TRICOPTER, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.QUADROTOR)
            {
                motormax = 4;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.QUADROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.HEXAROTOR)
            {
                motormax = 6;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.HEXAROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.OCTOROTOR)
            {
                motormax = 8;

                motors = HIL.Motor.build_motors(MAVLink.MAV_TYPE.OCTOROTOR, (int)(float)MainV2.comPort.MAV.param["FRAME"]);
            }
            else if (MainV2.comPort.MAV.aptype == MAVLink.MAV_TYPE.HELICOPTER)
            {
                motormax = 0;
            }

            for (int a = 1; a <= motormax; a++)
            {
                MyButton but = new MyButton();
                but.Text     = "Test motor " + (char)((a - 1) + 'A');
                but.Location = new Point(x, y);
                but.Click   += but_Click;
                but.Tag      = a;

                this.Controls.Add(but);

                y += 25;
            }
        }
Beispiel #3
0
        public static Motor[] build_motors(string frame)
        {
            Motor[] motors = new HIL.Motor[8];
            frame = frame.ToLower();
            if (frame.Contains("quad") || frame.Contains("quadx"))
            {
                motors = new HIL.Motor[] {
                    new Motor(90, False, 1),
                    new Motor(270, False, 2),
                    new Motor(0, True, 3),
                    new Motor(180, True, 4),
                };
                if (frame.Contains("quadx"))
                {
                    foreach (int i in range(4))
                    {
                        motors[i].angle -= 45.0;
                    }
                }
            }

            else if (frame.Contains("y6"))
            {
                motors = new HIL.Motor[] {
                    new Motor(60, False, 1),
                    new Motor(60, True, 7),
                    new Motor(180, True, 4),
                    new Motor(180, False, 8),
                    new Motor(-60, True, 2),
                    new Motor(-60, False, 3),
                };
            }
            else if (frame.Contains("hexa") || frame.Contains("hexax"))
            {
                motors = new HIL.Motor[] {
                    new Motor(0, True, 1),
                    new Motor(60, False, 4),
                    new Motor(120, True, 8),
                    new Motor(180, False, 2),
                    new Motor(240, True, 3),
                    new Motor(300, False, 7),
                };
            }
            else if (frame.Contains("hexax"))
            {
                motors = new HIL.Motor[] {
                    new Motor(30, False, 7),
                    new Motor(90, True, 1),
                    new Motor(150, False, 4),
                    new Motor(210, True, 8),
                    new Motor(270, False, 2),
                    new Motor(330, True, 3),
                };
            }
            else if (frame.Contains("octa") || frame.Contains("octax"))
            {
                motors = new HIL.Motor[] {
                    new Motor(0, True, 1),
                    new Motor(180, True, 2),
                    new Motor(45, False, 3),
                    new Motor(135, False, 4),
                    new Motor(-45, False, 7),
                    new Motor(-135, False, 8),
                    new Motor(270, True, 10),
                    new Motor(90, True, 11),
                };
                if (frame.Contains("octax"))
                {
                    foreach (int i in range(8))
                    {
                        motors[i].angle += 22.5;
                    }
                }
            }
            return(motors);
        }
Beispiel #4
0
        public static Motor[] build_motors(string frame)
        {
            Motor[] motors = new HIL.Motor[8];
            frame = frame.ToLower();
            if (frame.Contains("quad") || frame.Contains("quadx"))
            {
                motors = new HIL.Motor[] {
            new Motor(90,  False,  1),
            new Motor(270, False,  2),
            new Motor(0,   True,   3),
            new Motor(180, True,   4),
                };
                if (frame.Contains("quadx"))
                {
                    foreach (int i in range(4))
                        motors[i].angle -= 45.0;
                }
            }

            else if (frame.Contains("y6"))
            {
                motors = new HIL.Motor[] {
            new Motor(60,   False, 1),
            new Motor(60,   True,  7),
            new Motor(180,  True,  4),
            new Motor(180,  False, 8),
            new Motor(-60,  True,  2),
            new Motor(-60,  False, 3),
            };
            }
            else if (frame.Contains("hexa") || frame.Contains("hexax"))
            {
                motors = new HIL.Motor[] {
            new Motor(0,   True,  1),
            new Motor(60,  False, 4),
            new Motor(120, True,  8),
            new Motor(180, False, 2),
            new Motor(240, True,  3),
            new Motor(300, False, 7),
               };
            }
            else if (frame.Contains("hexax"))
            {
                motors = new HIL.Motor[] {
            new Motor(30,  False,  7),
            new Motor(90,  True,   1),
            new Motor(150, False,  4),
            new Motor(210, True,   8),
            new Motor(270, False,  2),
            new Motor(330, True,   3),
               };
            }
            else if (frame.Contains("octa") || frame.Contains("octax"))
            {
                motors = new HIL.Motor[] {
            new Motor(0,    True,  1),
            new Motor(180,  True,  2),
            new Motor(45,   False, 3),
            new Motor(135,  False, 4),
            new Motor(-45,  False, 7),
            new Motor(-135, False, 8),
            new Motor(270,  True, 10),
            new Motor(90,   True, 11),
            };
                if (frame.Contains("octax"))
                {
                    foreach (int i in range(8))
                        motors[i].angle += 22.5;
                }
            }
            return motors;
        }