void PGE_QuestionBox::exec()
{
    updateControllers();
    restart();
    while(running)
    {
        Uint32 start_render=SDL_GetTicks();

        update(uTickf);
        updateControllers();
        PGE_BoxBase::render();
        render();
        glFlush();
        PGE_Window::rePaint();

        if(uTick > (signed)(SDL_GetTicks() - start_render))
                SDL_Delay(uTick - (SDL_GetTicks()-start_render) );
    }
}
Exemple #2
0
//-----------------------------------------------------------------------------
void CCBRobot::run()
{
  if ( not mFgInitialized ) {
    PRT_WARN0( "Robot is not initialized, call init() first" );
    return;
  }

  while ( mFgRunning ) {
    // get data from ICreate
    //printf("mLastLoopDuration %f \n",mLastLoopDuration);
    if ( mCBDriver->readSensorData( mLastLoopDuration ) == 1 ) {

      // update all devices
      if ( mCBDrivetrain )
        mCBDrivetrain->updateData( mUpdateInterval );
      if ( mCBPowerPack )
        mCBPowerPack->updateData( mLastLoopDuration );
      if ( mCBLaser )
        mCBLaser->updateData( mLastLoopDuration );
      if ( mCBLights )
        mCBLights->updateData( mLastLoopDuration );
      if ( mCBSound )
        mCBSound->updateData( mLastLoopDuration );
      if ( mCBIrSensor )
        mCBIrSensor->updateData( mLastLoopDuration );
      if ( mCBTextDisplay )
        mCBTextDisplay->updateData( mLastLoopDuration );
      if ( mCBBumper )
        mCBBumper->updateData( mLastLoopDuration );
      if ( mCBWallSensor )
        mCBWallSensor->updateData( mLastLoopDuration );
      if ( mCBWheelDropSensor )
        mCBWheelDropSensor->updateData( mLastLoopDuration );
      if ( mCBCliffSensor )
        mCBCliffSensor->updateData( mLastLoopDuration );
      if ( mCBOverCurrentSensor )
        mCBOverCurrentSensor->updateData( mLastLoopDuration );
      if ( mCBFrontFiducial )
        mCBFrontFiducial->updateData( mLastLoopDuration );
      if ( mCBTopFiducial )
        mCBTopFiducial->updateData( mLastLoopDuration );
      if ( mCBPhotoSensor )
        mCBPhotoSensor->updateData( mLastLoopDuration );
      if ( mCBCreateButton )
        mCBCreateButton->updateData( mLastLoopDuration );
      if ( mCBVirtualWall )
        mCBVirtualWall->updateData( mLastLoopDuration );

      updateDevices();
      // Low side drivers updateData() is empty, no need to call it here
      //if ( mCBLowSideDriver )
      //  mCBLowSideDriver->updateData();
    }
    // update all registered controllers
    updateControllers();

    //******************************************************
    // last step - keep everything in sync
    synchronize( mUpdateInterval );
  } // while
}
Exemple #3
0
void Object::update(int deltaMs)
{
    updateControllers(deltaMs);
}
Exemple #4
0
task main()
{
  initializeRobot();
  waitForStart();   // wait for start of tele-op phase

  while (true)
  {
    updateControllers();

    //========== handle drive ==========
    calculateDrive(joystick.joy1_x1, joystick.joy1_y1);

    if (ControllerButtonPressed(BUTTON_LB, CONTROLLER_1)) {
      driveSetPower(30);
    } else if (ControllerButtonReleased(BUTTON_LB, CONTROLLER_1)) {
      driveSetPower(100);
    }

    //========== handle lift ==========
    if (ControllerButtonDown(BUTTON_X, CONTROLLER_1)) {
      liftBottomPositionSafety();
    } else if (ControllerButtonDown(BUTTON_Y, CONTROLLER_1)) {
      liftDumpPositionSafety();
    } else if (ControllerButtonDown(BUTTON_RSTICK, CONTROLLER_1)) {
      liftHangPositionSafety();
    } else {
      liftUpSpeed(joystick.joy1_y2);
    }

    //========== handle bucket ==========
    if (ControllerButtonPressed(BUTTON_RB, CONTROLLER_1)) {
      bucketIncrementState();
    } else if (ControllerButtonPressed(BUTTON_RT, CONTROLLER_1)) {
      bucketDecrementState();
    }

    //========== handle spinner ==========
    if (ControllerButtonPressed(BUTTON_START, CONTROLLER_1)) {
      spinnerOut();
    } else if (ControllerButtonPressed(BUTTON_BACK, CONTROLLER_1)) {
      spinnerIn();
    }

    if (ControllerButtonPressed(BUTTON_A, CONTROLLER_1)) {
      spinnerSpinCClockwise();
    } else if (ControllerButtonReleased(BUTTON_A, CONTROLLER_1)) {
      spinnerStop();
    }

    if (ControllerButtonPressed(BUTTON_B, CONTROLLER_1)) {
      spinnerAlignCClockwise();
    } else if (ControllerButtonReleased(BUTTON_B, CONTROLLER_1)) {
      spinnerStop();
    }

    //========== handle PTO ==========
    if (ControllerHatPressed(BUTTON_HAT_LEFT, CONTROLLER_1)) {
      hangingPTOEngage();
    }
    if (ControllerHatPressed(BUTTON_HAT_RIGHT, CONTROLLER_1)) {
      hangingPTODisengage();
    }
    if (ControllerButtonPressed(BUTTON_LT, CONTROLLER_1)) {
      hangingPTOEngage();
    } else if (ControllerButtonReleased(BUTTON_LT, CONTROLLER_1)) {
      hangingPTODisengage();
    }

    //========= handle Ratchet ==========
    if (ControllerHatPressed(BUTTON_HAT_UP, CONTROLLER_1)) {
      hangingRatchetLock();
    }
    if (ControllerHatPressed(BUTTON_HAT_DOWN, CONTROLLER_1)) {
      hangingRatchetUnlock();
    }

    //========== debug beep ==========
    if (ControllerButtonDown(BUTTON_LSTICK, CONTROLLER_1)) {
      PlayImmediateTone(4186, 1);
    }

    //========== EMERGENCY BACKUP FUNCTIONS!!! ==========
      //dump block in flipper
    if (ControllerButtonPressed(BUTTON_B, CONTROLLER_2)) {
      flipperDump();
    } else if (ControllerButtonReleased(BUTTON_B, CONTROLLER_2)) {
      flipperStorage();
    }

      //trim bucket positions
    if (ControllerButtonPressed(BUTTON_RB, CONTROLLER_2)) {
      bucketTrimUp();
    } else if (ControllerButtonPressed(BUTTON_RT, CONTROLLER_2)) {
      bucketTrimDown();
    }


  }
}