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


C++ MainMenu::userChoice方法代码示例

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


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

示例1: main

int main(int argc, char** argv) {

	TCPIP tcpip;
	bool simMode = false;
	bool isKheperaConnected = false;
	int triesLeft = 0; 		// nie polaczy sie, jak widac
	while (triesLeft > 0 && !(tcpip.init() && tcpip.connect_to_server(kheperaAddress, 3000))) { //!!!
		tcpip = TCPIP();
		triesLeft--;
	}
	if (triesLeft > 0){
		isKheperaConnected = true;
	}
	if (!isKheperaConnected) {
		printf("Connection could not be established.\n");
	} else {
		printf("Connection has been established.\n");
	}

	View* view;
	bool finish = false;

	MainMenu* mainMenu = new MainMenu();
	mainMenu->show();
	int userChoice = NONE;
	while (userChoice == NONE){
		userChoice = mainMenu->userChoice();
	}
	switch (userChoice){
	case CAMERA:
		view = new KheperaView(rtspAddress);
		if (view->start() < 0) {
			printf("Camera is null\n");
			finish = true;
		} else {
			view->capture();
		}
		break;
	case SIMULATION:
		simMode = true;
		view = new SimulationView();
		if (view->start() < 0) {
			printf("Simulation could not be started\n");
			finish = true;
		} else {
			view->capture();
		}
		break;
	case QUIT:
		waitKey(0);
		cvDestroyAllWindows();
		return 0;
		break;
	}


	WheelController wc(view->get_width(), CAMERA_ANGLE, WHEEL_DIST/2, DIST, REF_HEIGHT, 0);	// ostatni param: predkosc poczatkowa
	pair<int,int> control;

	while (!finish) {
		view->print_viewInfo();
		if (view->is_target_set()){
			view->print_targetInfo();
			// simulation mode
			if(simMode){
				((SimulationView*)view)->sim.printCoords();
				if(!OBSERVER) {
					control = wc.getSpeeds(view->get_target_position().x, (int)((SimulationView*)view)->sim.getHeight());	// zmienic na wysokosc celu
					if(control.first != 0)
						((SimulationView*)view)->sim.moveRobot(wc.getR(), wc.getSpeed()*INTERVAL, (control.first >= control.second));
				}
			} else {	// normal mode
				control = wc.getSpeeds(view->get_target_position().x, REF_HEIGHT/2);	// zmienic na wysokosc celu
			}

			//cout << control.first << ", " << control.second << endl;
			if (isKheperaConnected){
				tcpip.send_speed(control.first, control.second);
			}

		}
		if(!simMode)
			usleep(1000000 * INTERVAL);	//


		view->show_main_panel();
		view->capture();
		finish = view->is_stopped();
		if (!finish){
			view->track_target();
		}
	}

	tcpip.send_speed(0,0);
	cvDestroyAllWindows();
	waitKey(0);
	return 0;
}
开发者ID:FizzyMobile,项目名称:objecttracking,代码行数:98,代码来源:main.cpp


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