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


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

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


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

示例1: translation

    coredata::dmcp::ModuleExitCodeMessage::ModuleExitCode EgoController::body() {
        KeyValueConfiguration kvc = getKeyValueConfiguration();

        m_device = kvc.getValue<string>("egocontroller.device");
        transform(m_device.begin(), m_device.end(), m_device.begin(), ptr_fun(::tolower));

        string behaviorType = kvc.getValue<string>("egocontroller.behavior");
        transform(behaviorType.begin(), behaviorType.end(), behaviorType.begin(), ptr_fun(::tolower));

        ControlBehaviour* behaviour = NULL;
        if (behaviorType == "force") {
            cerr << "Using force control." << endl;
            behaviour = createForceControlBehaviour();
        } else if (behaviorType == "forcebicycle") {
            cerr << "Using bicycle control." << endl;
            behaviour = createForceControlBehaviourBicycleModel();
        } else if (behaviorType == "forcesimplifiedbicycle") {
            cerr << "Using simplified bicycle control." << endl;
            behaviour = createForceControlBehaviourSimplifiedBicycleModel();
        } else if (behaviorType == "simple") {
            cerr << "Using simple control." << endl;

            stringstream vehicleTranslation;
            vehicleTranslation << "egocontroller.start";
            Point3 translation(getKeyValueConfiguration().getValue<string>(vehicleTranslation.str()));

            stringstream vehicleRotZ;
            vehicleRotZ << "egocontroller.rotZ";
            const double rotZ = getKeyValueConfiguration().getValue<double>(vehicleRotZ.str());

            behaviour = new SimpleControlBehaviour(translation, rotZ);
        } else if (behaviorType == "linearbicyclenew") {
            behaviour = createLinearBicycleModelBehaviour();
        }

        if (behaviour == NULL) {
            cerr << "Cannot create control behavior " << behaviorType << endl;
            return coredata::dmcp::ModuleExitCodeMessage::SERIOUS_ERROR;
        }

        Controller* controller = NULL;
        if (m_device == "keyboard") {
            controller = new KeyboardController(*behaviour, 'w', 's','a','d','b');
        }
        else {
            // Try joystick.
            controller = new JoystickController(*behaviour, m_device);
        }

        if (controller == NULL) {
            cerr << "Cannot create controller for " << m_device << endl;
            return coredata::dmcp::ModuleExitCodeMessage::SERIOUS_ERROR;
        }


        while (getModuleStateAndWaitForRemainingTimeInTimeslice() == coredata::dmcp::ModuleStateMessage::RUNNING) {
            controller->doWork();

            Container container(Container::EGOSTATE, controller->getEgoState());
/*
        // Update internal data.
        m_vehicleData.setPosition(position);
        m_vehicleData.setHeading(m_heading);
        m_vehicleData.setVelocity(velocity);
        m_vehicleData.setSpeed(m_speed);
        m_vehicleData.setV_log(0);
        m_vehicleData.setV_batt(0);
        // For fake :-)
        m_vehicleData.setTemp(19.5 + cos(m_heading + m_deltaHeading));
        m_vehicleData.setRelTraveledPath(relDrivenPath);
//        const double FAULT = (1+(rand()%10)/300.0);
        const double FAULT = 1.0;
        m_vehicleData.setAbsTraveledPath(m_vehicleData.getAbsTraveledPath() + (relDrivenPath * FAULT));
//cerr << "FAULT: " << FAULT << ", tD: " << m_vehicleData.getAbsTraveledPath() << endl;
*/

            getConference().send(container);
        }

        return coredata::dmcp::ModuleExitCodeMessage::OKAY;
    }
开发者ID:TacoVox,项目名称:OpenDaVINCI,代码行数:81,代码来源:EgoController.cpp


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