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


C++ PlayerManager::waitForData方法代码示例

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


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

示例1: main

int main(int argc, char *argv[]) {
	MssArgs * args = new MssArgs(argc, argv);

	// Create PlayerManager			
	PlayerManager *pm = new PlayerManager(10, args->playerHostname, args->playerPort, args->verbosity);

	// Create PositionDevice
	PlayerPosition2D *pp2d = new PlayerPosition2D(pm, POSITION2D_INDEX, VFH_POSE_INDEX, AMCL_LOCALIZE_INDEX, args->verbosity);
	//PlayerPosition2D *pp2d = new PlayerPosition2D(pm, POSITION2D_INDEX, VFH_POSE_INDEX, POSITION2D_INDEX, args->verbosity);
	//PlayerPosition2D *pp2d = new PlayerPosition2D(pm, POSITION2D_INDEX, VFH_POSE_INDEX, VFH_POSITION_INDEX, args->verbosity);

	PlayerLaser pl(pm, LASER_INDEX, args->verbosity);

	PlayerBlobfinder *pbf = new PlayerBlobfinder(pm, BLOBFINDER_INDEX, args->verbosity);

	PlayerGripper *pg = new PlayerGripper(pm, GRIPPER_INDEX, args->verbosity);
	PlayerPtz *ptz = new PlayerPtz(pm, PTZ_INDEX, args->verbosity);
	// Create MapDevice
	PlayerMap *pmap = new PlayerMap(pm, 0, args->verbosity);
	// Create PlannerDevice
	//PlayerPlanner *pplan = new PlayerPlanner(pm, pp2d, pmap, POSITION2D_INDEX, true, args->verbosity, 0.3);

	//PlayerLocalization *ploc = new PlayerLocalization(pm, pp2d, 100, AMCL_LOCALIZE_INDEX, args->verbosity);

	PlayerPlanner *pplan = new PlayerPlanner(pm, pp2d, pmap, AMCL_LOCALIZE_INDEX, true, args->verbosity, 0.3);

	RobotManipulation *rm = new RobotManipulation(pm, pp2d, pg, pbf, ptz, args->verbosity);

	//parameter
	BlobColorType color1 = GREEN;
	BlobColorType color2 = RED;
	BlobColorType color = GREEN;
	playerc_blobfinder_blob_t blob;
	playerc_blobfinder_blob_t blob1;
	playerc_blobfinder_blob_t blob2;

	// Enable motors
	pp2d->powerUp();
	// Initialize Odometry to (0,0,0)
	pp2d->setOdometry(args->startX, args->startY, DTOR(args->startPhi));
	pg->moveDown();
	pg->open();
	//double pose[100][3] = {};
	//cout << ploc->getHypothCount() << endl;
	//ploc->localize(pp2d, pose);
	//ploc->getHypoth(1, pose);

	//cout << "plocpos\t" << pose[0] << "\t" << pose[1] << "\t" << pose[2] << std::endl;
	cout << "pp2dpos\t" << pp2d->getXPos() << "\t" << pp2d->getYPos() << std::endl;

	//2-dimensional array of search points
	clock_t start, finish;
	double duration = 0;
	double startX = args->startX;
	double startY = args->startY;
	//double searchPoint[4][2] = {{startX,startY},{1,-1},{1,1},{-1,1}};
	double searchPoint[3][2] = {{startX,startY},{-1.3,1.3},{-1.5,-1.5}};
	double goalX = 0;
	double goalY = 0;
	double phi = 0;
	bool flag = 0;

	int pointNum = 0;
	//int  windowWidth = 0;

	// main loop

	while( pointNum < 3 )
	{
		duration = 0;
		start = clock();
		flag = 0;

		//if the roboter on the start positon, just turn 1/4 circle
		if(abs(pp2d->getXPos()-startX)<0.2&&abs(pp2d->getYPos()-startY)<0.2)
		{
			pp2d->goToPose(startX,startY,DTOR(-90));
			while(!pp2d->getReached())
			{
				pm->waitForData();
			}
			//while(!pbf->blobFound(color1)&&!pbf->blobFound(color2)&&duration<1)
			cout << "No Blob! Searching!" << endl;
			pp2d->goToPose(startX,startY,DTOR(-180));
			while(!pp2d->getReached())
			{
				pm->waitForData();
				if((pbf->blobFound(color1)||pbf->blobFound(color2)))
				{
					if(pbf->blobFound(color1)&&abs((int)blob.area>80))
					{
						pbf->getBiggestBlob(color1, blob);
						flag = 1;
						break;
					}
					if(pbf->blobFound(color2)&&abs((int)blob.area>80))
					{
						pbf->getBiggestBlob(color2, blob);
						if((blob.right-blob.left)<(blob.bottom-blob.top))
						{
//.........这里部分代码省略.........
开发者ID:alfmunny,项目名称:matt,代码行数:101,代码来源:matt.cpp


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