// 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); }
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; }
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 task main() { resetEncoders(); ClearTimer(T1); while (true){ if (time1[T1]%5000 == 0) resetEncoders(); if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 <= -0.5*in && (nMotorEncoder[Left]+nMotorEncoder[Right])/2 > -2*in){ moveForward(30); } if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 >= 0.5*in && (nMotorEncoder[Left]+nMotorEncoder[Right])/2 < 2*in){ moveForward(-30); } if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 >= 2*in){ moveForward(-100); } if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 <= -2*in){ moveForward(100); } if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 > -0.5*in){ if ((nMotorEncoder[Left]+nMotorEncoder[Right])/2 < 0.5*in){ brake(); } } } }
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
/* * 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); }
glm::mat4 Camera::applyCamMatrix() { switch(keyState){ case KEY_STATE_FORWARD: if(velocity<=MAX_VELOCITY)velocity+=MOVE_STEP; moveForward(); break; case KEY_STATE_BACKWARD: if(velocity>=-MAX_VELOCITY)velocity-=MOVE_STEP; moveForward(); break; case KEY_STATE_LEFT: moveLeft(); break; case KEY_STATE_RIGHT: moveRight(); break; default: //std::cout<<velocity<<std::endl; if(velocity<-MOVE_STEP || velocity>MOVE_STEP){ velocity*=0.96f; moveForward(); } break; } glm::mat4 retMat = glm::rotate(angleXZ, glm::vec3(0.0f, 1.0f, 0.0f)); retMat *= glm::rotate(angleYZ, glm::vec3(1.0f, 0.0f, 0.0f)); retMat *= glm::translate(-pos.x, -pos.y, -pos.z); return retMat; }
void Camera::moveKeyboard() { // you may change key controls for the interactive // camera controls here, make sure you document your changes // in your README file if (Fl::event_key('w')) moveForward(+0.05); if (Fl::event_key('s')) moveForward(-0.05); if (Fl::event_key('a')) moveSideways(-0.05); if (Fl::event_key('d')) moveSideways(+0.05); if (Fl::event_key(FL_Up)) moveVertical(+0.05); if (Fl::event_key(FL_Down)) moveVertical(-0.05); if (Fl::event_key(FL_Left)) rotateYaw(+0.05); if (Fl::event_key(FL_Right)) rotateYaw(-0.05); if (Fl::event_key(FL_Page_Up)) rotatePitch(+0.05); if (Fl::event_key(FL_Page_Down)) rotatePitch(-0.05); }
void Camera::cameraInput(float deltaTime) { float speed = 0.001f; if (GetAsyncKeyState('W') & 0x8000) { moveForward(speed); } if (GetAsyncKeyState('A') & 0x8000) { strafe(-speed); } if (GetAsyncKeyState('S') & 0x8000) { moveForward(-speed); } if (GetAsyncKeyState('D') & 0x8000) { strafe(speed); } if (GetAsyncKeyState('X') & 0x8000) { moveVertically(-speed); } if (GetAsyncKeyState(VK_SPACE) & 0x8000) { moveVertically(speed); } }
/* * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initRobot(); modTimer(70, 40); moveForward(); P1DIR |= (BIT0 | BIT6); for (;;) { if (isRightClose() == FALSE) { P1OUT &= ~BIT0; P1OUT |= BIT6; halfLeft(); __delay_cycles(100000); } else if (isCenterClose() == FALSE) { halfLeft();; P1OUT &= ~BIT6; P1OUT |= BIT0; } else { P1OUT &= ~BIT0; P1OUT &= ~BIT6; moveForward(); } } return 0; }
void RobotManager::moveToStartPoint(WayPoint* waypoint) { double x, y, deltaX, deltaY, yaw, x1, y1; x = robot->GetX(); y = robot->GetY(); deltaX = waypoint->x_Coordinate - x; deltaY = waypoint->y_Coordinate - y; x1 = waypoint->x_Coordinate; y1 = waypoint->y_Coordinate; if(deltaX > 0) yaw = 0; else if(deltaX < 0) yaw = MathHelper::ConvertDegreeToRadian(180); xyPosition newPos(x1, y); cout<<"start waypoint x: "<<x1<<","<<y<<endl; moveForward(newPos, yaw, 0, true); robot->SetSpeed(0,0); if(deltaY > 0 ) yaw = MathHelper::ConvertDegreeToRadian(90); else yaw = MathHelper::ConvertDegreeToRadian(-90); xyPosition newPos1(x1, y1); cout<<"start waypoint y: "<<x1<<","<<y1<<endl; moveForward(newPos1, yaw, 0, true); robot->SetSpeed(0,0); cout<<"Reached to start WayPoint destination"<<endl; }
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);; }
int alignToBranch(int x){ int result = x; int isLineDetected = 0; turnRight(); moveForward(300); if (x==3) { return 4; } //Cari Branch terdekat hingga maksimal 3 branch isLineDetected = alignToLine(); while ( !isLineDetected && (result != 3) ){ moveForward(-300); turnLeft(); moveForward(300); result++; isLineDetected = alignToLine(); } result++; //Kasus khusus jika terdeteksi sudut tumpul if (isLineDetected == 2) { result = result * (-1); } return result; }
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. }
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 }
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 }
task main() { displayLCDCenteredString(0, "Started"); moveForward(100, 3000); turnX(LEFT, 100, _90DEG); moveForward(100, 3200); turnX(RIGHT, 100, _90DEG); moveForward(100, 1500); turnX(RIGHT, 100, _90DEG); moveForward(100, 1500); displayLCDCenteredString(0, "Finished"); }
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"])); }); }
task main() { initializeRobot(); waitForStart(); // Wait for the beginning of autonomous phase. moveForward((1400*9),100); turnRight((1400*6),80); moveForward((1400*16),-100); turnLeft((1400*6),80); moveForward((1400*2),100); turnRight((1400*6),80); moveForward((1400*0.5),-100); }
void Model::initialized() { loadImage(); floorLevel = 0; size = 0; thr = shr = 0; heliWidth = 5; tRadius = 8; poly = 0; PI = 3.1415926535897932384626433832795 ; numVertices = 360; rotZ = 0; accel = 1; roadA = 0; roadX = 0; roadZ = 0; roadY = floorLevel; rotZConstant = 5; accelConstant = 2.5; accelLimit = 8; running = 0; angle = -90; moveConstant = 0.5; iteration = 90; cLocation = 0; engWarn = 0; lap = 0; moveForward(); bb_heli.updateAdd(roadX,roadY,roadZ); }
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 }
/* * 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); }
task main() { for (int i = 1000; i<6000; i+=1500) { moveForward(100, i); moveBackward(100, i); } }
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; }
//x and y in meters void driveToWaypoint (float new_x, float new_y) { float dx = new_x - x; float dy = new_y - y; float targetAngle = 0; if (dy != 0) { targetAngle = atan( dx / dy ); } else { targetAngle = PI/2; } //SW quadrant if(dy < 0 && dx >= 0) { targetAngle += PI; } //NW if (dy <= 0 && dx < 0) { targetAngle -= PI; } if(dy > 0 && dx < 0) { targetAngle = -atan( abs(dx) / dy ); } float newAngle = targetAngle - theta; //wait1Msec(1000); turnNDegrees(newAngle); moveForward(sqrt((dx*dx) + (dy*dy))); }
task main () { nMotorEncoder[motorB]=0; moveForward (1800); turnRight (); nMotorEncoder[motorB]=0; moveForward (1800); turnRight (); nMotorEncoder[motorB]=0; moveForward (1800); turnRight (); nMotorEncoder[motorB]=0; moveForward (1800); turnRight (); }
//x and y in meters void navigateToWaypoint (float new_x, float new_y) { //new_x *= 100; //new_y *= 100; float dx = new_x - x; float dy = new_y - y; float newAngle = calculateAngle(dx, dy); float distanceToMove = calculateDistance(dx, dy); float step = 20; float moved = 0; while (distanceToMove > 0) { dx = new_x - x; dy = new_y - y; newAngle = calculateAngle(dx, dy); distanceToMove = calculateDistance(dx, dy); turnNDegrees(newAngle); moved = step < distanceToMove ? step : distanceToMove; moveForward(moved); //distanceToMove = distanceToMove - moved; } }
task main() { //Display nxtDisplayCenteredTextLine(0, "PMX robot-test"); nxtDisplayCenteredBigTextLine(1, "MOTOR"); nxtDisplayCenteredTextLine(3, "MotorWithPID"); // Configuration Motor nPidUpdateInterval = 10; nPidUpdateInterval12V = 10; nPidUpdateIntervalNxt = 10; nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg; //RIGHT nMotorPIDSpeedCtrl[motorC] = mtrSpeedReg; //LEFT nMaxRegulatedSpeed12V = 750; // Execution //decrBSpeedAtStart = 3; moveForward(-300); //turn(90); //decrBSpeedAtStart = 3; //moveForward(10); motor[motorA] = 0;//TODO Stop() motor[motorC] = 0; // End }
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; }