双向双路电调双流差速算法

这个很简单,就是直接使用油门+转向混合就好,超限的截掉,算法如下

     
                int esc1 =  thr-1500;   ///range -500->500
                int esc2 = esc1;      
                int diff = turn -1500;
                bool isTurnActive = (diff<-50 || diff > 50 );
                bool isThrActive  = (esc1 >50 || esc1 <-50);

                if(isThrActive|| isTurnActive )
                {
                    
                    esc2 = esc1 -diff;
                    esc1 = esc1 + diff;

                    LIMIT_TO(esc1,500,-500); ///range -500->500
                    LIMIT_TO(esc2,500,-500); ///range -500->500
   
                }
                else 
                {
                    esc1  = 0;
                    esc2  = 0;
                }

你可能感兴趣的:(算法,java,前端)