コード例 #1
0
        //------ Access motor controller  ----------//

        //------ Set output routines. ----------//
        public void BalanceSet(Styles.AdvancedStyle driveStyle, float forward, float turn)
        {
            /* calc the left and right demand */
            float l, r;

            Util.Split_1(forward, turn, out l, out r);
            if (l > 1)
            {
                //Left side is saturated +, beef up right side by remainder amount
                r += (l - 1);
            }
            else if (r > 1)
            {
                //Right side is saturated +, beef up left side by remainder
                l += (r - 1);
            }
            else if (l < -1)
            {
                //Left side is saturated -, beef up right side by remainder
                r += (l + 1);
            }
            else if (r < -1)
            {
                //Right side is saturated -, beef up left side by remainder
                l += (r + 1);
            }

            /* apply it */
            _left.Set(ControlMode.PercentOutput, l);
            _right.Set(ControlMode.PercentOutput, r);
        }
コード例 #2
0
        //------ Access motor controller  ----------//

        //------ Set output routines. ----------//
        public void Set(Styles.AdvancedStyle driveStyle, float forward, float turn)
        {
            /* calc the left and right demand */
            float l, r;

            Util.Split_1(forward, turn, out l, out r);
            /* lookup control mode to match caller's selected style */
            ControlMode cm = Styles.Routines.LookupCM(driveStyle);

            /* apply it */
            _left.Set(cm, l);
            _right.Set(cm, r);
        }