int _tmain(int argc, char** argv) { //-------------- M A I N D E L P R O G R A M A D E L R O B O T------------// //----------------------------------------------------------------------------------// //inicializaion de variables Aria::init(); ArArgumentParser parser(&argc, argv); parser.loadDefaultArguments(); ArSimpleConnector simpleConnector(&parser); ArRobot robot; ArSonarDevice sonar; ArAnalogGyro gyro(&robot); robot.addRangeDevice(&sonar); ActionTurns turn(400, 55); robot.addAction(&turn, 49); ActionTurns turn2(400, 55); robot.addAction(&turn2, 49); turn.deactivate(); turn2.deactivate(); // presionar tecla escape para salir del programa ArKeyHandler keyHandler; Aria::setKeyHandler(&keyHandler); robot.attachKeyHandler(&keyHandler); printf("Presionar ESC para salir\n"); // uso de sonares para evitar colisiones con las paredes u // obstaculos grandes, mayores a 8cm de alto ArActionLimiterForwards limiterAction("limitador velocidad cerca", 300, 600, 250); ArActionLimiterForwards limiterFarAction("limitador velocidad lejos", 300, 1100, 400); ArActionLimiterTableSensor tableLimiterAction; robot.addAction(&tableLimiterAction, 100); robot.addAction(&limiterAction, 95); robot.addAction(&limiterFarAction, 90); // Inicializon la funcion de goto ArActionGoto gotoPoseAction("goto"); robot.addAction(&gotoPoseAction, 50); // Finaliza el goto si es que no hace nada ArActionStop stopAction("stop"); robot.addAction(&stopAction, 40); // Parser del CLI if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(1); } // Conexion del robot if (!simpleConnector.connectRobot(&robot)) { printf("Could not connect to robot... exiting\n"); Aria::exit(1); } robot.runAsync(true); // enciende motores, apaga sonidos robot.enableMotors(); robot.comInt(ArCommands::SOUNDTOG, 0); // Imprimo algunos datos del robot como posicion velocidad y bateria robot.lock(); ArLog::log(ArLog::Normal, "Posicion=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Bateria=%.2fV", robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getBatteryVoltage()); robot.unlock(); const int duration = 100000; //msec ArLog::log(ArLog::Normal, "Completados los puntos en %d segundos", duration/1000); bool first = true; int goalNum = 0; int color = 3; ArTime start; start.setToNow(); while (Aria::getRunning()) { robot.lock(); // inicia el primer punto if (first || gotoPoseAction.haveAchievedGoal()) { first = false; goalNum++; //cambia de 0 a 1 el contador printf("El contador esta en: --> %d <---\n",goalNum); if (goalNum > 20) goalNum = 1; //comienza la secuencia de puntos if (goalNum == 1) { gotoPoseAction.setGoal(ArPose(1150, 0)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); // Imprimo algunos datos del robot como posicion velocidad y bateria robot.lock(); ArLog::log(ArLog::Normal, "Posicion=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Bateria=%.2fV", robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getBatteryVoltage()); robot.unlock(); } else if (goalNum == 2) { printf("Gira 90 grados izquierda\n"); robot.unlock(); turn.myActivate = 1; turn.myDirection = 1; turn.activate(); ArUtil::sleep(1000); turn.deactivate(); turn.myActivate = 0; turn.myDirection = 0; robot.lock(); } else if (goalNum == 3) { gotoPoseAction.setGoal(ArPose(1150, 2670)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); // Imprimo algunos datos del robot como posicion velocidad y bateria robot.lock(); ArLog::log(ArLog::Normal, "Posicion=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Bateria=%.2fV", robot.getX(), robot.getY(), robot.getTh(), robot.getVel(), robot.getBatteryVoltage()); robot.unlock(); } else if (goalNum == 4) { printf("Gira 90 grados izquierda\n"); robot.unlock(); turn2.myActivate = 1; turn2.myDirection = 1; turn2.activate(); ArUtil::sleep(1000); turn2.deactivate(); turn2.myActivate = 0; turn2.myDirection = 0; robot.lock(); } else if (goalNum == 5) { gotoPoseAction.setGoal(ArPose(650, 2670)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } else if (goalNum == 6) { printf("Gira 90 grados izquierda\n"); robot.unlock(); turn2.myActivate = 1; turn2.myDirection = 1; turn2.activate(); ArUtil::sleep(1000); turn2.deactivate(); turn2.myActivate = 0; turn2.myDirection = 0; robot.lock(); } else if (goalNum == 7) { gotoPoseAction.setGoal(ArPose(650, 0)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } else if (goalNum == 8) { gotoPoseAction.setGoal(ArPose(1800,1199)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } else if (goalNum == 9) { gotoPoseAction.setGoal(ArPose(2600, 1199)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } else if (goalNum == 10) { if (color == 1) { gotoPoseAction.setGoal(ArPose(2800, 850)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 2) { gotoPoseAction.setGoal(ArPose(3500, 1199)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(2800, 1550)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 11) { if (color == 1) { gotoPoseAction.setGoal(ArPose(2800, 613)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 2) { printf("Gira 180 grados derecha\n"); robot.unlock(); turn2.myActivate = 1; turn2.myDirection = 2; turn2.activate(); ArUtil::sleep(2000); turn2.deactivate(); turn2.myActivate = 0; turn2.myDirection = 0; robot.lock(); goalNum = 19; } if (color == 3) { gotoPoseAction.setGoal(ArPose(2800, 1785)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 12) { if (color == 1) { gotoPoseAction.setGoal(ArPose(3300, 413)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(3300, 1985)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 13) { if (color == 1) { gotoPoseAction.setGoal(ArPose(3500, 413)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(3500, 1985)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 14) { //secuencia de drop de la figura } else if (goalNum == 15) { printf("Gira 180 grados derecha\n"); robot.unlock(); turn2.myActivate = 1; turn2.myDirection = 2; turn2.activate(); ArUtil::sleep(2000); turn2.deactivate(); turn2.myActivate = 0; turn2.myDirection = 0; robot.lock(); } else if (goalNum == 16) { if (color == 1) { gotoPoseAction.setGoal(ArPose(3300, 413)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(3300, 1985)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 17) { if (color == 1) { gotoPoseAction.setGoal(ArPose(2800, 603)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(2800, 1795)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 18) { if (color == 1) { gotoPoseAction.setGoal(ArPose(2800, 860)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if (color == 3) { gotoPoseAction.setGoal(ArPose(2800, 1540)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } else if (goalNum == 19) { gotoPoseAction.setGoal(ArPose(2600, 1199)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } else if (goalNum == 20) { gotoPoseAction.setGoal(ArPose(1800, 1199)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } } if(start.mSecSince() >= duration) { ArLog::log(ArLog::Normal, "No puede llegar al punto, y la aplicacion saldra en %d", duration/1000); gotoPoseAction.cancelGoal(); robot.unlock(); ArUtil::sleep(3000); break; } robot.unlock(); ArUtil::sleep(10); } // Robot desconectado al terminal el sleep Aria::shutdown(); //----------------------------------------------------------------------------------// return 0; }
int main(int argc, char **argv) { Aria::init(); ArArgumentParser parser(&argc, argv); parser.loadDefaultArguments(); ArRobot robot; ArAnalogGyro gyro(&robot); ArSonarDevice sonar; ArRobotConnector robotConnector(&parser, &robot); ArLaserConnector laserConnector(&parser, &robot, &robotConnector); // Connect to the robot, get some initial data from it such as type and name, // and then load parameter files for this robot. if(!robotConnector.connectRobot()) { ArLog::log(ArLog::Terse, "gotoActionExample: Could not connect to the robot."); if(parser.checkHelpAndWarnUnparsed()) { // -help not given Aria::logOptions(); Aria::exit(1); } } if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); Aria::exit(1); } ArLog::log(ArLog::Normal, "gotoActionExample: Connected to robot."); robot.addRangeDevice(&sonar); robot.runAsync(true); // Make a key handler, so that escape will shut down the program // cleanly ArKeyHandler keyHandler; Aria::setKeyHandler(&keyHandler); robot.attachKeyHandler(&keyHandler); printf("You may press escape to exit\n"); // Collision avoidance actions at higher priority ArActionLimiterForwards limiterAction("speed limiter near", 300, 600, 250); ArActionLimiterForwards limiterFarAction("speed limiter far", 300, 1100, 400); ArActionLimiterTableSensor tableLimiterAction; robot.addAction(&tableLimiterAction, 100); robot.addAction(&limiterAction, 95); robot.addAction(&limiterFarAction, 90); // Goto action at lower priority ArActionGoto gotoPoseAction("goto"); robot.addAction(&gotoPoseAction, 50); // Stop action at lower priority, so the robot stops if it has no goal ArActionStop stopAction("stop"); robot.addAction(&stopAction, 40); // turn on the motors, turn off amigobot sounds robot.enableMotors(); robot.comInt(ArCommands::SOUNDTOG, 0); const int duration = 30000; //msec ArLog::log(ArLog::Normal, "Going to four goals in turn for %d seconds, then cancelling goal and exiting.", duration/1000); bool first = true; int goalNum = 0; ArTime start; start.setToNow(); while (Aria::getRunning()) { robot.lock(); // Choose a new goal if this is the first loop iteration, or if we // achieved the previous goal. if (first || gotoPoseAction.haveAchievedGoal()) { first = false; goalNum++; if (goalNum > 4) goalNum = 1; // start again at goal #1 // set our positions for the different goals if (goalNum == 1) gotoPoseAction.setGoal(ArPose(2500, 0)); else if (goalNum == 2) gotoPoseAction.setGoal(ArPose(2500, 2500)); else if (goalNum == 3) gotoPoseAction.setGoal(ArPose(0, 2500)); else if (goalNum == 4) gotoPoseAction.setGoal(ArPose(0, 0)); ArLog::log(ArLog::Normal, "Going to next goal at %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if(start.mSecSince() >= duration) { ArLog::log(ArLog::Normal, "%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000); gotoPoseAction.cancelGoal(); robot.unlock(); ArUtil::sleep(3000); break; } robot.unlock(); ArUtil::sleep(100); } // Robot disconnected or time elapsed, shut down Aria::exit(0); return 0; }
void Soldier::handleCollisionWith(GameObject* gameObject) { // if (this->hp<=0) { // this->isScheduledForRemove = true; // } // // bloodBar->setScaleX(0.3f*hp/maxHp); if (gameObject != NULL) { if (gameObject->getTag() >= 200) { // if (ccpDistance(this->getPosition(), gameObject->getPosition())<=this->radius()) { if (stopAction()) { return; } if (checkIsCollision(gameObject)) { isCollision = true; stop(); if (normalSkillTrigger()) { normalSkillHandler(gameObject); } if (haloSkillTrigger()) { haloSkillHandler(gameObject); } if (normalAtkTrigger()) { normalAtkHandler(gameObject); } curActionCount++; } //this->setPositionX(this->getPositionX()-10); // if (hp>0) { //bloodBar->setVisible(true); // { // gameObject->setHp(gameObject->getHp()-this->getAtk()); //if (isS9) { /* if (strcmp(animationManager->getRunningSequenceName(), "attack2")!=false) { animationManager->runAnimationsForSequenceNamed("attack2"); } */ //} else { //} // } //} // } // } else { // if (isS6) { // if (!gameObject->isMaxHp()) { // CCBAnimationManager* animationManager = dynamic_cast<CCBAnimationManager*>(this->getUserObject()); // if (animationManager->getRunningSequenceName()==NULL or strcmp(animationManager->getRunningSequenceName(), "attack1")!=false) { // animationManager->runAnimationsForSequenceNamed("attack1"); // } // } // } else if (!this->isMaxHp()) { // CCBAnimationManager* animationManager = dynamic_cast<CCBAnimationManager*>(gameObject->getUserObject()); // if (animationManager->getRunningSequenceName()==NULL or strcmp(animationManager->getRunningSequenceName(), "attack1")!=false) { // float newHp = this->getMaxHp()>(this->getHp()+gameObject->getAtk()) ? this->getHp()+gameObject->getAtk() : this->getMaxHp(); // this->setHp(newHp); // } // } } } }
bool Akuerdate::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event) { if(Configuracion::desarrollo) log("BEGAN %f %f",touch->getLocation().x,touch->getLocation().y); if(juegoTerminado) irAtras(NULL); if(isPlayNarracion){ if(Configuracion::comprobarToque(touch, capaTextoCuadroInicial)){ saltarAnimacion(); } } //SI LE DIO AL PROFESOR bool tocaProfesor = false; auto target = profesor; Point locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = profesor->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); if (rect.containsPoint(locationInNode)) { tocaProfesor = true; if(isPlayNarracion || textosProfesor->count()>0 || cuadroDialogo->getString()!=""){ cambiarTextoDialogo(LanguageManager::getInstance()->getString("PROFESOR_MENJ_01")); if(isPlayNarracion){ mostrarDialogoComenzar(); stopAction(narracion); isPlayNarracion = false; CocosDenshion::SimpleAudioEngine::getInstance()->stopAllEffects(); } }else{ cambiarTextoDialogo(LanguageManager::getInstance()->getString("PROFESOR_MENJ_02")); } } if(!escuchadores){ return false; } if(!escuchadorElementos){ if(Configuracion::comprobarToque(touch, cuadroJuego)){ cambiarTextoDialogo(LanguageManager::getInstance()->getString("Aun_no")); return false; }else return false; } if(comprobarToqueElemento(touch)){ comprobarExitoElemento(touch); CCLOG("IMPLEMENTAR SECUENCIA TOCADA DE MOSTRO"); CCLOG("PARTE TOCADA DE MOSTRO"); }else{ CCLOG("NO TOCO PARTE MOSTRO"); } return true; }
void Drop::stopWave() { if (waveAction) stopAction(waveAction); setScale(1); }
int main(int argc, char **argv) { Aria::init(); argc = 3; argv[0] = ""; argv[1] = "-rp"; argv[2] = "/dev/ttyUSB0"; ArArgumentParser parser(&argc, argv); parser.loadDefaultArguments(); ArRobot robot; ArAnalogGyro gyro(&robot); ArSonarDevice sonar; ArRobotConnector robotConnector(&parser, &robot); if(!robotConnector.connectRobot()) { if(parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); Aria::exit(1); } } if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); Aria::exit(1); } imgdb.setRobot(&robot); int Rc; pthread_t slam_thread; Rc = pthread_create(&slam_thread, NULL, slam_event, NULL); if (Rc) { printf("Create slam thread failed!\n"); exit(-1); } ImageList* current = NULL; while (!current) current = imgdb.getEdge(); // current->person_point robot.addRangeDevice(&sonar); robot.runAsync(true); ArKeyHandler keyHandler; Aria::setKeyHandler(&keyHandler); robot.attachKeyHandler(&keyHandler); printf("You may press escape to exit\n"); robot.setAbsoluteMaxRotVel(30); ArActionStallRecover recover; ArActionBumpers bumpers; double minDistance=10000; // ArPose endPoint(point.x, point.z); // current->collect_x // current->collect_y // robot.getX() // robot.getY() // current = imgdb.getEdge(); // for (int i = 0; i < current->edge.size(); i++) { // for (int j = 0; j < current->edge[i].size() - 1; j++) { // double dis = sqrt(pow(current->edge[i][j].z,2)+(pow(current->edge[i][j].x,2))); // if(dis<minDistance){ // minDistance=dis; // } // } // } // 引入避障action,前方安全距离为500mm,侧边安全距离为340mm Avoid avoidSide("Avoid side", ArPose(0, 0), 800, 100, 1000*minDistance); robot.addAction(&recover, 100); robot.addAction(&bumpers, 95); robot.addAction(&avoidSide, 80); ArActionStop stopAction("stop"); robot.addAction(&stopAction, 50); robot.enableMotors(); robot.comInt(ArCommands::SOUNDTOG, 0); const int duration = 500000; bool first = true; int goalNum = 0; ArTime start; start.setToNow(); while (Aria::getRunning()) { current = imgdb.getEdge(); for (int i = 0; i < current->edge.size(); i++) { for (int j = 0; j < current->edge[i].size() - 1; j++) { // printf("i=%d\n",i); double dis = sqrt(pow(current->edge[i][j].z,2)+(pow(current->edge[i][j].x,2))); // printf("dis=%f,mindis=%f\n",dis,minDistance); if(dis<minDistance){ minDistance=dis; printf("min=%f\n",minDistance); } } } //引入避障action,前方安全距离为500mm,侧边安全距离为340mm // Avoid avoidSide("Avoid side", ArPose(0, 0), 800, 200, minDistance); // robot.addAction(&avoidSide,80); robot.lock(); if (first || avoidSide.haveAchievedGoal()) { first = false; goalNum++; printf("count goalNum = %d\n", goalNum); if (goalNum > 2){ goalNum = 1; // start again at goal #1 } // avoidSide.setGoal(ArPose(10000,0)); if(goalNum==1){ printf("zuobiaox=%f,zuobiaoy=%f\n",-current->person_point.z,current->person_point.x); avoidSide.setGoal(ArPose(1000*current->person_point.z, -1000*current->person_point.x)); printf("goalNum == 1\n\n"); } else if(goalNum==2){ printf("zuobiaox=%f,zuobiaoy=%f\n",-current->person_point.z,current->person_point.x); avoidSide.setGoal(ArPose(1000*current->person_point.z, -1000*current->person_point.x)); printf("goalNum == 2\n\n"); } } if(start.mSecSince() >= duration) { ArLog::log(ArLog::Normal, "%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000); avoidSide.cancelGoal(); robot.unlock(); ArUtil::sleep(3000); break; } robot.unlock(); ArUtil::sleep(100); } Aria::exit(0); return 0; }
VSCVWidget::VSCVWidget(s32 nId, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) { m_pStarted = FALSE; m_nId = nId; m_nPlayId = 0; m_pRenderBuffer = NULL; m_bDeviceDeleted = FALSE; m_bFocus = FALSE; m_lastMoveTime = 0; m_InstantPbMode = FALSE; m_pbThread = NULL; m_autoUpdate = TRUE; m_Render = RENDER_QT; m_DragStart = FALSE; m_PtzStart = FALSE; m_PtzEnable = FALSE; gettimeofday(&m_lastPtz, NULL); this->setAcceptDrops(true); m_pStop = new QAction(QIcon(tr(":/action/resources/stop.png")), tr("Stop"), this); connect(m_pStop, SIGNAL(triggered()), this, SLOT(stopAction())); m_pStop->setEnabled(false); m_pFloating = new QAction(QIcon(tr(":/action/resources/float.png")), tr("Float"), this); connect(m_pFloating, SIGNAL(triggered()), this, SIGNAL(ShowFloatingClicked())); m_pPTZ = new QAction(QIcon(tr(":/device/resources/dome.png")), tr("PTZ"), this); connect(m_pPTZ, SIGNAL(triggered()), this, SLOT(PTZEnable())); m_pRecord = new QAction(QIcon(tr("images/open.ico")), tr("RECORD"), this); //connect(m_pFloating, SIGNAL(triggered()), this, SIGNAL(ShowFloatingClicked())); m_pTabbed = new QAction(QIcon(tr(":/action/resources/tabbed.png")), tr("Tabbed"), this); connect(m_pTabbed, SIGNAL(triggered()), this, SIGNAL(ShowTabbedClicked())); m_pControlEnable = new QAction(QIcon(tr(":/action/resources/control_panel.png")), tr("Control Panel"), this); connect(m_pControlEnable, SIGNAL(triggered()), this, SIGNAL(ShowControlPanelClicked())); m_pDisplay1 = new QAction(QIcon(tr(":/action/resources/display.png")), tr("DISPLAY 1"), this); connect(m_pDisplay1, SIGNAL(triggered()), this, SLOT(showDisplay1())); m_pDisplay2 = new QAction(QIcon(tr(":/action/resources/display.png")), tr("DISPLAY 2"), this); connect(m_pDisplay2, SIGNAL(triggered()), this, SLOT(showDisplay2())); m_pDisplay3 = new QAction(QIcon(tr(":/action/resources/display.png")), tr("DISPLAY 3"), this); connect(m_pDisplay3, SIGNAL(triggered()), this, SLOT(showDisplay3())); m_pDisplay4 = new QAction(QIcon(tr(":/action/resources/display.png")), tr("DISPLAY 4"), this); connect(m_pDisplay4, SIGNAL(triggered()), this, SLOT(showDisplay4())); createContentMenu(); ui.setupUi(this); ui.videoControl->setVisible(false); //ui.widgetTimeline->hide(); /* Hide all the control button */ StopPlayUI(); //ui.videoControl->setMaximumHeight(20); m_videoWindow = (HWND)ui.video->winId(); setMouseTracking(true); connect(ui.video, SIGNAL(videoMouseMove(QMouseEvent *)), this, SLOT(videoMouseMove(QMouseEvent *))); connect(ui.video, SIGNAL(videoResize()), this, SLOT(videoResizeEvent())); connect(ui.pbInstantpb, SIGNAL( clicked() ), this, SLOT(instantPbClick())); connect(ui.widgetTimeline, SIGNAL( TimeLineChange(int) ), this, SLOT(TimeLineChanged(int))); ui.widgetTimeline->SetEnabled(FALSE); connect(ui.pbPause, SIGNAL( clicked() ), this, SLOT(InstantPbPause())); connect(ui.pbPlay, SIGNAL( clicked() ), this, SLOT(InstantPbPlay())); connect(ui.timelineZoom, SIGNAL( currentIndexChanged (int) ), this, SLOT(TimeLineLengthChanged(int))); ui.timelineZoom->setCurrentIndex (TIMELINE_LEN_5_MIN); m_Timer = new QTimer(this); connect(m_Timer,SIGNAL(timeout()),this,SLOT(UpdateVideoControl())); m_Timer->start(500); m_lastWidth = ui.video->width(); m_lastHeight = ui.video->height(); }
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if (!Layer::init()) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); /* * Task : Create a menu with single button. * Button should listen to the mouse, and close the application on click */ auto addDragObject = [this](const std::string& name, const int& shift, const Color3B& color) { auto label1 = Label::createWithTTF("BAUHS93.TTF", name); label1->setColor(color); auto labelMenuItem1 = MenuItemLabel::create(label1); labelMenuItem1->setPosition(Lazy::Common::VisibleRect::center() - Vec2(shift, shift)); labelMenuItem1->setRotation(45.0f); labelMenuItem1->setScale(1.5f); auto label2 = Label::createWithTTF("BAUHS93.TTF", name); label2->setColor(color); auto labelMenuItem2 = MenuItemLabel::create(label2); labelMenuItem2->setPosition(Lazy::Common::VisibleRect::center() - Vec2(shift + 30, shift + 30)); auto label3 = Label::createWithTTF("BAUHS93.TTF", name); label3->setColor(color); auto labelMenuItem3 = MenuItemLabel::create(label3); labelMenuItem3->setPosition(Lazy::Common::VisibleRect::center() - Vec2(shift + 50, shift + 50)); labelMenuItem3->setRotation(-45.0f); labelMenuItem3->setScale(0.5f); auto dragObject = Lazy::Common::DragObject::create({ labelMenuItem1, labelMenuItem2, labelMenuItem3 }); dragObject->onActivated = [this, label1, labelMenuItem1, label2, labelMenuItem2, label3, labelMenuItem3, dragObject]() { labelMenuItem1->stopAllActions(); labelMenuItem2->stopAllActions(); labelMenuItem3->stopAllActions(); auto rotateTo = RepeatForever::create(RotateBy::create(1.0, 360.0f)); auto rotateTo2 = RepeatForever::create(RotateBy::create(0.5, 360.0f)); auto rotateTo3 = RepeatForever::create(RotateBy::create(0.25, 360.0f)); labelMenuItem1->runAction(rotateTo); labelMenuItem2->runAction(rotateTo2); labelMenuItem3->runAction(rotateTo3); dragObject->onDeactivated = [this, label1, labelMenuItem1, rotateTo, label2, labelMenuItem2, rotateTo2, label3, labelMenuItem3, rotateTo3]() { labelMenuItem1->stopAction(rotateTo); labelMenuItem2->stopAction(rotateTo2); labelMenuItem3->stopAction(rotateTo3); auto rotateBack = RepeatForever::create(RotateTo::create(1.0, 0.0f)); auto rotateBack2 = RepeatForever::create(RotateTo::create(1.0, 0.0f)); auto rotateBack3 = RepeatForever::create(RotateTo::create(1.0, 0.0f)); labelMenuItem1->runAction(rotateBack); labelMenuItem2->runAction(rotateBack2); labelMenuItem3->runAction(rotateBack3); }; }; dragObject->setDrawBB(false); this->addChild(dragObject); }; addDragObject("Vlad", 0, Color3B::BLUE); addDragObject("Irina", 50, Color3B::RED); addDragObject("Eugene_Goncharuk", -100, Color3B::GREEN); return true; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); //-------------- M A I N D E L P R O G R A M A D E L R O B O T------------// //---------------------------------------------------------------------------------------------------------- //inicializaion de variables Aria::init(); ArArgumentParser parser(&argc, argv); parser.loadDefaultArguments(); ArSimpleConnector simpleConnector(&parser); ArRobot robot; ArSonarDevice sonar; ArAnalogGyro gyro(&robot); robot.addRangeDevice(&sonar); // presionar tecla escape para salir del programa ArKeyHandler keyHandler; Aria::setKeyHandler(&keyHandler); robot.attachKeyHandler(&keyHandler); printf("You may press escape to exit\n"); // uso de sonares para evitar colisiones con las paredes u // obstaculos grandes, mayores a 8cm de alto ArActionLimiterForwards limiterAction("speed limiter near", 300, 600, 250); ArActionLimiterForwards limiterFarAction("speed limiter far", 300, 1100, 400); ArActionLimiterTableSensor tableLimiterAction; robot.addAction(&tableLimiterAction, 100); robot.addAction(&limiterAction, 95); robot.addAction(&limiterFarAction, 90); // Inicializon la funcion de goto ArActionGoto gotoPoseAction("goto"); robot.addAction(&gotoPoseAction, 50); // Finaliza el goto si es que no hace nada ArActionStop stopAction("stop"); robot.addAction(&stopAction, 40); // Parser del CLI if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(1); } // Conexion del robot if (!simpleConnector.connectRobot(&robot)) { printf("Could not connect to robot... exiting\n"); Aria::exit(1); } robot.runAsync(true); // enciende motores, apaga sonidos robot.enableMotors(); robot.comInt(ArCommands::SOUNDTOG, 0); const int duration = 100000; //msec ArLog::log(ArLog::Normal, "Completados los puntos en %d segundos", duration/1000); bool first = true; int horiz = 1800; int vert = 380; int goalNum = 0; ArTime start; start.setToNow(); while (Aria::getRunning()) { robot.lock(); // inicia el primer punto if (first || gotoPoseAction.haveAchievedGoal()) { first = false; goalNum++; //cambia de 0 a 1 el contador if (goalNum > 7) goalNum = 1; //comienza la secuencia de puntos if (goalNum == 1) gotoPoseAction.setGoal(ArPose(horiz, vert*0)); else if (goalNum == 2) gotoPoseAction.setGoal(ArPose(0, vert*1)); else if (goalNum == 3) gotoPoseAction.setGoa l(ArPose(horiz, vert*2)+5); else if (goalNum == 4) gotoPoseAction.setGoal(ArPose(0, vert*3)); else if (goalNum == 5) gotoPoseAction.setGoal(ArPose(horiz, vert*4+5)); else if (goalNum == 6) gotoPoseAction.setGoal(ArPose(0, vert*5)); else if (goalNum == 7) gotoPoseAction.setGoal(ArPose(0, vert*0)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if(start.mSecSince() >= duration) { ArLog::log(ArLog::Normal, "%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000); gotoPoseAction.cancelGoal(); robot.unlock(); ArUtil::sleep(3000); break; } robot.unlock(); ArUtil::sleep(100); } // Robot desconectado al terminal el sleep Aria::shutdown(); return 0; //---------------------------------------------------------------------------------------------------------- // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_VENTANAROBOT, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_VENTANAROBOT)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }