/* ============================================================================= main task with some testing code */ task main() { // Standard range is set to short range bool shortrange = true; tObstacleZone zone = MSSUMO_NONE; nNxtButtonTask = -2; eraseDisplay(); displayCenteredTextLine(0, "Mindsensors"); displayCenteredBigTextLine(1, "SUMO Eyes"); displayCenteredTextLine(3, "Test 1"); displayCenteredTextLine(5, "Press enter to"); displayCenteredTextLine(6, "switch between"); displayCenteredTextLine(7, "ranges"); sleep(2000); eraseDisplay(); // Set the sensor to short range MSSUMOsetShortRange(HTMSSUMO); while(true) { if (time1[T1] > 1000) { if (shortrange == false) { // set the sensor to short range and display this MSSUMOsetShortRange(HTMSSUMO); displayClearTextLine(1); displayTextLine(1, "Short range"); shortrange = true; } else { // set the sensor to long range and display this MSSUMOsetLongRange(HTMSSUMO); displayClearTextLine(1); displayTextLine(1, "Long range"); shortrange = false; } playSound(soundBeepBeep); while(bSoundActive) time1[T1] = 0; } while(nNxtButtonPressed != kEnterButton) { // Read the zone data zone = MSSUMOreadZone(HTMSSUMO); switch (zone) { case MSSUMO_FRONT: displayCenteredBigTextLine(4, "FRONT"); break; case MSSUMO_LEFT: displayCenteredBigTextLine(4, "LEFT"); break; case MSSUMO_RIGHT: displayCenteredBigTextLine(4, "RIGHT"); break; case MSSUMO_NONE: displayCenteredBigTextLine(4, "NONE"); break; } sleep(50); } } }
task main() { StartTask(USNEW); StartTask(USOLD); StartTask(pAxies); MSSUMOsetShortRange(HTMSSUMO); while(true) { runSensors(); nxtDisplayCenteredBigTextLine(1, "X: %d", xA); nxtDisplayCenteredBigTextLine(3, "Y: %d", yA); nxtDisplayCenteredBigTextLine(5, "Z: %d", zA); zone = MSSUMOreadZone(HTMSSUMO); switch (zone) { case MSSUMO_FRONT: allStop(); break; case MSSUMO_LEFT: turnRight(); break; case MSSUMO_RIGHT: turnLeft(); break; case MSSUMO_NONE: allGo(); break; } if ((us_NewResult < 14 ) || ( us_OldResult < 14 )) { sonarObsticalCheck(1); } if ( xA < -25) { allStall(); wait1Msec(500); allBack(); wait1Msec(1000); sonarObsticalCheck(3); } if ( yA < -25) { allStall(); wait1Msec(500); allBack(); wait1Msec(1000); sonarObsticalCheck(3); } } }
//Lets Get this thing moving! task main() { // Start up the two sonar sensors and their config files StartTask(USNEW); StartTask(USOLD); //Start up the IDMU config StartTask(pAxies); // Set Sumo to Long Range MSSUMOsetShortRange(HTMSSUMO); while(true) { zone = MSSUMOreadZone(HTMSSUMO); // Check front IR sensor LEFT FRONT RIGHT switch (zone) { case MSSUMO_FRONT: allStop(); break; case MSSUMO_LEFT: turnRight(); break; case MSSUMO_RIGHT: turnLeft(); break; case MSSUMO_NONE: allGo(); break; } // Check left and right sonar sensors for objects if ((us_NewResult < 12 ) || ( us_OldResult < 12 )){ sonarObsticalCheck(1); } else if ( ( yA > 35 ) || ( xA > 35 ) ){ allStall(); wait1Msec(500); allBack(); wait1Msec(1000); sonarObsticalCheck(3); //checkLevel(); } } }
/* ============================================================================= main task with some testing code */ task main() { // Standard range is set to short range bool shortrange = true; tObstacleZone zone = 0; nNxtButtonTask = -2; eraseDisplay(); nxtDisplayCenteredTextLine(0, "Mindsensors"); nxtDisplayCenteredBigTextLine(1, "SumoEyes"); nxtDisplayCenteredTextLine(3, "Test 2"); nxtDisplayCenteredTextLine(5, "Press enter to"); nxtDisplayCenteredTextLine(6, "switch between"); nxtDisplayCenteredTextLine(7, "ranges"); wait1Msec(2000); eraseDisplay(); // Set the sensor to short range MSSUMOsetShortRange(HTMSSUMO); nxtDisplayRICFile(0, 0, "sumonone.ric"); while(true) { if (time1[T1] > 1000) { if (shortrange == false) { // set the sensor to short range and display this MSSUMOsetShortRange(HTMSSUMO); nxtDisplayCenteredTextLine(7, "Short range"); shortrange = true; } else { // set the sensor to long range and display this MSSUMOsetLongRange(HTMSSUMO); nxtDisplayCenteredTextLine(7, "Long range"); shortrange = false; } PlaySound(soundBeepBeep); while(bSoundActive) time1[T1] = 0; } while(nNxtButtonPressed != kEnterButton) { zone = MSSUMOreadZone(HTMSSUMO); if (shortrange) { switch (zone) { case MSSUMO_NONE: nxtDisplayRICFile(0, 0, "sumonone.ric"); break; case MSSUMO_FRONT: nxtDisplayRICFile(0, 0, "sumoSF.ric"); break; case MSSUMO_RIGHT: nxtDisplayRICFile(0, 0, "sumoSL.ric"); break; case MSSUMO_LEFT: nxtDisplayRICFile(0, 0, "sumoSR.ric"); break; } nxtDisplayCenteredTextLine(7, "Short range"); } else { switch (zone) { case MSSUMO_NONE: nxtDisplayRICFile(0, 0, "sumonone.ric"); break; case MSSUMO_FRONT: nxtDisplayRICFile(0, 0, "sumoLF.ric"); break; case MSSUMO_RIGHT: nxtDisplayRICFile(0, 0, "sumoLL.ric"); break; case MSSUMO_LEFT: nxtDisplayRICFile(0, 0, "sumoLR.ric"); break; } nxtDisplayCenteredTextLine(7, "Long range"); } wait1Msec(10); } } }