size_t BasePrefetchingDataLayer<Ftype, Btype>::parser_threads(const LayerParameter& param) {
  // Check user's override in prototxt file
  size_t parser_threads = param.data_param().parser_threads();
  if (!auto_mode(param) && parser_threads == 0U) {
    parser_threads = 1U;  // input error fix
  }
  // 1 thread for test net
  return (auto_mode(param) || param.phase() == TEST || parser_threads == 0U) ? 1U : parser_threads;
}
// ------------------------------Auto Thread-------------------------------------
void* auto_thread(void*notused)
{
	int homed;
	homed = 0;
	while(1)
	{
		//printf("home: %i\n",homed);
		if ((last_input == BASECW)   	|| (last_input == BASECCW)  	||
		    (last_input == SHOULDERUP)  || (last_input == SHOULDERDW)	||
			(last_input == ELBOWUP)  	|| (last_input == ELBOWDW)		||
			(last_input == PITCHUP) 	|| (last_input == PITCHDW)		||
			(last_input == GRIPPEROP)   || (last_input == GRIPPERCLOSE) ||
			(last_input == ROLLCW)      || (last_input == ROLLCCW))
			homed = 0;
		if (memData.autoModeOn == ON)
		{
			if (last_input == HOMEROBOT)
			{
				printf("homing!\n");
				if (homed != 1)
				{
					homed = homing();
					last_input = MANUALON;
					writeMsg(last_input);
				}
				printf("home done\n");
				flushall();
				last_input = MANUALON;
				writeMsg(last_input);
			}
			if (last_input == MANUALOFF)
			{
				if (readLowerByte.lowIpReserved1 == 1)
				{
					printf("No block in the loader\n");
					flushall();
				}
				else
				{
					if (homed != 1)
						homing();
					homed = 0;
					auto_mode();
				}
				last_input = MANUALON;
				writeMsg(last_input);
				printf("auto done\n");
				flushall();
			}
		}
		delay(50);
	}
}
BasePrefetchingDataLayer<Ftype, Btype>::BasePrefetchingDataLayer(const LayerParameter& param)
    : BaseDataLayer<Ftype, Btype>(param, threads(param)),
      InternalThread(Caffe::current_device(), this->solver_rank_, threads(param), false),
      auto_mode_(Caffe::mode() == Caffe::GPU && auto_mode(param)),
      parsers_num_(parser_threads(param)),
      transf_num_(threads(param)),
      queues_num_(transf_num_ * parsers_num_),
      next_batch_queue_(0UL) {
  CHECK_EQ(transf_num_, threads_num());
  // We begin with minimum required
  ResizeQueues();
}
Example #4
0
void manual_mode() 
{
    int discardSensors = 1;
    while(1) {
	    _delay_ms(1);
	    //printf("\r\nPlease enter the input in the format : <dir> <l1><l0> <r1><r0>\r\n");
	    //char dir   = getchar();
  	      if( bit_is_set(UCSR0A, RXC0) != 0) {
	       	    char dir = UDR0;
	 	    printf("UDR0 = %c\r\n",dir);

		    if(dir == 'a') {
			printf("Auto mode enabled\r\n");
			auto_mode();
		    }
		    while( (dir !='d') & (dir !='h') & (dir !='f') & (dir !='b') & (dir !='l') & (dir !='r') & (dir !='s') ) {
			printf("Enter valid direction character(f,b,l,r,s,d,h)");
			char dir   = getchar();
		    }
		    if(dir=='d') {
			discardSensors = 1;		// Discard Sensor Values
		    }
		    if(dir=='h') {
			discardSensors = 0; 	// Hold    Sensor Values
		    }

		    if(dir=='f') {
			int  speedl1 = getchar();
			int  speedl0 = getchar();
			int  speedr1 = getchar();
			int  speedr0 = getchar();
			printf("You entered input as : %c %c%c %c%c\r\n", dir, speedl1,speedl0,speedr1,speedr0);
			int  speedl  = ((speedl1-48)*10  +  (speedl0-48))*255/99;
			int  speedr  = ((speedr1-48)*10  +  (speedr0-48))*255/99;

			moveForward(speedl,speedr);
			printf("Robot moves forward\r\n");
		    }
		    if(dir=='b') {
			int  speedl1 = getchar();
			int  speedl0 = getchar();
			int  speedr1 = getchar();
			int  speedr0 = getchar();
			printf("You entered input as : %c %c%c %c%c\r\n", dir, speedl1,speedl0,speedr1,speedr0);
			int  speedl  = ((speedl1-48)*10  +  (speedl0-48))*255/99;
			int  speedr  = ((speedr1-48)*10  +  (speedr0-48))*255/99;

			moveBackward(speedl,speedr);
			printf("Robot moves backward\r\n");
		    }
		    if(dir=='r') {
			int  speedl1 = getchar();
			int  speedl0 = getchar();
			int  speedr1 = getchar();
			int  speedr0 = getchar();
			printf("You entered input as : %c %c%c %c%c\r\n", dir, speedl1,speedl0,speedr1,speedr0);
			int  speedl  = ((speedl1-48)*10  +  (speedl0-48))*255/99;
			int  speedr  = ((speedr1-48)*10  +  (speedr0-48))*255/99;

			moveRight(speedl,speedr);
			printf("Robot moves right\r\n");
		    }
		    if(dir=='l') {
			int  speedl1 = getchar();
			int  speedl0 = getchar();
			int  speedr1 = getchar();
			int  speedr0 = getchar();
			printf("You entered input as : %c %c%c %c%c\r\n", dir, speedl1,speedl0,speedr1,speedr0);
			int  speedl  = ((speedl1-48)*10  +  (speedl0-48))*255/99;
			int  speedr  = ((speedr1-48)*10  +  (speedr0-48))*255/99;

			moveLeft(speedl,speedr);
			printf("Robot moves left\r\n");
		    }
		    if(dir=='s') {
			printf("You entered input as : %c\r\n", dir);

			moveStop();
			printf("Robot stops\r\n");
		    }

  	     }
	     else if( discardSensors!=1 ) {
			  _delay_ms(50);
			  int adc_val0=ReadADC(0);
			  _delay_ms(50);
			  int adc_val1=ReadADC(1);
			  _delay_ms(50);
			  int adc_val2=ReadADC(2);
			  printf("Sensor Readings :  ClifL = %d, ClifR = %d, Bump = %d\r\n",adc_val0,adc_val1,adc_val2);

			  if( (adc_val0 < 100) ) {
			  //if( (adc_val0 < 100) | (adc_val1 < 100) | (adc_val2 < 100) ) {
				moveStop();
				printf("Robot stops\r\n");
				_delay_ms(0500);
				
				moveBackward(160,160);
				printf("Robot moves backward\r\n");
				_delay_ms(1000);

				moveStop();
				printf("Robot stops\r\n");
				_delay_ms(0500);
				
				moveRight(160,160);
				printf("Robot moves Right\r\n");
				_delay_ms(0500);

				moveStop();
				printf("Robot stops\r\n");
				_delay_ms(0500);
			  }
            }
  }
}