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


C++ Serial::send方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
		//Estrategia.players[2].comportamento = 2;

		// Atribuição de objetivos
		Estrategia.goleiro4();
		Estrategia.lateral();
		Estrategia.atacante2();
		Estrategia.zagueiro();


		Estrategia.generalRouting();
		
		
		//Estrategia.players[0].setGoal(23, 98);
		//Estrategia.players[1].setGoal(23, 98);


		estraF = clock();



		//  =========================== CONTROLE =========================== //
		controlI = clock();
		Controle00.controla(Camera.players[0], robot(Estrategia.players[0].goal_x, Estrategia.players[0].goal_y), robot(Estrategia.players[0].objective_x, Estrategia.players[0].objective_y));
		Controle01.controla(Camera.players[1], robot(Estrategia.players[1].goal_x, Estrategia.players[1].goal_y), robot(Estrategia.players[1].objective_x, Estrategia.players[1].objective_y));
		Controle02.controla(Camera.players[2], robot(Estrategia.players[2].goal_x, Estrategia.players[2].goal_y), robot(Estrategia.players[2].objective_x, Estrategia.players[2].objective_y));
		controlF = clock();

		// =========================== COMUNICAÇÃO =========================== //
		commI = clock();

		if (!paused)
		{
			//SP->send(0, 0, 15);
			SP->send(0, Controle00.v.x, Controle00.v.y);
			whishPath.push_back(robot(Estrategia.players[0].goal_x, Estrategia.players[0].goal_y));
			followedPath.push_back(Camera.players[0]);
			//SP->send(1, Controle01.v.x, Controle01.v.y);
			//SP->send(2, Controle02.v.x, Controle02.v.y);
		}
		else
		{
			SP->send(0, 0, 0);
			SP->send(1, 0, 0);
			SP->send(2, 0, 0);
		}
		commF = clock();


		// Debug em prompt de comando
		debugI = clock();

		//system("cls");
		//cout << "Roxo: " << Estrategia.players[0].x << ", " << Estrategia.players[0].y << " --> " << Estrategia.players[0].goal_x << ", " << Estrategia.players[0].goal_y << endl;
		//cout << "Verde: " << Estrategia.players[1].x << ", " << Estrategia.players[1].y << " --> " << Estrategia.players[1].goal_x << ", " << Estrategia.players[1].goal_y << endl;
		//cout << "Marrom: " << Estrategia.players[2].x << ", " << Estrategia.players[2].y << " --> " << Estrategia.players[2].goal_x << ", " << Estrategia.players[2].goal_y << endl;

		//cout << "Carrinho: (" << Camera.players[0].x << ", " << Camera.players[0].y << ", " << Camera.players[0].theta *(180/M_PI) << ")" << endl;
		//cout << "Objetivo: (" << (int) Estrategia.ponto_f.x << ", " << (int) Estrategia.ponto_f.y << ")" << endl;
		//cout << "Velocidade (d, e): " << Controle00.v.x << ", "<< Controle00.v.y << ")" <<endl;



		// Debug em janela

		cvSetMouseCallback("Live", mouseEvent, 0);
开发者ID:Hefestos,项目名称:cup2015,代码行数:66,代码来源:main_new_old.cpp

示例2: main

int main(){
	init();
		usb.send(PINA & 0x1F);

	MoteurManager engines = MoteurManager();
	


    enum States {
        AVANCER,
        ADJUST_INTER,
        TURN_LEFT,
        TURN_RIGHT
    };

    // Set the initial state
    States state = AVANCER;
		
	for(;;) {

 		switch (state) {
            case AVANCER:
				engines.avancer(140);

				// 00100
				// 01100
				// 00110
				if (((PINC & 0x1F) == 0x04) || ((PINC & 0x1F) == 0x06) || ((PINC & 0x1F) == 0x0C))  {
					// PORTA = 0x0;
					engines.adjustcenter();
					_delay_ms(10);
				}

				// 00010
				// 00001
				// 00011
				if (((PINC & 0x1F) == 0x01) || ((PINC & 0x1F) == 0x03) || ((PINC & 0x1F) == 0x02)) {
					//PORTA = 0x2;
					engines.adjustToLeft();
					_delay_ms(10);
				}

				// 11000
				// 10000
				// 01000
				if (((PINC & 0x1F) == 0x18) || ((PINC & 0x1F) == 0x10) || ((PINC & 0x1F) == 0x08)) {
				// PORTA = 0x1;
					engines.adjustToRight();
					_delay_ms(10);
				}

				// 11111
				// 00111
				// 11100
				// 01111
				// 11110
				if (((PINC & 0x1F) == 0x1F) || ((PINC & 0x1F) == 0x07) || ((PINC & 0x1F) == 0x1C) ||((PINC & 0x1F) == 0x0F)||((PINC & 0x1F) == 0x1E)) {
					_delay_ms(15);
		
					if(((PINC & 0x1F) == 0x1F) || ((PINC & 0x1F) == 0x07) || ((PINC & 0x1F) == 0x1C) ||((PINC & 0x1F) == 0x0F)||((PINC & 0x1F) == 0x1E)) {
						state = ADJUST_INTER;
					}
				}
				break;
			case ADJUST_INTER:
				engines.avancer(160);
				_delay_ms(1000);
				state = TURN_LEFT;

			case TURN_LEFT:
				
				engines.arreter();
				_delay_ms(500);
				engines.tournerGauche(40);

				while ((PINC & 0x1F) == 0x00) {
					//engines.tournerGauche(1);
					engines.adjustToLeft();
					
				}

				state = AVANCER;

				break;

			case TURN_RIGHT:
				engines.arreter();
				_delay_ms(500);
				engines.tournerDroite(45);

				while ((PINC & 0x1F) == 0x00) {
					//engines.tournerDroite(1);
					engines.adjustToRight();
				}

				state = AVANCER;

				break;


//.........这里部分代码省略.........
开发者ID:ArchSirius,项目名称:inf1995,代码行数:101,代码来源:main.cpp


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