int main() { printf("version 1.0 "); printf("moving forwrd 10 "); moveForward(10); printf("right angle right"); rightAngleFwd(RIGHT); moveForward(10); printf("click a button to continue"); while (a_button_clicked() == 0) { msleep(25); } printf("moving bckwrd 10 "); moveBackward(10); printf("right angle back right"); rightAngleBwd(RIGHT); moveBackward(10); printf("click a button to continue"); while (a_button_clicked() == 0) { msleep(25); } //printf("program finished, POMS should be in...\n"); return 0; }
// Self-test routines static void selfTest(void) { /* test behaviors */ turn(-90); sleep(5000); turn(90); sleep(5000); lfUpdateDisplay(SEARCH, -1, -1); turn(-45); sleep(2000); turn(-45); sleep(2000); turn(45); sleep(2000); turn(45); sleep(2000); lfUpdateDisplay(FOLLOW, 5, 15); moveForward(2, true); moveBackward(2, true); sleep(5000); moveForward(2, false); moveBackward(2, false); sleep(5000); }
task main() { motor[lift] = 0; //waitForStart(); initializeRobot(); int centerGoal; moveForward(2.5); wait10Msec(50); readSensor(&irSeeker); centerGoal = irSeeker.acDirection; displayTextLine(1, "D:%4d", irSeeker.acDirection); if(centerGoal >= 0 && centerGoal <= 3) { playSound(soundBeepBeep); turnRight(90); wait10Msec(50); moveForward(1.5); wait10Msec(50); } else if(centerGoal > 3 && centerGoal < 5) { playSound(soundDownwardTones); moveBackward(1); wait10Msec(50); turnRight(70); wait10Msec(50); moveForward(2); wait10Msec(50); } else if(centerGoal >= 5 && centerGoal <= 9) { playSound(soundFastUpwardTones); moveBackward(2); wait10Msec(50); turnRight(90); wait10Msec(50); moveForward(1); wait10Msec(50); } else { stopBot(); } }
Camera::Camera(Ogre::String camName, Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* window): scene_{sceneMgr}, rotX_{0}, rotY_{0}, direction_{Ogre::Vector3::ZERO}, rotSpeed_{0.2}, mvtSpeed_{0.0006} { cameraNode_ = scene_->getRootSceneNode()->createChildSceneNode(); cameraYawNode_ = cameraNode_->createChildSceneNode(); cameraPitchNode_ = cameraYawNode_->createChildSceneNode(); cameraRollNode_ = cameraPitchNode_->createChildSceneNode(); camera_ = scene_->createCamera(camName); cameraRollNode_->attachObject(camera_); viewport_ = window->addViewport(camera_); viewport_->setBackgroundColour(Ogre::ColourValue(0.4,0.4,0.4)); camera_->setAspectRatio(Ogre::Real(viewport_->getActualWidth()) / Ogre::Real(viewport_->getActualHeight())); subscribe("changeBackgroundColour", [this](std::string eventName, Arguments args){ viewport_->setBackgroundColour(Ogre::ColourValue(1,0,1)); }); subscribe("startScrollCamLeft", [this](std::string eventName, Arguments args){ moveLeft(true); }); subscribe("stopScrollCamLeft", [this](std::string eventName, Arguments args){ moveLeft(false); }); subscribe("startScrollCamUp", [this](std::string eventName, Arguments args){ moveForward(true); }); subscribe("stopScrollCamUp", [this](std::string eventName, Arguments args){ moveForward(false); }); subscribe("startScrollCamRight", [this](std::string eventName, Arguments args){ moveRight(true); }); subscribe("stopScrollCamRight", [this](std::string eventName, Arguments args){ moveRight(false); }); subscribe("startScrollCamDown", [this](std::string eventName, Arguments args){ moveBackward(true); }); subscribe("stopScrollCamDown", [this](std::string eventName, Arguments args){ moveBackward(false); }); subscribe("zoomCamera", [this](std::string eventName, Arguments args){ zoom(boost::any_cast<int>(args["Zrel"])); }); subscribe("unzoomCamera", [this](std::string eventName, Arguments args){ zoom(boost::any_cast<int>(args["Zrel"])); }); }
int main(void) { pinIO(); serialSetupUSB(); timerSetup(); motorSetup(); encSetup(); //infinete loop in which we count while(1) { //currentVelocity = velocityGet(); moveForward(16); delay(10); moveBackward(16); } //remain here forever, never end the main function. return 0; //we should never really return }
//the keyboard callback to change the values to the transforms void keyboard(unsigned char key, int x, int y ) { // printf("%c pressed\n", key); switch( key ) { case 'w': moveForward(); break; case 's': moveBackward(); break; case 'a': strafeLeft(); break; case 'd': strafeRight(); break; case 32: // space rise(); break; case 'c': fall(); break; case 'n': g_shadeType = g_shadeType == NORMAL ? PHONG : NORMAL; break; case 'q': case 'Q' : exit( EXIT_SUCCESS ); break; } //glutPostRedisplay(); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initPinOuts(); timersConfig(); while (1) { leftTurn(); __delay_cycles(500000); rightTurn(); __delay_cycles(500000); moveForward(); __delay_cycles(2500000); moveBackward(); __delay_cycles(2500000); leftTurn(); __delay_cycles(1000000); rightTurn(); __delay_cycles(1000000); } return 0; }
task main() { //Move the robot forward for 1000 encoder counts //at a speed of 50, then wait for half of a second // intake(); StartTask(moveArm); turnLeft(130,127); moveForward(1450, 127); // wait1Msec(500); //Turn the robot to the right for 285 encoder counts //at a speed of 25, then wait for half of a second // turnRight(370, 25); moveBackward(); //wait1Msec(500); //Turn the robot to the left for 285 encoder counts //at a speed of 25, then wait for half of a second StartTask(downArm); turnLeft(145, 127); // wait1Msec(500); moveForward(1800,127); turnRight(214,127); StartTask(moveArm); moveForward(350,127); motor[leftIntake] = 70; motor[rightIntake] = 70; wait1Msec(2000); }
task main() { for (int i = 1000; i<6000; i+=1500) { moveForward(100, i); moveBackward(100, i); } }
task main() { /*chooseProgram(); //start the program chooser switch (PROGID) { //handle the results from the program chooser case 1: FORWARD_LEFT_RIGHT = true; //debug("Auton prog set to FORWARD_LEFT_RIGHT"); break; case 2: FORWARD_RIGHT_LEFT = true; //debug("Auton prog set to FORWARD_RIGHT_LEFT"); break; case 3: //debug_clear(); //debug("Cleared Debug Stream"); break; default: FORWARD_LEFT_RIGHT = true; //debug("Auton prog defaulted to FORWARD_LEFT_RIGHT"); PlaySoundFile("Woops.rso"); break; } //end switch(PROGID)*/ moveForward(3000, 100); turnRight(2000, 100); moveForward(2000, 100); turnLeft(2000, 100); moveBackward(3000, 100); } //end task main
task autonomous() { //Move the robot forward for 1000 encoder counts //at a speed of 50, then wait for half of a second // intake(); StartTask(moveArm); turnLeft(130,127); moveForward(1450, 127); // wait1Msec(500); //Turn the robot to the right for 285 encoder counts //at a speed of 25, then wait for half of a second // turnRight(370, 25); moveBackward(); // wait1Msec(500); //Turn the robot to the left for 285 encoder counts //at a speed of 25, then wait for half of a second StartTask(downArm); turnLeft(145, 127); // wait1Msec(500); moveForward(1800,127); turnRight(214,127); StartTask(moveArm); moveForward(350,127); motor[leftIntake] = 70; motor[rightIntake] = 70; wait1Msec(2000); //AutonomousCodePlaceholderForTesting(); // Remove this function call once you have "real" code. }
/* * main.c */ void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initTimerOutputSignals(); configureA0andA1Timers(); __delay_cycles(1000000); //wait before the first instruciton so i have time to get away from the robot before it starts moving moveForward(); __delay_cycles(1000000); //delays between each movement to differentiate which movement is which moveBackward(); __delay_cycles(1000000); turnSmallRight(); __delay_cycles(1000000); turnSmallLeft(); __delay_cycles(1000000); turnBigLeft(); __delay_cycles(1000000); turnBigRight(); __delay_cycles(1000000); }
/* * main.c * Description: Makes the robot move in the corresponding directions. * The length of delay cycles after each function call determines how * long/far the robot moves in that particular direction. */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer InitPinsOut(); InitTimer(); while (1) { //move forward moveForward(); _delay_cycles(1000000); //move backward moveBackward(); _delay_cycles(1000000); //complete a small (<45 degree) right turn rightTurn(); _delay_cycles(500000); //complete a small (<45 degree) left turn leftTurn(); _delay_cycles(500000); //complete a large (>45 degree) right turn rightTurn(); _delay_cycles(1000000); //complete a large (>45 degree) left turn leftTurn(); _delay_cycles(1000000); } return 0; }
void pushOffRamp() { moveForward(1.5, 100); //drive forward and backward (make sure this doesnt drive us off the ramp) wait1Msec(200); moveBackward(1.5, 100); wait1Msec(200); PlaySound(soundBlip); }
void MainWindow::makeConnections() { connect(pt_videocapture, SIGNAL(positionUpdated(int)), ui->positionSlider, SLOT(setValue(int))); connect(ui->positionSlider, SIGNAL(sliderPressed()), pt_videocapture, SLOT(pause())); connect(ui->positionSlider, SIGNAL(sliderReleased(int)), pt_videocapture, SLOT(setPosition(int))); connect(ui->positionSlider, SIGNAL(sliderReleased(int)), pt_videocapture, SLOT(resume())); connect(pt_videocapture, SIGNAL(framesInFile(int)), ui->positionSlider, SLOT(setMaxValue(int))); connect(ui->resumeButton, SIGNAL(pressed()), pt_resumeAct, SLOT(trigger())); connect(ui->pauseButton, SIGNAL(pressed()), pt_pauseAct, SLOT(trigger())); connect(ui->backwardButton, SIGNAL(pressed()), pt_backwardAct, SLOT(trigger())); connect(ui->forwardButton, SIGNAL(pressed()), pt_forwardAct, SLOT(trigger())); connect(ui->speeddownButton, SIGNAL(pressed()), pt_speeddownAct, SLOT(trigger())); connect(ui->speedupButton, SIGNAL(pressed()), pt_speedupAct, SLOT(trigger())); connect(pt_videocapture, SIGNAL(positionUpdated(int)), ui->frameLCD, SLOT(display(int))); connect(pt_videocapture, SIGNAL(framesInFile(int)), ui->totalframesLCD, SLOT(display(int))); connect(pt_stasm, SIGNAL(frametimeUpdated(double)), ui->frametimeLCD, SLOT(display(double))); connect(pt_opencv, SIGNAL(snrUpdated(double)), ui->snrLCD, SLOT(display(double))); connect(pt_opencv, SIGNAL(contrastUpdated(double)), ui->contrastLCD, SLOT(display(double))); connect(pt_stasm, SIGNAL(eyesdistanceUpdated(double)), ui->eyesLCD, SLOT(display(double))); qRegisterMetaType<cv::Rect>("cv::Rect"); connect(pt_stasm, SIGNAL(facerectUpdated(cv::Rect)), ui->display, SLOT(updateSelection(cv::Rect))); //seriesanalyzer part connect(ui->dataseriaW, SIGNAL(stateChanged(bool)), this, SLOT(dataanalysconnection(bool))); connect(pt_seriesanalyzer, SIGNAL(seriesFound(DataSeria,uint,uint)), ui->dataseriaW, SLOT(updateSeries(DataSeria,uint,uint))); connect(ui->dataseriaW, SIGNAL(moveBackward()), pt_seriesanalyzer, SLOT(stepBackward())); connect(ui->dataseriaW, SIGNAL(moveForward()), pt_seriesanalyzer, SLOT(stepForward())); connect(ui->dataseriaW, SIGNAL(clearHistory()), pt_seriesanalyzer, SLOT(clearSeriesHistory())); }
GenericGeometry<SkinVertex> * CLODSkinnedMesh::getGeometry(uint vsplits) { HASSERT(vsplits >= 0 && vsplits <= numVertexSplits); if(isCached && vsplits == lastVertexSplits) return tmpGeometry; else if(isCached) { int difference = vsplits - lastVertexSplits; // how much vsplits has to be perfomed (can be negative, in that case we have to reverse the operations) std::vector<uint> counters(geometry->getNumSubMeshes()); for(int i = 0; i < geometry->getNumSubMeshes(); i++) { const ExtendableSubMesh * sm = (ExtendableSubMesh *)(tmpGeometry->getSubMesh(i)); counters[i] = sm->getNumIndices(); } if(difference > 0) return moveForward(difference, counters); else return moveBackward(-difference, counters); } lastVertexSplits = 0; std::vector<uint> counters(geometry->getNumSubMeshes()); for(int i = 0; i < geometry->getNumSubMeshes(); i++) { const SubMesh * sm = geometry->getSubMesh(i); ExtendableSubMesh * extSubMesh = (ExtendableSubMesh *)(tmpGeometry->getSubMesh(i)); counters[i] = sm->getNumIndices(); // overwrite previous changes std::copy(sm->getIndices(), sm->getIndices() + sm->getNumIndices(), extSubMesh->getIndices()); } return moveForward(vsplits, counters);; }
bool MotorsClass::changeDirection(uint8_t directionValue, uint16_t speed) { if (directionValue < DIRECTIN_FIRST || directionValue > DIRECTION_LAST) { return false; } MOTORS_DIRECTION direction = static_cast<MOTORS_DIRECTION>(directionValue); switch (direction) { case DIRECTION_STOP: stop(); break; case DIRECTION_FORWARD: moveForward(speed); break; case DIRECTION_BACKWARD: moveBackward(speed); break; case DIRECTION_LEFT: turnLeft(speed); break; case DIRECTION_RIGHT: turnRight(speed); break; default: break; } return true; }
/* * Goes forward, makes a full left and right turn, then makes *a half left and right turn, will eventually move it backwards. */ void basicFunctionality(){ pauseBoth(); pauseBoth(); pauseBoth(); moveBackward(); halt(); __delay_cycles(STRAIGHTTIME); moveForward(); __delay_cycles(STRAIGHTTIME); fullTurnLeft(); moveForward(); __delay_cycles(STRAIGHTTIME); fullTurnRight(); moveForward(); __delay_cycles(STRAIGHTTIME); halfTurnLeft(); moveForward(); __delay_cycles(STRAIGHTTIME); halfTurnRight(); moveForward(); __delay_cycles(2*STRAIGHTTIME); }
task main() { waitForStart(); moveForward(0.25, 80); wait10Msec(50); leftTwoWheelTurn(45, 50); wait10Msec(56); moveForward(41.5, 80); wait10Msec(50); rightTwoWheelTurn(45, 50); wait10Msec(135); //robot stopped in the third bucket from the right side of the pendulum stopMotors(); wait10Msec(100); /* motor[tiltingMotor] = 75; wait10Msec(98); motor[tiltingMotor] = 25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10); motor[conveyorMotor] = 100; wait10Msec(200); motor[conveyorMotor] = 0; wait10Msec(50); motor[tiltingMotor] = -35; wait10Msec(105); motor[tiltingMotor] = -25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10);*/ armUp(); wait10Msec(200); conveyorForward(); wait10Msec(200); conveyorStop(); wait10Msec(100); armDown(); wait10Msec(200); leftTwoWheelTurn(42, 50); wait10Msec(127); moveForward(16, 80); wait10Msec(50); rightTwoWheelTurn(48, 50); wait10Msec(53.5); moveForward(25, 80); wait10Msec(50); rightTwoWheelTurn(48, 50); wait10Msec(58); moveForward(36, 80); wait10Msec(50); leftTwoWheelTurn(53, 50); wait10Msec(115); moveBackward(49, 80); wait10Msec(50); //robot parked in the middle of the ramp }
/* * checks the direction the robot moved last (forward, backward, still) */ void checkDirection(int direction) { if(direction == FORWARD) { moveForward(1); } else if(direction == BACKWARD) { moveBackward(1); } else { stop(); } }
ssize_t Buffer::moveCursor(CursorId cursor, ssize_t relativeOffs) { if (relativeOffs > 0) { return moveForward(cursor, relativeOffs); } else if (relativeOffs < 0) { return -moveBackward(cursor, -relativeOffs); } else { return 0; } }
task main() { waitForStart(); stopMotors(); wait10Msec(500); moveForward(2, 80); wait10Msec(50); rightTwoWheelTurn(10, 50); wait10Msec(40); //robot stops at first bucket from the right side of the pendulum stopMotors(); wait10Msec(100); /* motor[tiltingMotor] = 75; wait10Msec(105); motor[tiltingMotor] = 25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10); motor[conveyorMotor] = 100; wait10Msec(200); motor[conveyorMotor] = 0; wait10Msec(50); motor[tiltingMotor] = -45; wait10Msec(110); motor[tiltingMotor] = -25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10);*/ armUp(); wait10Msec(200); conveyorForward(); wait10Msec(200); conveyorStop(); wait10Msec(100); armDown(); wait10Msec(200); moveForward(3, 80); wait10Msec(50); rightTwoWheelTurn(50, 50); wait10Msec(83); moveForward(25, 80); wait10Msec(50); leftTwoWheelTurn(48, 50); wait10Msec(58); moveForward(29, 80); wait10Msec(50); rightTwoWheelTurn(53, 50); wait10Msec(150); moveBackward(43, 80); wait10Msec(60); //robot parked in the middle of the ramp }
void FPcamera::Run(const double dt, float heightOffset) { if (dt > 0) { moveForward(dt, heightOffset, true); } else if (dt < 0) { moveBackward(abs(dt), heightOffset, true); } }
void GLES2Lesson::onNormalizedTouch(float x, float y) { if (x < 0.25f) { turnLeft(1.5f); } else if (x > 0.75f) { turnRight(1.5f); } if (y < 0.25f) { moveForward(0.1f); } else if (y > 0.75f) { moveBackward(0.1f); } }
void loop() { val = analogRead(A0); if (val > 540) { // move faster the higher the value from the potentiometer delayTime = 2048 - 1024 * val / 512 + 1; moveForward(); } else if (val < 480) { // move faster the lower the value from the potentiometer delayTime = 1024 * val / 512 + 1; moveBackward(); } else { delayTime = 1024; } }
task main() { waitForStart(); moveForward(2, 80); wait10Msec(50); leftTwoWheelTurn(45, 50); wait10Msec(13); //positioned in first bucket from the left side of the pendulum stopMotors(); wait10Msec(50); /* motor[tiltingMotor] = 70; wait10Msec(105); motor[tiltingMotor] = 25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10); motor[conveyorMotor] = 100; wait10Msec(300); motor[conveyorMotor] = 0; wait10Msec(50); motor[tiltingMotor] = -55; wait10Msec(80); motor[tiltingMotor] = -25; wait10Msec(5); motor[tiltingMotor] = 0; wait10Msec(10);*/ armUp(); wait10Msec(200); conveyorForward(); wait10Msec(200); conveyorStop(); wait10Msec(100); armDown(); wait10Msec(200); leftTwoWheelTurn(45, 50); wait10Msec(60); moveForward(54, 80); wait10Msec(50); leftTwoWheelTurn(90, 50); wait10Msec(95); moveBackward(46, 100); wait10Msec(70); //robot parked in the middle of the ramp }
task main() { int distanceBack = 1; if (getBumperValue(bumpSwitch) = 1) { int rightEncoder = getMotorEncoder(rightMotor); while ((getMotorEncoder(rightMotor)) > (getMotorEncoder(rightMotor)-distanceBack)) { moveBackward(SLOW); } void armClose(); } }
int findIRBeacon() { int dir; int i; for (i = 0; i < 4; i++) { moveBackward(travelDistance[i], 50); wait1Msec(500); dir = HTIRS2readACDir(IRSeeker); showIRSegment(dir); nxtDisplayTextLine(2, "Reading %d", dir); if (dir == 5) { return i; } } return -1; }
task main() { int basketNumber; bool done = false; initializeRobot(); waitForStart(); // Wait for the beginning of autonomous phase. wait1Msec(10000); disableDiagnosticsDisplay(); eraseDisplay(); basketNumber = findIRBeacon(); nxtDisplayTextLine(5, "Beacon #%d", basketNumber); wait1Msec(300); if (basketNumber != -1) { if (compensation[basketNumber] < 0) { moveForward(abs(compensation[basketNumber]), 60); } else { moveBackward(compensation[basketNumber], 60); } /*for (int i = 0; i <= basketNumber; i++) { displayCaution(); wait1Msec(500); displayBackward(); wait1Msec(500); } displayRestingPulse(); */ dumpBlock(); } else { basketNumber = 3; } //moveToRamp(basketNumber); while (true) {} }
void View::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Right) { // Zoom in. int steps = 1; if (event->modifiers() == Qt::ControlModifier) steps = 10; if (event->modifiers() == Qt::ShiftModifier) steps = 100; moveForward(steps); } else if (event->key() == Qt::Key_Left) { // Zoom out. int steps = 1; if (event->modifiers() == Qt::ControlModifier) steps = 10; if (event->modifiers() == Qt::ShiftModifier) steps = 100; moveBackward(steps); } else if (event->key() == Qt::Key_S) { if (event->modifiers() == Qt::ControlModifier) { /* * Render SVG. */ QString fileName = QFileDialog::getSaveFileName(this, "Save SVG", QString(), "SVG Files (*.svg)"); QSvgGenerator generator; generator.setFileName(fileName); generator.setSize(viewport()->rect().size()); generator.setViewBox(viewport()->rect()); // Temporarily give legs and edges non-cosmetic pens while rendering. foreach (QGraphicsLineItem *leg, m_legs) { QPen pen = leg->pen(); pen.setCosmetic(false); pen.setWidthF(1.0/transform().m11()); leg->setPen(pen); } foreach (QGraphicsLineItem *edge, m_edges) { QPen pen = edge->pen(); pen.setCosmetic(false); pen.setWidthF(1.0/transform().m11()); edge->setPen(pen); }