task main() { int timeToWait = requestTimeToWait(); initializeRobot(); waitForStart(); disableDiagnosticsDisplay(); //Initialize the gyro and turning GyroInit(g_Gyro, gyro, 0); PidTurnInit(g_PidTurn, leftDrive, rightDrive, MIN_TURN_POWER, g_Gyro, TURN_KP, TURN_TOLERANCE); countdown(timeToWait); //Start actual movement code moveForwardInches(60,43);//initial forwards turn(g_PidTurn,45,20); clearEncoders(); wait1Msec(50); const int totalTics = 6806;//total tics from before IR to end- CHANGED FOR LESSENED AMOUNT OF FORWARDS const int ticsToCenter = 3663;//tics from start to central beam const int ticsToSubtract = 1665;//failsafe, may still need testing //finding IR while(HTIRS2readACDir(IR) != 4 && (abs(nMotorEncoder[leftDrive]) < totalTics - ticsToSubtract)){ //finds the beacon zone 4 (rough) //nxtDisplayCenteredTextLine(5,"Direction:%d",HTIRS2readACDir(IR)); startBackward(27); } stopDrive(); wait1Msec(300); while(HTIRS2readACDir(IR) != 5 && (abs(nMotorEncoder[leftDrive]) < totalTics - ticsToSubtract)){ //slow down to look for basket (fine) startForward(15); } int currentPosition = abs(nMotorEncoder[leftDrive]); if (currentPosition > ticsToCenter)//check where we are moveForwardInchesNoReset(20, 6);//move forwards 5 inches (buckets 1 and 2) else moveForwardInchesNoReset(20, 3);//forwards 3 inches (buckets 3 and 4) stopDrive();//stops robot servo[dumper] = 30;//dumps the block motor[lift]= 50;//starts the lift up wait1Msec(700); motor[lift]= 0;//stops lift servo[dumper] = servoRestPosition;//resets servo int ticsToMove= totalTics - abs(nMotorEncoder[leftDrive]);//tics left after IR displayCenteredTextLine(0,"TTM: %d", ticsToMove); moveBackwardTics(90, ticsToMove); //move to end after IR turn(g_PidTurn, -87,40); //turn to go towards ramp moveForwardInches(90, 44, false, LEFTENCODER); //forwards to ramp turn(g_PidTurn, 95, 40); //turn to face ramp moveForwardInches(90, 45, false, LEFTENCODER);//onto ramp motor[lift]= -50;//starts the lift down wait1Msec(500); motor[lift]= 0;//stops lift while(true){} }
GlPictureFlow::GlPictureFlow(GlObject* parent) : GlObject(parent) { setGeometry(0,0,800,300); setPercent(0); for_backward = &GlPictureFlow::draw_forward; buttonLeft = new GlButton(this); buttonLeft->setGeometry(280,270,60,30); buttonLeft->setBackGroundPixmap(QPixmap(":/images/pictureFlowLeft.png")); buttonLeft->setBackGroundPixmapPressed(QPixmap(":/images/pictureFlowLeftPressed.png")); buttonLeft->setText("<"); connect(buttonLeft, SIGNAL(clicked()), this, SLOT(startForward())); buttonRigth = new GlButton(this); buttonRigth->setGeometry(460,270,60,30); buttonRigth->setBackGroundPixmap(QPixmap(":/images/pictureFlowRigth.png")); buttonRigth->setBackGroundPixmapPressed(QPixmap(":/images/pictureFlowRigthPressed.png")); buttonRigth->setText(">"); connect(buttonRigth, SIGNAL(clicked()), this, SLOT(startBackward())); buttonTracks = new GlButton(this); buttonTracks->setGeometry(340,270,120,30); buttonTracks->setBackGroundPixmap(QPixmap(":/images/button120.png")); buttonTracks->setBackGroundPixmapPressed(QPixmap(":/images/button120Pressed.png")); buttonTracks->setText("Tracks"); connect(buttonTracks, SIGNAL(clicked()), this, SIGNAL(buttonTracks_Clicked())); timeLine = new QTimeLine(350, this); timeLine->setLoopCount(1); timeLine->setFrameRange(0, 100); timeLine->setCurveShape(QTimeLine::EaseInCurve); connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(newPercent(int))); connect(timeLine, SIGNAL(finished()), this, SLOT(done())); distShort = 50; distLong = 150; sizeSmall = 130; sizeBig = 150; pt0.setX(50); pt0.setY(150); pt1.setX(100); pt1.setY(150); pt2.setX(150); pt2.setY(150); pt3.setX(200); pt3.setY(150); pt4.setX(250); pt4.setY(150); pt5.setX(400); pt5.setY(150); pt6.setX(750); pt6.setY(150); pt7.setX(700); pt7.setY(150); pt8.setX(650); pt8.setY(150); pt9.setX(600); pt9.setY(150); pt10.setX(550); pt10.setY(150); pt11.setX(400); pt11.setY(150); }