void main(void) { BYTE re1, re2; BYTE a1, a2, a3, a4, a5, a6; M48Init(); printf("\r\nM88PA demo\r\n"); pip(); #define T 1000 PORTB.1 = 1; PORTB.2 = 1; robotStop(); goFwd(); delay_ms(T); goBack(); delay_ms(T); goLeft(); delay_ms(T); goRight(); delay_ms(T); robotStop(); pip(); while (1) { //char c; //c = getchar(); //printf("[%c] %3d\r\n",c, (int)c); re1 = ReadByteADC(ADC_E1); re2 = ReadByteADC(ADC_E2); a1 = ReadByteADC(ADC_1); a2 = ReadByteADC(ADC_2); a3 = ReadByteADC(ADC_3); a4 = ReadByteADC(ADC_4); a5 = ReadByteADC(ADC_5); a6 = ReadByteADC(ADC_6); delay_ms(20); printf("%4u %4u %4u %4u %4u %4u %4u %4u\r", re1, re2, a1, a2, a3, a4, a5, a6); } }
int main(int argc,char ** argv) { int index=0; struct option argarr[]={ { "port",1,NULL,'P' }, { "mgroup",1,NULL,'M' }, { "player",1,NULL,'p' }, { "help",1,NULL,'H' }, { NULL,0,NULL,0 } }; /* *初始化 *级别: 默认值 ,配置文件,环境变量,命令行参数 * */ int c; while(1) { c= getopt_long(argc,argv,"P:M:p:H",argarr,&index) if(c<0) switch(c) { case 'p': client_conf.revport=optarg; break; case 'M' client_conf.mgroup=optarg; break; case 'p' client_conf.player_cmd=optarg; break; case 'H' printhelp(); exit(0); break; default: abort(); break; } } pip(); fork(); // 子继承调用解码器 // 父进程 从网络上收包 发送给子进程 exit(0); }
typename Foam::GGIInterpolation<MasterPatch, SlavePatch>::insideOutside GGIInterpolation<MasterPatch, SlavePatch>::isVertexInsidePolygon ( const List<point2D>& clippingPolygon, const List<point2D>& subjectPolygon, List<bool>& subjectVertexInside ) const { insideOutside retValue = ALL_OUTSIDE; // The class HormannAgathos implements the algorithm // We use distErrorTol_ to evaluate a distance factor called // epsilon. That epsilon factor will be used to detect if a point // is on a vertex or an edge. const scalar distErrorTol = sqrt(areaErrorTol_); HormannAgathos pip(clippingPolygon, distErrorTol); // Counter label nbrsOutside = 0; // Iterate over all subject vertices, determining if they are // inside/outside the clipping polygon forAll(subjectPolygon, sPI) { switch (pip.evaluate(subjectPolygon[sPI])) { case HormannAgathos::POINT_OUTSIDE: nbrsOutside++; subjectVertexInside[sPI] = false; break; case HormannAgathos::POINT_ON_VERTEX: case HormannAgathos::POINT_ON_EDGE: case HormannAgathos::POINT_INSIDE: default: // Vertex, Edge or Inside: We are inside! subjectVertexInside[sPI] = true; break; } } // Let's do the inventory now... if (nbrsOutside == 0) { retValue = ALL_INSIDE; } else if (nbrsOutside < subjectPolygon.size()) { retValue = PARTIALLY_OVERLAPPING; } // else, all the points are outside, which is not necessarily a // problem if the subject Polygon is enclosing partially or // completely the clipping polygon instead return retValue; }
void DebugProc(void) { BYTE re1, re2; BYTE a1, a2, a3, a4, a5, a6; printf("\r\nTEST REGIME\r\n"); // Отладочные телодвижения // (проверка правильности подключения двигателей: вперед, назад, влево, вправо) #define Time 500 goFwd(); delay_ms(Time); goBack(); delay_ms(Time); goLeft(); delay_ms(Time); goRight(); delay_ms(Time); robotStop(); pip(); goFastLeft(); delay_ms(Time); goFastRight(); delay_ms(Time); robotStop(); pip(); while (1) { re1 = ReadByteADC(ADC_E1); re2 = ReadByteADC(ADC_E2); a1 = ReadByteADC(ADC_1); a2 = ReadByteADC(ADC_2); a3 = ReadByteADC(ADC_3); a4 = ReadByteADC(ADC_4); a5 = ReadByteADC(ADC_5); a6 = ReadByteADC(ADC_6); delay_ms(20); printf("(%4u %4u) (%4u %4u) %4u %4u %4u %4u\r", re1, re2, a1, a2, a3, a4, a5, a6); } }
interact() { int i, intrpt(); char cmd[80], *rest, *index(); for (;;) { if (firsttime++ == 0) { signal(SIGINT, intrpt, -1); setret(env); } if (cmdinp(cmd) < 0) return (0); rest = index(cmd, ' '); if (rest) *rest++ = '\0'; i = chkcmd(cmd); #ifdef DEBUG printf("command: %s, ind: %d\n", cmd, i); #endif switch (i) { default: errinp; break; case CMD_DIR: case CMD_LS: dispdir(); break; case CMD_RENAME: rename(rest); break; case CMD_OCOPY: copyc(rest, 0); break; case CMD_ICOPY: pip(rest, 0); break; case CMD_DELETE: case CMD_ERASE: delete(rest); break; case CMD_EXIT: case CMD_LOGOUT: return(0); case CMD_TYPE: copy(rest, stdout, 0); break; case CMD_HELP: help(); break; case CMD_OCCOPY: copyc(rest, 1); break; case CMD_ICCOPY: pip(rest,1); break; case CMD_DUMP: dump(rest); break; case CMD_UNIX: system(rest); break; case CMD_DISK: disk(); break; } } }
void main(void) { int T; // Счетчик тактов для смены тактики поиска int a; // Куда крутиться, 0 - влево, 1 - вправо, 2 - вперёд BYTE cntOtval = 0; // Счетчик числа импульсов для опускания отвала // Инициализация контроллера M48Init(); // Port C initialization // Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State6=T State5=P State4=P State3=P State2=P State1=T State0=T PORTC=0x3C; DDRC=0x00; // Переопределяем ef_2 (D.4) как цифровой подтянутый вход // Port D initialization // Func7=Out Func6=Out Func5=Out Func4=In Func3=Out Func2=Out Func1=In Func0=In // State7=0 State6=0 State5=0 State4=P State3=0 State2=0 State1=T State0=T PORTD=0x10; DDRD=0xEC; // Скроостью управлять не будем. Выставляем по максиммуму PORTB.1 = 1; PORTB.2 = 1; robotStop(); pip(); printf("\r\nSumo 88 RK-25/26MS Version 1.05\r\n\r\n"); //-------------------------------------------------------- // Переход в отладочный режим // Для перехода в отладочный режим необходимо, чтоб перед включением датчики // границы находились на светлом фоне //-------------------------------------------------------- FotoL = ReadByteADC(6)>LimLeft; FotoR = ReadByteADC(7)>LimRight; if(FotoL && FotoR) DebugProc(); robotStop(); //-------------------------------------------------------- // Ожидание сигнала START //-------------------------------------------------------- while(SENSOR_START==0); /*** // Выдача управляющах импульсов на сервомашинку, для опускания отвала // Изображаем управляющий ШИМ // Это займет около 10*(18+0.9) = 189 мс. for(n=0;n<MAX_CNT_OTVAL;n++) { ef_1 = 0; delay_us(18000); // Период импульсов. Вообще должно быть так: 20000 - <ширина импульса> = 20000-900 = 19100 ef_1 = 1; delay_us(900); // Ширина импульса 900 мкс (0.9 мс) - крайнее положение } ***/ ef_1 = 0; T = 0; a = 0; //-------------------------------------------------------- // Основной цикл //-------------------------------------------------------- while (1) { //------------------------------------------------------ // Опускаем отвал на ходу //------------------------------------------------------ if(cntOtval<MAX_CNT_OTVAL) { cntOtval++; //Выдаем импульс (с задержками) delay_us(18000); // Период импульсов. Вообще должно быть так: 20000 - <ширина импульса> = 20000-900 = 19100 ef_1 = 1; delay_us(900); // Ширина импульса 900 мкс (0.9 мс) - крайнее положение ef_1 = 0; } // Реакция на сигнал СТОП if(SENSOR_START==0) { robotStop(); pip(); while(1); } // Считываем сигналы датчиков SharpSL = (sen_3==0); SharpSR = (sen_4==0); SharpFL = (sen_5==0); SharpFR = (sen_6==0); FotoL = ReadByteADC(6)>LimLeft; FotoR = ReadByteADC(7)>LimRight; //------------------------------------------------------ // Безусловные рефлексы // Сначала и идет обработка самых приоритетных сигналов //------------------------------------------------------ // Реакция на границу поля if(FotoL) { // Отъезжаем назад goBack(); delay_ms(100); // Начинаем крутиться goRight(); T = 0; continue; } if(FotoR) { // Отъезжаем назад goBack(); delay_ms(100); // Начинаем крутиться goLeft(); T = 0; continue; } //------------------------------------------------------ // Общие действия // Обнаружение противника передними датчиками //------------------------------------------------------ if(SharpFL&&SharpFR) { goFwd(); T = 0; continue; } if(SharpFL||SharpSL) { goLeft(); T = 0; a = 0; continue; } if(SharpFR||SharpSR) { goRight(); T = 0; a = 1; continue; } //------------------------------------------------------ // Никого не обнаружили // Поиск противника //------------------------------------------------------ if(a==0) goLeft(); if(a==1) goRight(); if(a==2) goFwd(); T=T+1; if(T>MAXT) // Пора менять тактику { //pip(); T=0; // Выбираем действие "случайным" образом a=rand()%3; // Остаток от деления на 3 (деление по модулю 3) } } }
void CoreCloseBipartitePairContainer::do_before_evaluate() { IMP_OBJECT_LOG; if (covers_[0]==base::get_invalid_index<ParticleIndexTag>() || algebra::get_distance(get_model()->get_sphere(covers_[0]), get_model()->get_sphere(covers_[1])) < distance_ || reset_) { if (!reset_ && were_close_ && !internal::get_if_moved(get_model(), slack_, xyzrs_[0], rbs_[0], constituents_, rbs_backup_[0], xyzrs_backup_[0]) && !internal::get_if_moved(get_model(), slack_, xyzrs_[1], rbs_[1], constituents_, rbs_backup_[1], xyzrs_backup_[1])){ // all ok } else { // rebuild IMP_LOG(TERSE, "Recomputing bipartite close pairs list." << std::endl); internal::reset_moved(get_model(), xyzrs_[0], rbs_[0], constituents_, rbs_backup_[0], xyzrs_backup_[0]); internal::reset_moved(get_model(), xyzrs_[1], rbs_[1], constituents_, rbs_backup_[1], xyzrs_backup_[1]); ParticleIndexPairs pips; internal::fill_list(get_model(), access_pair_filters(), key_, 2*slack_+distance_, xyzrs_, rbs_, constituents_, pips); reset_=false; update_list(pips); } were_close_=true; } else { ParticleIndexPairs none; update_list(none); } IMP_IF_CHECK(base::USAGE_AND_INTERNAL) { for (unsigned int i=0; i< sc_[0]->get_number_of_particles(); ++i) { XYZR d0(sc_[0]->get_particle(i)); for (unsigned int j=0; j< sc_[1]->get_number_of_particles(); ++j) { XYZR d1(sc_[1]->get_particle(j)); double dist = get_distance(d0, d1); if (dist < .9*distance_) { ParticleIndexPair pip(d0.get_particle_index(), d1.get_particle_index()); bool filtered=false; for (unsigned int i=0; i< get_number_of_pair_filters(); ++i) { if (get_pair_filter(i)->get_value_index(get_model(), pip)) { filtered=true; break; } } IMP_INTERNAL_CHECK(filtered|| std::find(get_access().begin(), get_access().end(), pip) != get_access().end(), "Pair " << pip << " not found in list with coordinates " << d0 << " and " << d1 << " list is " << get_access()); } } } } }