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


C++ Timestamp::setToNow方法代码示例

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


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

示例1: addArtificialNoise

void PTrackerROS::addArtificialNoise(vector<ObjectSensorReading::Observation>& obs)
{
	/// Adding Gaussian noise to observations.
	if (isGaussianNoise)
	{
		for (vector<ObjectSensorReading::Observation>::iterator it = obs.begin(); it != obs.end(); ++it)
		{
			it->observation.x += gaussianNoise(gaussianNoiseX,0.3);
			it->observation.y += gaussianNoise(gaussianNoiseY,0.3);
		}
	}
	
	/// Adding false positive observations for a burst period of time equals to falsePositiveBurstTime.
	if ((falsePositiveBurstTime > 0.0) && (falsePositiveObservations > 0))
	{
		static const int TIME_TO_WAIT_BEFORE_NEXT_BURST = 10000 - falsePositiveBurstTime;
		
		static vector<ObjectSensorReading::Observation> falseObservations;
		static Timestamp initialTimestamp, initialTimestampBurst;
		static bool isBurstTime = false, isGenerationTime = true;
		
		if (isBurstTime)
		{
			if ((Timestamp() - initialTimestampBurst).getMs() < falsePositiveBurstTime)
			{
				if (isGenerationTime)
				{
					falseObservations.clear();
					
					isGenerationTime = false;
					
					for (int i = 1; i <= falsePositiveObservations; ++i)
					{
						ObjectSensorReading::Observation falseObservation;
						
						falseObservation.observation.x = Utils::randr(worldSizeX);
						falseObservation.observation.y = Utils::randr(worldSizeY);
						falseObservation.head.x = falseObservation.observation.x;
						falseObservation.head.y = falseObservation.observation.y;
						falseObservation.model.barycenter = falseObservation.observation.x;
						
						falseObservations.push_back(falseObservation);
					}
				}
				
				for (vector<ObjectSensorReading::Observation>::const_iterator it = falseObservations.begin(); it != falseObservations.end(); ++it)
				{
					ObjectSensorReading::Observation falseObservation;
					
					falseObservation.observation.x = it->observation.x + gaussianNoise(gaussianNoiseX,0.3);
					falseObservation.observation.y = it->observation.y + gaussianNoise(gaussianNoiseY,0.3);
					
					obs.push_back(falseObservation);
				}
			}
			else
			{
				initialTimestamp.setToNow();
				isBurstTime = false;
			}
		}
		else
		{
			if ((TIME_TO_WAIT_BEFORE_NEXT_BURST - (Timestamp() - initialTimestamp).getMs()) < 0.0)
			{
				initialTimestampBurst.setToNow();
				isBurstTime = true;
				isGenerationTime = true;
			}
		}
	}
	
	if (strcasecmp(distortion.c_str(),"none") != 0)
	{
		Point2of currentRobotPose;
		
		mutex.lock();
		
		currentRobotPose = robotPose;
		
		mutex.unlock();
		
		/// Adding sensor's distortion. Set this parameter to 'none' for having an ideal sensor.
		for (vector<ObjectSensorReading::Observation>::iterator it = obs.begin(); it != obs.end(); ++it)
		{
			if (strcasecmp(distortion.c_str(),"linear") == 0)
			{
				float displacementX, displacementY;
				
				displacementX = currentRobotPose.x - it->observation.x;
				displacementY = currentRobotPose.y - it->observation.y;
				
				if (sqrt(pow(displacementX,2) + pow(displacementY,2)) > startingDistortionDistance)
				{
					it->observation.x += (displacementX * 0.1);
					it->observation.y += (displacementY * 0.1);
				}
			}
		}
	}
//.........这里部分代码省略.........
开发者ID:fabioprev,项目名称:PTrackerROS,代码行数:101,代码来源:PTrackerROS.cpp


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