/*
 * main
 * main function of the robot
 */
task main(){
    initFlags();
    initClamp();
    initHitch();
    startTask(task_run_drivemode);
    while(true){

        //Check if we should drive with slow sleeds.
        slow_multiplier = 1.0 - (vexRT[JOY_BTN_SLOW] * SLOW_SPEED_MULTIPLIER);

        //Check if we should switch the drivemode
        checkSwitchDrivemode();

        checkSwitchFlagMode();

        //Call the Arm control method
        runArm();
        //Call the Claw control method
        runClamp();
		//Call the Hitch control method
        runHitch();
		//Call the task handling method
        checkRunModeTask();
    }
}
rspfRefPtr<rspfImageData> rspfBandClipFilter::getTile(
   const rspfIrect& rect,
   rspf_uint32 resLevel)
{
   if(!theInputConnection)
   {
      return NULL;
   }
   
   rspfRefPtr<rspfImageData> data =
      theInputConnection->getTile(rect, resLevel);
   if(!data.get())
   {
      return data;
   }
   rspfDataObjectStatus status = data->getDataObjectStatus();
   if((status != RSPF_NULL) &&
      (status != RSPF_EMPTY))
   {
      rspf_uint32 dw = data->getWidth();
      rspf_uint32 dh = data->getHeight();
      rspf_uint32 db = data->getNumberOfBands();

      rspf_uint32 tw = theTile->getWidth();
      rspf_uint32 th = theTile->getHeight();
      rspf_uint32 tb = theTile->getNumberOfBands();

      if(((tw*th)!=(dw*dh))||
         (tb != db))
      {
         theTile = new rspfImageData(this,
                                      RSPF_NORMALIZED_FLOAT,
                                      db,
                                      dw,
                                      dh);
         theTile->initialize();
      }

      if(getNumberOfValues() != theTile->getNumberOfBands())
      {
         // Should this go on??? (drb)
         rspfNotify(rspfNotifyLevel_WARN)
            << "rspfBandClipFilter::getTile\n"
            << "getNumberOfValues() != theTile->getNumberOfBands"
            << endl;
      }
      
      data->copyTileToNormalizedBuffer(static_cast<float*>(theTile->getBuf()));
      theTile->setDataObjectStatus(data->getDataObjectStatus());
      
      switch(theClipType)
      {
         case rspfBandClipType_CLIP:
         {
            runClip();
            break;
         }
         case rspfBandClipType_CLAMP:
         {
            runClamp();
            break;
         }
         case rspfBandClipType_LINEAR_STRETCH:
         {
            runLinearStretch();
            break;
         }
         case rspfBandClipType_MEDIAN_STRETCH:
         {
            runMedianStretch();
            break;
         }
         default:
            break;
      }
      data->copyNormalizedBufferToTile(static_cast<float*>(theTile->getBuf()));
   }
   
   return data;
}