Exemple #1
0
        /*
         * V-Tail un-mixing
         * Take the data going to both tail servos and extract the orthogonal axes.
         * It is assumed that the mixed channels are ch1 and ch4
         * All other channels do not change
         */
        protected override IJoystickData Process(IJoystickData channels, int max, int min)
        {
            var inData  = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            var outData = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            // Copy input data to input buffer
            for (var i = 0; i < 6; i++)
            {
                inData[i] = channels.Data[i];
            }

            if (channels.Count >= 4)
            {
                var rudder   = (max - min) / 2 + (inData[0] - inData[3]) / 4;
                var elevator = (inData[0] + inData[3]) / 2;

                outData[0]  = elevator;
                outData[1]  = inData[1];
                outData[2]  = inData[2];
                outData[3]  = rudder;
                outData[4]  = inData[4];
                outData[5]  = inData[5];
                outData[6]  = inData[6];
                outData[7]  = inData[7];
                outData[8]  = inData[8];
                outData[9]  = inData[9];
                outData[10] = inData[10];
                outData[11] = inData[11];
            }

            return(new JoystickData(channels.Count, outData));
        }
Exemple #2
0
        /*
         * Contributed by by Joseph Congiundi
         *
         * Convert E-Sky CCPM 6 channel signal into 4 orthogonal channels
         *
         * CCPM operation:
         * Rudder:	Independent channel.
         * Pitch:	Obtained by Front servo going up (or down) while both rear servos going down (or up).
         *      Rear servos travel at 50% rate of the front servo.
         *      Elevator stick throw obtained from Front servo channel.
         * Roll:	Obtained by one rear servo going up and one rear servo going down.
         *      Aileron throw obtained from a Rear servo channel with the reduction of the Pitch element.
         * Power:	Throttle stick throw obtained from Power channel.
         *      When power channel in in the Mid to Max range, it also a Rear servo and the Front servo
         *
         * Input 6 channels are -
         * Channel 1 (inData[0]) - Rear servo 1
         * Channel 2 (inData[1]) - Front servo
         * Channel 3 (inData[2]) - Power
         * Channel 4 (inData[3]) - Rudder
         * Channel 5 (inData[4]) - Not used
         * Channel 6 (inData[6]) - Rear servo 2
         *
         * Output 4 channes are -
         * Channel 1 (outData[0]) - Rudder
         * Channel 2 (outData[1]) - Throttle
         * Channel 3 (outData[2]) - Elevator
         * Channel 4 (outData[3]) - Ailerons
         *
         * Input:
         *  channels		Pointer to structure containing CCPM channel data
         *  channels.Count	Number of input channels (only the first 6 are relevant)
         *  channels.Data[]	Array of channel values
         *  min				Minimum possible CCPM channel value
         *  max				Maximum possible CCPM channel value
         *
         * Return:
         *  Pointer to structure containing orthogonal channel data (4ch)
         *
         */
        protected override IJoystickData Process(IJoystickData channels, int max, int min)
        {
            var inData  = new[] { 0, 0, 0, 0, 0, 0 };
            var outData = new[] { 0, 0, 0, 0, 0, 0, 0, 0 };

            // Copy input data to input buffer
            for (var i = 0; i < 6; i++)
            {
                inData[i] = channels.Data[i];
            }

            // Rudder
            outData[0] = inData[3];

            // Throttle = Power channel
            outData[1] = inData[2];

            // Elevator: Front servo (Pitch correction when power above mid-point)
            outData[2] = inData[1] - (int)(.35 * inData[2]);

            // Ailerons: Rear servo minus pitch effect (roll correction when power above mid-point)
            outData[3] = (int)(max / 2 + inData[0] + .5 * inData[1] - .53 * inData[2]);

            return(new JoystickData(4, outData));
        }
Exemple #3
0
        /*
         *  Delta wing un-mixing
         *  Take the data going to both wing servos and extract the orthogonal axes.
         *  No rudder.
         *  It is assumed that the mixed channels are ch1 and ch2
         *  All other channels do not change
         */
        protected override IJoystickData Process(IJoystickData channels, int max, int min)
        {
            // Copy input data to input buffer
            for (var i = 0; i < 6; i++)
            {
                InData[i] = channels.Data[i];
            }

            if (channels.Count >= 2)
            {
                var ailerons = (max - min) / 2 + (InData[0] - InData[1]) / 4;
                var elevator = (InData[0] + InData[1]) / 2;

                OutData[0]  = elevator;
                OutData[1]  = ailerons;
                OutData[2]  = InData[2];
                OutData[3]  = InData[3];
                OutData[4]  = InData[4];
                OutData[5]  = InData[5];
                OutData[6]  = InData[6];
                OutData[7]  = InData[7];
                OutData[8]  = InData[8];
                OutData[9]  = InData[9];
                OutData[10] = InData[10];
                OutData[11] = InData[11];
            }

            return(new JoystickData(channels.Count, OutData));
        }
Exemple #4
0
        /*
         * Contributed by Matthew Morrison
         *
         * Convert E-Sky CCPM 6 channel signal into 4 orthogonal channels and a 5th for blade pitch
         *
         * CCPM operation:
         * Rudder: Independent channel.
         * Elevator: Obtained by Front servo going up (or down) while both rear servos going down (or up).
         * Roll: Obtained by one rear servo going up and one rear servo going down.
         * Power: Throttle stick throw obtained from Power channel.
         * Input 6 channels are -
         * Channel 1 (inData[0]) - Rear servo 1
         * Channel 2 (inData[1]) - Front servo
         * Channel 3 (inData[2]) - Power
         * Channel 4 (inData[3]) - Rudder
         * Channel 5 (inData[4]) - Not used
         * Channel 6 (inData[6]) - Rear servo 2
         *
         * Output 5 channels are -
         * Channel 1 (outData[0]) - Rudder
         * Channel 2 (outData[1]) - Throttle
         * Channel 3 (outData[2]) - Elevator
         * Channel 4 (outData[3]) - Ailerons
         * Channel 5 (outData[4]) - Pitch
         *
         * Input:
         *  channels Pointer to structure containing CCPM channel data
         *  channels.Count Number of input channels (only the first 6 are relevant)
         *  channels.Data[] Array of channel values
         *  min Minimum possible CCPM channel value
         *  max Maximum possible CCPM channel value
         *
         * Return:
         *  Pointer to structure containing orthogonal channel data (5ch)
         *
         */
        protected override IJoystickData Process(IJoystickData channels, int max, int min)
        {
            var inData  = new[] { 0, 0, 0, 0, 0, 0 };
            var outData = new[] { 0, 0, 0, 0, 0, 0, 0, 0 };

            var servo0 = max - inData[0]; // Servo 0 needs to be inverted

            // Copy input data to input buffer
            for (var i = 0; i < 6; i++)
            {
                inData[i] = channels.Data[i];
            }

            // Rudder
            outData[0] = inData[3];

            // Throttle = Power channel
            outData[1] = inData[2];

            // Pitch: average of all servos compared to the max
            outData[4] = (int)(servo0 + inData[5] + inData[1]) / 3;

            // Roll: the difference between the rear servos compared to the midpoint
            outData[3] = (max / 2 + inData[5] - servo0) / 2;

            // Elevator: the difference between the front servo and the mean of the rear servos
            outData[2] = max / 2 + (inData[1] - (servo0 + inData[5]) / 2) / 2;

            return(new JoystickData(5, outData));
        }
Exemple #5
0
        /*
         * NULL Filter
         */
        protected override IJoystickData Process(IJoystickData channels, int max, int min)
        {
            var inData  = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            var outData = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            // Copy input data to input buffer
            var limit = 12;

            if (channels.Count < limit)
            {
                limit = channels.Count;
            }

            for (var i = 0; i < limit; i++)
            {
                outData[i] = channels.Data[i];
            }

            return(new JoystickData(channels.Count, outData));
        }
Exemple #6
0
 protected abstract IJoystickData Process(IJoystickData channels, int max, int min);