• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ boost::timer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中boost::timer的典型用法代码示例。如果您正苦于以下问题:C++ timer类的具体用法?C++ timer怎么用?C++ timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: OnTimer

void CMainDlg::OnTimer(UINT_PTR nIDEvent)
{
	if (nIDEvent == 1 && gStop)
	{
		static boost::timer tmr;
		// 延迟3秒关闭
		if (tmr.elapsed() > 3)
		{
			// 检测关闭
			trayIcon.Hide();
			CloseDialog(0);
			TerminateProcess(GetCurrentProcess(), 0);
		}
	}
	else if (nIDEvent == 2 && exiting && !gStop)
	{
		static int times = 0;
		if (times < 3)
		{
			times++;
			// L"正在退出太一,请稍候.."
			trayIcon.SetBalloonDetails(GetLocalWStr(strTrayNowExiting), L"", CTrayNotifyIcon::None, 100);
		}
	}
	else
	{
		SetMsgHandled(false);
	}
}
开发者ID:lcfGitHubCode,项目名称:TaiyiCode,代码行数:29,代码来源:MainDlg.cpp


示例2: wait_idle_time

 void Reconstruct::wait_idle_time( boost::timer& timer, int idle_time )
 {
     timer.restart( );
     while( boost::posix_time::seconds( timer.elapsed( ) ) < boost::posix_time::milliseconds( idle_time ) && !m_abort_scan )
     {
         boost::this_thread::sleep( boost::posix_time::milliseconds( 1 ) );
         QApplication::processEvents( );
     }
 }
开发者ID:Gombat,项目名称:bla3Dscan,代码行数:9,代码来源:reconstruct.cpp


示例3: sufficient_time

bool sufficient_time()
{
   // return true if enough time has passed since the tests began:
   static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT ;
   boost::static_mutex::scoped_lock guard(mut);
   static boost::timer t;
   // is 10 seconds enough?
   return t.elapsed() >= 10.0;
}
开发者ID:hoangphihung0604,项目名称:boost,代码行数:9,代码来源:static_mutex_test.cpp


示例4: send

	virtual boost::unique_future<bool> send(const safe_ptr<core::read_frame>& frame) override
	{
		CASPAR_VERIFY(format_desc_.height * format_desc_.width * 4 == static_cast<unsigned>(frame->image_data().size()));

		return executor_.begin_invoke([=]() -> bool
		{			
			graph_->set_value("tick-time", tick_timer_.elapsed() * format_desc_.fps * 0.5);
			tick_timer_.restart();
			frame_timer_.restart();

			// AUDIO

			std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_buffer;

			if (core::needs_rearranging(
					frame->multichannel_view(),
					channel_layout_,
					channel_layout_.num_channels))
			{
				core::audio_buffer downmixed;

				downmixed.resize(
						frame->multichannel_view().num_samples() 
								* channel_layout_.num_channels,
						0);

				auto dest_view = core::make_multichannel_view<int32_t>(
						downmixed.begin(), downmixed.end(), channel_layout_);

				core::rearrange_or_rearrange_and_mix(
						frame->multichannel_view(),
						dest_view,
						core::default_mix_config_repository());

				audio_buffer = core::audio_32_to_16(downmixed);
			}
			else
			{
				audio_buffer = core::audio_32_to_16(frame->audio_data());
			}

			airsend::add_audio(air_send_.get(), audio_buffer.data(), audio_buffer.size() / channel_layout_.num_channels);

			// VIDEO

			connected_ = airsend::add_frame_bgra(air_send_.get(), frame->image_data().begin());

			graph_->set_text(print());
			graph_->set_value("frame-time", frame_timer_.elapsed() * format_desc_.fps * 0.5);
			
			return true;
		});
	}
开发者ID:GamingAtheist,项目名称:Server,代码行数:53,代码来源:newtek_ivga_consumer.cpp


示例5: get_and_record_age_millis

	int64_t get_and_record_age_millis()
	{
		if (recorded_frame_age_ == -1)
			recorded_frame_age_ = static_cast<int64_t>(
					since_created_timer_.elapsed() * 1000.0);

		return recorded_frame_age_;
	}
开发者ID:AKinanS,项目名称:Server,代码行数:8,代码来源:write_frame.cpp


示例6: OnGetData

	virtual bool OnGetData(sf::SoundStream::Chunk& data) override
	{		
		win32_exception::ensure_handler_installed_for_thread(
				"sfml-audio-thread");
		std::pair<std::shared_ptr<core::read_frame>, std::shared_ptr<audio_buffer_16>> audio_data;

		input_.pop(audio_data); // Block until available

		graph_->set_value("tick-time", perf_timer_.elapsed()*format_desc_.fps*0.5);		
		perf_timer_.restart();

		container_.push_back(std::move(*audio_data.second));
		data.Samples = container_.back().data();
		data.NbSamples = container_.back().size();	
		

		if (audio_data.first)
			presentation_age_ = audio_data.first->get_age_millis();

		return is_running_;
	}
开发者ID:AurelienRevault,项目名称:Caspar-Server,代码行数:21,代码来源:oal_consumer.cpp


示例7: run_test

void run_test(int NUM_TESTS, std::vector<int> NUM_POINTS, std::vector<int> NUM_RUNS) {
    for (int i = 0; i < NUM_TESTS; ++i) {

        kdtree::KDTree<Point> tr(2);
        for(int k=0; k<NUM_POINTS[i]; k++) {
            double x = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            double y = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            Point p(x,y);
            tr.insert( p );
        }
    
        timer.restart();
        for (int j = 0; j < NUM_RUNS[i]; ++j) {
            double x = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            double y = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            Point ps(x,y);
            std::pair<Point,double> pt = tr.nearest( ps );
        }
        double total_time = timer.elapsed();
        double time_per_test = total_time / NUM_RUNS[i];
        format_line(NUM_POINTS[i], NUM_RUNS[i], total_time, time_per_test);
    }
}
开发者ID:aewallin,项目名称:sandbox,代码行数:23,代码来源:bench.cpp


示例8: Execute

std::string StartGate::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState) << "\tTime: " << _timestamp.elapsed() << std::endl;
    std::cout << std::endl;

    bool pathExists = false;
    std::vector<Path> paths;

    switch (mState)
    {
        case GoToDepth:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;

            if(fabs(AI::Utility::DepthDiff(mCurrentDepth, mInitDepth)) < mDepthThresh && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mStartYaw)) <= mYawThresh)
            {

                mInitTravel.Start();
                mState = InitTravel;
            }

            break;

        case InitTravel:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;
            mDesiredAxialThrust = mInitTravelSpeed;

            if(mInitTravel.IsFinished())
            {
                mPathTravel.Start();
                mState = PathTravel;
            }

            std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
            std::cout << "Timer:"
                      << "\t" << mInitTravel.GetRunTime()
                      << "\t" << mInitTravel.TimeElapsed()
                      << "\t" << mInitTravel.GetRunTime()-mInitTravel.TimeElapsed()
                      << std::endl;

            break;

        case PathTravel:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;
            mDesiredAxialThrust = mPathTravelSpeed;

            pathExists = GetPaths(paths , mCurrentYaw, mDWFrame, mDWProcFrame);


            if(mPathTravel.IsFinished() || pathExists == true)
            {
                mState = LeaveMission;
            }

            std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
            std::cout << "Timer:"
                      << "\t" << mPathTravel.GetRunTime()
                      << "\t" << mPathTravel.TimeElapsed()
                      << "\t" << mPathTravel.GetRunTime()-mPathTravel.TimeElapsed()
                      << std::endl;

            break;

        case LeaveMission:

            if(mLeaveMission == false)
            {
                mGlobalInfo->SetInfo(GlobalInfo::FixedYaw,mStartYaw);
                //mGlobalInfo->SetInfo(GlobalInfo::StartYaw,mStartYaw);
                Utility::Display::CloseAllWindows();
                mLeaveMission = true;
            }

            return NextMission;

            break;

        default:

            std::cout << "ERROR::" << ID << " state " << mState << " does not exist!" << std::endl;

            break;

    }

    //if (mState == PathTravel)
    {
        AI::Utility::HeadingDisplay(mDWProcFrame, mCurrentYaw, mDesiredYaw, 0, 255, 255);
        AI::Utility::DepthDisplay(mDWProcFrame, mCurrentDepth, mDesiredDepth, 0, 192);
        AI::Utility::ThrustDisplay(mDWProcFrame, mDesiredAxialThrust, mDesiredLateralThrust);

        Utility::Display::DisplayImage("DW Frame",mDWFrame);
        Utility::Display::DisplayImage("Processed DW Frame",mDWProcFrame);
//.........这里部分代码省略.........
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:101,代码来源:startgate.cpp


示例9: timeElapsed

void timeElapsed(const boost::timer &time){
  cout<<"finished in "<<floor(time.elapsed()/60)<<"min "
      <<fmod(time.elapsed(),60) <<"s"<<endl;
}
开发者ID:anguoyang,项目名称:face-thief,代码行数:4,代码来源:Detector.cpp


示例10: VideoInputFrameArrived

	virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame* video, IDeckLinkAudioInputPacket* audio)
	{	
		if(!video)
			return S_OK;

		try
		{
			graph_->set_value("tick-time", tick_timer_.elapsed()*format_desc_.fps*0.5);
			tick_timer_.restart();

			frame_timer_.restart();

			// PUSH

			void* bytes = nullptr;
			if(FAILED(video->GetBytes(&bytes)) || !bytes)
				return S_OK;
			
			safe_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);	
			avcodec_get_frame_defaults(av_frame.get());
						
			av_frame->data[0]			= reinterpret_cast<uint8_t*>(bytes);
			av_frame->linesize[0]		= video->GetRowBytes();			
			av_frame->format			= PIX_FMT_UYVY422;
			av_frame->width				= video->GetWidth();
			av_frame->height			= video->GetHeight();
			av_frame->interlaced_frame	= format_desc_.field_mode != core::field_mode::progressive;
			av_frame->top_field_first	= format_desc_.field_mode == core::field_mode::upper ? 1 : 0;
				
			std::shared_ptr<core::audio_buffer> audio_buffer;

			// It is assumed that audio is always equal or ahead of video.
			if(audio && SUCCEEDED(audio->GetBytes(&bytes)) && bytes)
			{
				auto sample_frame_count = audio->GetSampleFrameCount();
				auto audio_data = reinterpret_cast<int32_t*>(bytes);
				audio_buffer = std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels);
			}
			else			
				audio_buffer = std::make_shared<core::audio_buffer>(audio_cadence_.front(), 0);
			
			// Note: Uses 1 step rotated cadence for 1001 modes (1602, 1602, 1601, 1602, 1601)
			// This cadence fills the audio mixer most optimally.

			sync_buffer_.push_back(audio_buffer->size());		
			if(!boost::range::equal(sync_buffer_, audio_cadence_))
			{
				CASPAR_LOG(trace) << print() << L" Syncing audio.";
				return S_OK;
			}

			muxer_.push(audio_buffer);
			muxer_.push(av_frame, hints_);	
											
			boost::range::rotate(audio_cadence_, std::begin(audio_cadence_)+1);
			
			// POLL
			
			for(auto frame = muxer_.poll(); frame; frame = muxer_.poll())
			{
				if(!frame_buffer_.try_push(make_safe_ptr(frame)))
				{
					auto dummy = core::basic_frame::empty();
					frame_buffer_.try_pop(dummy);

					frame_buffer_.try_push(make_safe_ptr(frame));

					graph_->set_tag("dropped-frame");
				}
			}

			graph_->set_value("frame-time", frame_timer_.elapsed()*format_desc_.fps*0.5);

			graph_->set_value("output-buffer", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));	
		}
		catch(...)
		{
			exception_ = std::current_exception();
			return E_FAIL;
		}

		return S_OK;
	}
开发者ID:Mistobaan,项目名称:CasparCG,代码行数:83,代码来源:decklink_producer.cpp


示例11:

            ~bench_no_lock() {
			    threads.join_all();
                std::cerr << "bench_no_lock: x = " << x << ", elapsed time is " << timer.elapsed()
                          << "\n";
		    }
开发者ID:drednout,项目名称:cpp_bench,代码行数:5,代码来源:main.cpp


示例12: Execute

std::string EtTuBrute::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState) << "\tTime: " << _timestamp.elapsed() << " " << mStateTimeout.TimeElapsed() << std::endl;
    std::cout << std::endl;

    bool pathExists = false;
    std::vector<Path> paths;

    switch (mState)
    {
        // Go to Path Depth, leave immediatley if path is found
        case GoToPathDepth:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;
            mDesiredAxialThrust = 0;
            mDesiredLateralThrust = 0;

            pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);


            if((fabs(AI::Utility::DepthDiff(mCurrentDepth, mPathDepth)) < mDepthThresh
                && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mFixedYaw)) <= mYawThresh))
                // Add a check if the path is seen to go directly to path found ... || )
            {

                mPathSearchTimer.Start();
                InitSearch();
                mState = PathSearch;
            }

            break;

        //Search for a path, if found center, if not timeout and look at buoys
        case PathSearch:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;
            mDesiredAxialThrust = 0;
            mDesiredLateralThrust = 0;

            pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            //Add some kind of debouncing to get here, in fetch probably
            if(pathExists)
            {
                mState = DoPath;
            }
            else if(mPathSearchTimer.IsFinished())
            {
                mState = GoToObstacleDepth;
            }
            else
            {
                SearchStep();
                //mPathSearchPattern.SearchStep(mDesiredLateralThrust, mDesiredAxialThrust);
            }

            std::cout << "Number of Paths: " << paths.size() << std::endl;

            std::cout << "Timer:"
                      << "\t" << mPathSearchTimer.GetRunTime()
                      << "\t" << mPathSearchTimer.TimeElapsed()
                      << "\t" << mPathSearchTimer.GetRunTime()-mPathSearchTimer.TimeElapsed()
                      << std::endl;

            break;

        //center in on a path
        case DoPath:

            //Don't debounce in DoPath
            GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            if(paths.size()>0)
            {
                //if path is found change thrust
                if(mPathCenteredDebounce.Bounce(mPathFinder.StepPath(&paths[0], mCurrentYaw, mDesiredYaw, mDesiredAxialThrust, mDesiredLateralThrust)))
                {

                    mPathTimer.Initialize(mPathExitTime);
                    mPathTimer.Start();
                    //mFixedYaw = mDesiredYaw;
                    //mDesiredYaw = paths[0].mAngle;
                    mGlobalInfo->SetInfo(GlobalInfo::FixedYaw, mDesiredYaw);

                    cvCircle(mDWProcFrame, cvPoint(mDWProcFrame->width/2,mDWProcFrame->height/2), 200, cvScalar(0,255,0), 4);

                    mState = ExitPath;
                }
                else
                {
                    std::cout << "NOT CENTERED SEEN" << std::endl;
                    //mPathCenteredDebounce.Miss();
                }

                std::cout << "PATHS SEEN" << std::endl;
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:101,代码来源:ettubrute.cpp


示例13: Execute

std::string SimpleStartGate::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState)<< "\tTime: " << _timestamp.elapsed() << std::endl;
    std::cout << std::endl;


    switch (mState)
    {
        case GoToDepth:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mStartDepth;
            
            if(fabs(AI::Utility::DepthDiff(mCurrentDepth, mStartDepth)) < mDepthThresh && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mStartYaw)) <= mYawThresh)
            {
                mState = ThroughGate;
                mStopWatch.Start();
            }

            break;
        
        case ThroughGate:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mStartDepth;
            mDesiredAxialThrust = mGateSpeed;
            
            if(mStopWatch.IsFinished())
            {
                mState = LeaveMission;
            }

            std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
            //std::cout << std::endl;
            std::cout << "Timer:"
                      << "\t" << mStopWatch.GetRunTime()
                      << "\t" << mStopWatch.TimeElapsed()
                      << "\t" << mStopWatch.GetRunTime()-mStopWatch.TimeElapsed()
                      << std::endl;

            break;
        
        case LeaveMission:

            return NextMission;

    }

    std::cout << std::endl;
    std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
    //std::cout << std::endl;
    std::cout << "Yaw:"
              << "\t" << mDesiredYaw
              << "\t" << mCurrentYaw
              << "\t" << Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mDesiredYaw)
              << std::endl;
    std::cout << "Pitch:"
              << "\t" << mDesiredPitch
              << "\t" << mCurrentPitch
              << "\t" << Zebulon::AI::Utility::AngleDiff(mCurrentPitch, mDesiredPitch)
              << std::endl;
    std::cout << "Roll:"
              << "\t" << mDesiredRoll
              << "\t" << mCurrentRoll
              << "\t" << Zebulon::AI::Utility::AngleDiff(mCurrentRoll, mDesiredRoll)
              << std::endl;
    std::cout << "Depth:"
              << "\t" << mDesiredDepth
              << "\t" << mCurrentDepth
              << "\t" << Zebulon::AI::Utility::AngleDiff(mCurrentDepth, mDesiredDepth)
              << std::endl;
    std::cout << std::endl;
    std::cout << "Forward:"
              << "\t" << mDesiredAxialThrust
              << std::endl;
    std::cout << "Lateral:"
              << "\t" << mDesiredLateralThrust
              << std::endl;
    
    mGlobalCommand->SetDesiredPitch(mDesiredPitch);
    mGlobalCommand->SetDesiredRoll(mDesiredRoll);
    mGlobalCommand->SetDesiredYaw(mDesiredYaw);

    mGlobalCommand->SetDesiredAxialVel(mDesiredAxialThrust);
    mGlobalCommand->SetDesiredLateralVel(mDesiredLateralThrust);
    mGlobalCommand->SetDesiredDepth(mDesiredDepth);
    
    return "KeepRunning";
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:91,代码来源:simplestartgate.cpp


示例14: reportStart

 virtual void reportStart() {
     timer.restart();
     customStart();
 }
开发者ID:n-sreek,项目名称:trayRacer2,代码行数:4,代码来源:renderobserver.hpp


示例15: main

int main(int argc, char **argv)
{
    std::string environment_uri;
    std::string robot_name;
    std::string plugin_name;
    size_t num_trials;
    bool self = false;
    bool profile = false;

    // Parse arguments.
    po::options_description desc("Profile OpenRAVE's memory usage.");
    desc.add_options()
        ("num-samples", po::value<size_t>(&num_trials)->default_value(10000),
            "number of samples to run")
        ("self", po::value<bool>(&self)->zero_tokens(),
            "run self-collision checks")
        ("profile", po::value<bool>(&profile)->zero_tokens(),
            "remove objects from environment")
        ("environment_uri",
            po::value<std::string>(&environment_uri)->required(),
            "number of samples to run")
        ("robot", po::value<std::string>(&robot_name)->required(),
            "robot_name")
        ("collision_checker",
            po::value<std::string>(&plugin_name)->required(),
            "collision checker name")
        ("help",
            "print usage information")
        ;

    po::positional_options_description pd;
    pd.add("environment_uri", 1);
    pd.add("robot", 1);
    pd.add("collision_checker", 1);

    po::variables_map vm;
    po::store(
        po::command_line_parser(argc, argv)
            .options(desc)
            .positional(pd).run(),
        vm
    );
    po::notify(vm);    

    if (vm.count("help")) {
        std::cout << desc << std::endl;
        return 1;
    }

    // Create the OpenRAVE environment.
    RaveInitialize(true);

    EnvironmentBasePtr const env = RaveCreateEnvironment();
    CollisionCheckerBasePtr const collision_checker
            = RaveCreateCollisionChecker(env, plugin_name);
    env->SetCollisionChecker(collision_checker);

    env->StopSimulation();

    // "/usr/share/openrave-0.9/data/wamtest1.env.xml"
    env->Load(environment_uri);
    KinBodyPtr const body = env->GetKinBody(robot_name);

    // Generate random configuations.
    std::vector<OpenRAVE::dReal> lower;
    std::vector<OpenRAVE::dReal> upper;
    body->GetDOFLimits(lower, upper);
	std::vector<std::vector<double> > data;
    data = benchmarks::DataUtils::GenerateRandomConfigurations(
            num_trials, lower, upper);

    //
    RAVELOG_INFO("Running %d collision checks.\n", num_trials);

    boost::timer const timer;
    if (profile) {
        std::string const prof_name = str(
                format("CheckCollision.%s.prof") %  plugin_name);
        RAVELOG_INFO("Writing gperftools information to '%s'.\n",
            prof_name.c_str()
        );

        ProfilerStart(prof_name.c_str());
    }

    size_t num_collision = 0;
    for (size_t i = 0; i < num_trials; ++i) {
        body->SetDOFValues(data[i]);

        bool is_collision;
        if (self) {
            is_collision = body->CheckSelfCollision();
        } else {
            is_collision = env->CheckCollision(body);
        }
        num_collision += !!is_collision;
    }

    if (profile) {
        ProfilerStop();
//.........这里部分代码省略.........
开发者ID:cdellin,项目名称:or_benchmarks,代码行数:101,代码来源:run_benchmark.cpp


示例16: stop

 void stop() { elapsed_ = timer_.elapsed(); }
开发者ID:BGC-nglass,项目名称:quantlib,代码行数:1,代码来源:Gaussian1dModels.cpp


示例17: Execute

std::string Training::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState) << "\tTime: " << _timestamp.elapsed() << std::endl;
    std::cout << std::endl;

    bool pathExists = false;
    std::vector<Path> paths;

    switch (mState)
    {
        // Go to Path Depth, leave immediatley if path is found
        case GoToPathDepth:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;
            mDesiredAxialThrust = 0;
            mDesiredLateralThrust = 0;

            //pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            /*if(pathExists)
            {

            }*/

            if((fabs(AI::Utility::DepthDiff(mCurrentDepth, mPathDepth)) < mDepthThresh
                && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mFixedYaw)) <= mYawThresh))
                // Add a check if the path is seen to go directly to path found ... || )
            {

                mPathSearchTimer.Start();
                mState = PathSearch;
            }

            break;

        //Search for a path, if found center, if not timeout and look at buoys
        case PathSearch:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;

            pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            //Add some kind of debouncing to get here, in fetch probably
            if(pathExists)
            {
                mState = DoPath;
            }
            else if(mPathSearchTimer.IsFinished())
            {
                mState = BuoySearch;
            }
            else
            {
                mPathSearchPattern.SearchStep(mDesiredLateralThrust, mDesiredAxialThrust);
            }

            std::cout << "Number of Paths: " << paths.size() << std::endl;

            std::cout << "Timer:"
                      << "\t" << mPathSearchTimer.GetRunTime()
                      << "\t" << mPathSearchTimer.TimeElapsed()
                      << "\t" << mPathSearchTimer.GetRunTime()-mPathSearchTimer.TimeElapsed()
                      << std::endl;

            break;

        //center in on a path
        case DoPath:

            //Don't debounce in DoPath
            GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            if(paths.size()>0)
            {
                //if path is found change thrust
                if(mPathCenteredDebounce.Bounce(mPathFinder.StepPath(&paths[0], mCurrentYaw, mDesiredYaw, mDesiredAxialThrust, mDesiredLateralThrust)))
                {

                    mPathTimer.Initialize(mPathExitTime);
                    mPathTimer.Start();
                    //mFixedYaw = mDesiredYaw;
                    //mDesiredYaw = paths[0].mAngle;
                    mGlobalInfo->SetInfo(GlobalInfo::FixedYaw, mDesiredYaw); // should be current yaw

                    cvCircle(mDWProcFrame, cvPoint(mDWProcFrame->width/2,mDWProcFrame->height/2), 200, cvScalar(0,255,0), 4);

                    mState = ExitPath;
                }
                else
                {
                    std::cout << "NOT CENTERED SEEN" << std::endl;
                    //mPathCenteredDebounce.Miss();
                }

                std::cout << "PATHS SEEN" << std::endl;
            }
            else
            {
                //can't be centered if didn't see it
//.........这里部分代码省略.........
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:101,代码来源:training.cpp


示例18: route

		/// \brief Primary route call.
		void route(RouteNet& inNet) {
			mRouteTimer.restart();
			routeNet(inNet);
			double routeTime = mRouteTimer.elapsed();
			mTotalRouteTime += routeTime;
			inNet.mProperties[eRouteTime] = routeTime;
		}
开发者ID:torc-isi,项目名称:torc,代码行数:8,代码来源:NetRouterBase.hpp


示例19: testQuickSort

float testQuickSort(int vectorSize, int numberOfIterations)
{
	vector<int> quick;
	quick.reserve(vectorSize);
	float elapsedTime = 0;

	for (int iterations = 0; iterations < numberOfIterations; ++iterations)
	{
		quick = fillVectorWithRandomInts(quick.size());
		testTimer.restart();
		quick = sorter.quickSort(quick);
		elapsedTime += testTimer.elapsed();
	}
	return (elapsedTime / numberOfIterations);
}
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:15,代码来源:Driver.cpp


示例20: testInsertionSort

float testInsertionSort(int vectorSize, int numberOfIterations)
{
	vector<int> insertion;
	insertion.reserve(vectorSize);
	float elapsedTime = 0;

	for (int iterations = 0; iterations < numberOfIterations; ++iterations)
	{
		insertion = fillVectorWithRandomInts(insertion.size());
		testTimer.restart();
		insertion = sorter.insertionSort(insertion);
		elapsedTime += testTimer.elapsed();
	}
	return (elapsedTime / numberOfIterations);
}
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:15,代码来源:Driver.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ boost::unique_lock类代码示例发布时间:2022-05-31
下一篇:
C++ boost::timed_mutex类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap