当前位置: 首页>>代码示例>>C++>>正文


C++ Controller::calculate方法代码示例

本文整理汇总了C++中Controller::calculate方法的典型用法代码示例。如果您正苦于以下问题:C++ Controller::calculate方法的具体用法?C++ Controller::calculate怎么用?C++ Controller::calculate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controller的用法示例。


在下文中一共展示了Controller::calculate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestTwo

    /**-------------------------------------------------------------------------------
    	TestTwo

    	@brief
    	@return void
    ---------------------------------------------------------------------------------*/
    void TestTwo()
    {

        getSystemOutput(0,true);

        const double PIDexpected[]= {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0.150000000000000, 0.125000000000000, 0.180000000000000, 0.181250000000000, 0.224125000000000,
            0.238125000000000, 0.269793750000000, 0.287765625000000, 0.313890000000000, 0.333272656250000,
            0.356089640625000, 0.375405078125000, 0.396004611718750, 0.414652892578125, 0.433596977812500,
            0.451332337207031, 0.468919980533203, 0.485665133486328, 0.502073022043652, 0.517827056758057,
            0.533171873003359, 0.547967323187073, 0.562335600973608, 0.576218614296456, 0.589680782567980,
            0.602701939938742, 0.615319020792677, 0.627529166541620, 0.639356026890439, 0.650804430303555,
            0.661891412677581, 0.672625013940508, 0.683018802333854, 0.693081959202753, 0.702826080525318,
            0.712260543064563, 0.721395692081785, 0.730240678287689, 0.738804954326723, 0.747097267491099,
            0.755126364571985, 0.762900525053083, 0.770427895267497, 0.777716274199548, 0.784773273922038,
            0.791606223329374, 0.798222247036399, 0.804628224044169, 0.810830828247730, 0.816836512573039,
            0.822651531297221, 0.828281935886121, 0.833733588594279, 0.839012163573476, 0.844123156195273,
            0.849071886434885, 0.853863506007396, 0.858503002637217, 0.862995205997976, 0.867344792228484,
            0.871556289150349, 0.875634080741917, 0.879582411865564, 0.883405392574458, 0.887107002467577,
            0.890691094779930, 0.894161400429485, 0.897521531876399, 0.900774986900232, 0.903925152229540,
            0.906975307075183, 0.909928626538501, 0.912788184920152, 0.915556958917837, 0.918237830726655,
            0.920833591038189, 0.923346941946321, 0.925780499759464, 0.928136797724423, 0.930418288663157,
            0.932627347526255, 0.934766273865052, 0.936837294225467, 0.938842564465697, 0.940784172000429,
            0.942664137973737, 0.944484419363038, 0.946246911016228, 0.947953447624150, 0.949605805630448,
            0.951205705080773, 0.952754811413295, 0.954254737192366, 0.955707043787133, 0.957113242996879,
            0.958474798624742, 0.959793128001490, 0.961069603460905, 0.962305553768336, 0.963502265503901,
            0.964660984401760, 0.965782916646892, 0.966869230130682, 0.967921055666656, 0.968939488167622,
            0.969925587785427, 0.970880381014546, 0.971804861760619, 0.972699992375075, 0.973566704656904,
            0.974405900822628, 0.975218454445475, 0.976005211364738, 0.976766990566260, 0.977504585034977,
            0.978218762580379, 0.978910266635777, 0.979579817032188, 0.980228110747654, 0.980855822632771,
            0.981463606113189, 0.982052093869795, 0.982621898497321, 0.983173613142026, 0.983707812119147,
            0.984225051510732, 0.984725869744512, 0.985210788154374, 0.985680311523058, 0.986134928607620,
            0.986575112648200, 0.987001321860660, 0.987413999913564, 0.987813576390021, 0.988200467234868,
            0.988575075187653, 0.988937790201872, 0.989288989850895, 0.989629039721011, 0.989958293791987,
            0.990277094805546, 0.990585774622155, 0.990884654566476, 0.991174045761852, 0.991454249454179,
            0.991725557325491, 0.991988251797589, 0.992242606326033, 0.992488885684800, 0.992727346241905,
            0.992958236226268, 0.993181795986115, 0.993398258239167, 0.993607848314899, 0.993810784389090,
            0.994007277710945, 0.994197532822990, 0.994381747774000, 0.994560114325160, 0.994732818149676,
            0.994900039026059, 0.995061951025268, 0.995218722691909, 0.995370517219686, 0.995517492621281,
            0.995659801892836, 0.995797593173217, 0.995931009898225, 0.996060190949905, 0.996185270801115,
            0.996306379655514, 0.996423643583091, 0.996537184651406, 0.996647121052654, 0.996753567226702,
            0.996856633980214, 0.996956428601998, 0.997053054974690, 0.997146613682893, 0.997237202117879,
            0.997324914578972, 0.997409842371711, 0.997492073902894, 0.997571694772608, 0.997648787863332,
            0.997723433426221, 0.997795709164639, 0.997865690315046, 0.997933449725322, 0.997999057930590,
            0.998062583226649, 0.998124091741062, 0.998183647501997, 0.998241312504870, 0.998297146776892,
            0.998351208439545, 0.998403553769086, 0.998454237255136, 0.998503311657392, 0.998550828060553
        };

        double Kp = 0.1, Ti = 0.02, Td = 0.01;
        int type = 0;
        Controller<double>* controller = new ControllerPID(Kp, Ti, Td, 0);

        const float td=0.01f;
        double y=0;
        int i=0;

        for (float t=0.01f; t<3.0f; t+=td) {
            if (t<1) {
                controller->setSetpoint(0.0);
            } else {
                controller->setSetpoint(1.0);
            }

            controller->setInput(y);
            controller->calculate(0.01);
            double out;
            controller->getOutput(out);
            y=getSystemOutput(out);

            //CFIX_LOG(L"%d",i);
            CFIX_ASSERT(fabs(PIDexpected[i]-y)<1e-8);
            ++i;
        }

        delete controller;
    }
开发者ID:,项目名称:,代码行数:85,代码来源:


注:本文中的Controller::calculate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。