Example #1
0
 QDir users(const QString &prefixHash)
 {
     return drive(prefixHash).absoluteFilePath("users");
 }
Example #2
0
task main()
{
	infra ();
	drive () ;

}
Example #3
0
cypher()
{
	register int n;
	int junk;
	int lflag = -1;
	char buffer[10];

	while (wordtype[wordnumber] == ADJS)
		wordnumber++;
	while (wordnumber <= wordcount) {
		switch(wordvalue[wordnumber]) {

			case UP:
				if (location[position].access || wiz || tempwiz) {
					if (!location[position].access)
						puts("Zap!  A gust of wind lifts you up.");
					if (!move(location[position].up, AHEAD))
						return(-1);
				} else {
					puts("There is no way up");
					return(-1);
				}
				lflag = 0;
				break;

			 case DOWN:
				if (!move(location[position].down, AHEAD))
					return(-1);
				lflag = 0;
				break;

			 case LEFT:
				if (!move(left, LEFT))
					return(-1);
				lflag = 0;
				break;

			 case RIGHT:
				if (!move(right, RIGHT))
					return(-1);
				lflag = 0;
				break;
			 
			 case AHEAD:
				if (!move(ahead, AHEAD))
					return(-1);
				lflag = 0;
				break;
			 
			 case BACK:
				if (!move(back, BACK))
					return(-1);
				lflag = 0;
				break;
			 
			 case SHOOT:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = shoot();
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					shoot();
				break;

			 case TAKE:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = take(location[position].objects);
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					take(location[position].objects);
				break;

			 case DROP:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = drop("Dropped");
						}
				wordnumber++;
				wordnumber++;
				}
				else 
					drop("Dropped");
				break;


			 case KICK:
			 case THROW:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n) ||
						  testbit(location[position].objects, n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
						}
					wordnumber += 2;
				} else 
					throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
				break;

			 case TAKEOFF:
				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = takeoff();
						}
					wordnumber += 2;
				}
				else 
					takeoff();
				break;


			 case DRAW:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = draw();
						}
					wordnumber += 2;
				}
				else 
					draw();
				break;


			 case PUTON:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(location[position].objects,n) && *objsht[n]){
							wordvalue[wordnumber+1] = n;
							wordnumber = puton();
						}
					wordnumber += 2;
				}
				else 
					puton();
				break;

			 case WEARIT:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = wearit();
						}
					wordnumber += 2;
				}
				else 
					wearit();
				break;


			 case EAT:

				if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n)){
							wordvalue[wordnumber+1] = n;
							wordnumber = eat();
						}
					wordnumber += 2;
				}
				else 
					eat();
				break;


			case PUT:
				put();
				break;


			case INVEN:
				if (ucard(inven)){
					puts("You are holding:\n");
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(inven,n))
							printf("\t%s\n", objsht[n]);
					printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."),(WEIGHT ? carrying*100/WEIGHT : -1));
					printf("Your arms are %d%% full.\n",encumber*100/CUMBER);
				}
				else
					puts("You aren't carrying anything.");
					
				if (ucard(wear)){
					puts("\nYou are wearing:\n");
					for (n=0; n < NUMOFOBJECTS; n++)
						if (testbit(wear,n))
							printf("\t%s\n", objsht[n]);
				}
				else
					puts("\nYou are stark naked.");
				if (card(injuries,NUMOFINJURIES)){
					puts("\nYou have suffered:\n");
					for (n=0; n < NUMOFINJURIES; n++)
						if (injuries[n])
							printf("\t%s\n",ouch[n]);
					printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT,(WEIGHT == 1 ? "." : "s."));
				}
				else
					puts("\nYou are in perfect health.");
				break;

			case USE:
				lflag = use();
				break;

			case LOOK:
				if (!notes[CANTSEE] || testbit(inven,LAMPON) || testbit(location[position].objects,LAMPON) || matchlight){
					beenthere[position] = 2;
					writedes();
					printobjs();
					if (matchlight){
						puts("\nYour match splutters out.");
						matchlight = 0;
					}
				} else 
					puts("I can't see anything.");
				return(-1);
				break;

			 case SU:
			 if (wiz || tempwiz){
				printf("\nRoom (was %d) = ", position);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &position);
				printf("Time (was %d) = ",time);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &time);
				printf("Fuel (was %d) = ",fuel);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &fuel);
				printf("Torps (was %d) = ",torps);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &torps);
				printf("CUMBER (was %d) = ",CUMBER);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d", &CUMBER);
				printf("WEIGHT (was %d) = ",WEIGHT);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d",&WEIGHT);
				printf("Clock (was %d) = ",clock);
				fgets(buffer,10,stdin);
				if (*buffer != '\n')
					sscanf(buffer,"%d",&clock);
				printf("Wizard (was %d, %d) = ",wiz, tempwiz);
				fgets(buffer,10,stdin);
				if (*buffer != '\n'){
					sscanf(buffer,"%d",&junk);
					if (!junk)
						tempwiz = wiz = 0;
				}
				printf("\nDONE.\n");
				return(0);
			 }
			 else
				 puts("You aren't a wizard.");
			 break;
				
			 case SCORE:
				printf("\tPLEASURE\tPOWER\t\tEGO\n");
				printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure,power,ego);
				printf("This gives you the rating of %s in %d turns.\n",rate(),time);
				printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere,NUMOFROOMS),NUMOFROOMS,card(beenthere,NUMOFROOMS)*100/NUMOFROOMS);
				break;

			 case KNIFE:
			 case KILL:
				murder();
				break;

			 case UNDRESS:
			 case RAVAGE:
				ravage();
				break;

			 case SAVE:
				save();
				break;

			 case FOLLOW:
				lflag = follow();
				break;

			 case GIVE:
				give();
				break;

			 case KISS:
				kiss();
				break;

			 case LOVE:
				 love();
				 break;

			 case RIDE:
				lflag = ride();
				break;

			 case DRIVE:
				lflag = drive();
				break;

			 case LIGHT:
				 light();
				 break;

			 case LAUNCH:
				if (!launch())
					return(-1);
				else 
					lflag = 0;
				break;

			case LANDIT:
				if (!land())
					return(-1);
				else
					lflag = 0;
				break;

			case TIME:
				chime();
				break;

			 case SLEEP:
				zzz();
				break;

			 case DIG:
				dig();
				break;

			 case JUMP:
				lflag = jump();
				break;

			 case BURY:
				bury();
				break;

			 case SWIM:
				puts("Surf's up!");
				break;

			 case DRINK:
				drink();
				break;

			 case QUIT:
				die();

			 default:
				puts("How's that?");
				return(-1);
				break;

			 
		}
		if (wordnumber < wordcount && *words[wordnumber++] == ',')
			continue;
		else return(lflag);
       }
       return(lflag);
}
Example #4
0
void Mobot::navigate(int p1x, int p1y, int p2x, int p2y) {
  // Assume that only one of dx or dy is nonzero and that their value is
  // either -1 or +1. Same goes for headingX and headingY.

  //             + -y
  //             |
  //             |
  //             |
  //     <--------------->
  //     -x      |      +x
  //             |
  //             |
  //             + +y
  //
  // Counterclockwise: positive degrees
  // Clockwise: negative degrees

  int dx = p2x - p1x;
  int dy = p2y - p1y;

  int turnDegrees = 0;

  if (dx != 0) {
    // If in the opposite direction, turn around
    if (dx * headingX < 0) {
      turnDegrees = 180;
    }

    else if (dx * headingY > 0) {
      turnDegrees = 90;
    }

    else if (dx * headingY < 0) {
      turnDegrees = -90;
    }
  }

  else if (dy != 0) {
    // If in the opposite direction, turn around
    if (dy * headingY < 0) {
      turnDegrees = 180;
    }

    else if (dy * headingX > 0) {
      turnDegrees = -90;
    }

    else if (dy * headingX < 0) {
      turnDegrees = 90;
    }
  }

  headingX = dx;
  headingY = dy;

  if (turnDegrees != 0) {
    turn(turnDegrees);
  }

  drive(resolution);
}
Example #5
0
void ScrollMachine::wheel(int steps)
{
	speed_ += steps * trans_;
	if (int(speed_) == 0) speed_ = steps;
	drive();
}
Example #6
0
task main()
{
	waitForStart();
	//servoChangeRate[handJoint] = 10;
	nMotorEncoder[spear] = 0;
	writeDebugStreamLine("encoder set to: %d", nMotorEncoder[spear]);

	int maxVal = 40;

	while (true)
	{
		getJoystickSettings(joystick);

		int cont1_left_yval = avoidWeird(joystick.joy1_y1, 20); //y coordinate for the left joystick on controller 1
		int cont1_left_xval = avoidWeird(joystick.joy1_x1, 75); //x coordinate for the left joystick on controller 1
		int cont1_right_yval = avoidWeird(joystick.joy1_y2, 20);
		int cont1_dPad = joystick.joy1_TopHat; //Value of the dPad for controller 2

		//if (joy1Btn(4) == 1)
		//{
		//	if ((ServoValue[handJoint] + 5) < maxHandValue)
		//	{
		//		servo[handJoint] = ServoValue[handJoint] + 5;
		//	}
		//}
		//if (joy1Btn(2) == 1)
		//{
		//	if ((ServoValue[handJoint] - 5) > minHandValue)
		//	{
		//		servo[handJoint] = ServoValue[handJoint] - 5;
		//	}
		//}

		if (joy1Btn(1) == 1){
			nMotorEncoder[spear] = 0;
		}

		if (joy1Btn(4) == 1){
			spearMovement(20);
		}
		if (joy1Btn(2) == 1){
			spearMovement(-20);
		}
		if (joy1Btn(2) != 1 && joy1Btn(4) != 1){
			spearMovement(0);
		}

		//if (joy1Btn(6) == 1)
		//{
		//	fold_arm(false);
		//}
		//if (joy1Btn(5) == 1)
		//{
		//	fold_arm(true);
		//}

		if (joy1Btn(1) == 1){
			maxVal = 100;
		}

		if (joy1Btn(1) != 1){
			maxVal = 40;
		}

		//if (joy2Btn(1) == 1)
		//{
		//	servo[ramp] = 0;
		//}
		//if (joy2Btn(3) == 1)
		//{
		//	servo[ramp] = 255;
		//}
		//if (joy2Btn(1) != 1 && joy2Btn(3) != 1)
		//{
		//	servo[ramp] = 128;
		//}

		drive(cont1_left_yval, cont1_left_xval, maxVal);
		//shoulderMovement(cont1_right_yval);
		//handMovement(cont1_dPad);
	}
}
Example #7
0
int main ( void )
{
  uint8_t *bufcontents;
  uint8_t i;
  uint8_t tv[] = "foobar1";
  uint16_t ticker = 0;
  uint8_t rc;
  aes128_ctx_t ctx;

  uint8_t key[] = "0123456789ABCDEF";
  uint8_t IV[] = "FEDCBA9876543210";
  uint8_t text[] = "Hello rfm12 world. I've gonna cipher you       ";
	
  drive(LED1);
  drive(LED2);

  toggle_output(LED1);
	
  uart_init();

  _delay_ms(250);
  _delay_ms(250);

  sei();

  toggle_output(LED2);
  uart_putstr ("AVR Boot Ok\r\n");
  _delay_ms(250);
  toggle_output(LED2);

  aes128_init(key,&ctx);

  while (1) {
    uart_putstr("key = ");
    uart_putstr(key);
    uart_putstr("\r\n");

    uart_putstr("text = ");
    uart_putstr(text);
    uart_putstr("\r\n");

    /* Ciphering in CBC mode */
    memxor(text,IV,16);
    aes128_enc(text,&ctx);
    memxor(text+16,text,16);
    aes128_enc(text+16,&ctx);
    memxor(text+32,text+16,16);
    aes128_enc(text+32,&ctx);

    uart_putstr("text ciphered = \r\n");
    uart_hexdump(text,sizeof(text));

    /* Deciphering in CBC mode */
    aes128_dec(text+32,&ctx);
    memxor(text+32,text+16,16);
    aes128_dec(text+16,&ctx);
    memxor(text+16,text,16);
    aes128_dec(text,&ctx);
    memxor(text,IV,16);

    uart_putstr("text unciphered = ");
    uart_putstr(text);
    uart_putstr("\r\n");

    /* Let change the IV */
    IV[0]++;

    _delay_ms(250);
    _delay_ms(250);
    _delay_ms(250);
    _delay_ms(250);
  }
}
Example #8
0
/*
 * Runs the user operator control code. This function will be started in its own task with the
 * default priority and stack size whenever the robot is enabled via the Field Management System
 * or the VEX Competition Switch in the operator control mode. If the robot is disabled or
 * communications is lost, the operator control task will be stopped by the kernel. Re-enabling
 * the robot will restart the task, not resume it from where it left off.
 *
 * If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
 * run the operator control task. Be warned that this will also occur if the VEX Cortex is
 * tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
 *
 * Code running in this task can take almost any action, as the VEX Joystick is available and
 * the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
 * recommended to give other tasks (including system tasks such as updating LCDs) time to run.
 *
 * This task should never exit; it should end with some kind of infinite loop, even if empty.
 */
void operatorControl() {
#ifdef AUTO
	autonomous();
#elif defined(TEST)

#define DEFAULT_SHOOTER_SPEED 0
#define SHOOTER_SPEED_INCREMENT 5

	int8_t xSpeed, ySpeed, rotation;
	int8_t lifterSpeed/*, intakeSpeed*/;

	int16_t shooterSpeed = DEFAULT_SHOOTER_SPEED; //shooter is on when robot starts
	int8_t frontIntakeSpeed = INTAKE_SPEED;
	bool isShooterOn = true;
	bool isAutoShootOn = false;

	//lfilterClear();

	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_UP);		// intake forward
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_LEFT);	// intake off
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_RIGHT);	// intake off
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_DOWN);	// intake backward
	toggleBtnInit(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_DOWN);   // shooter on off
	toggleBtnInit(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_RIGHT);   // auto shoot on off
	toggleBtnInit(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_UP);   // shooter speed up
	toggleBtnInit(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_DOWN);   // shooter speed down

	while (true) {
		printf("ultra distance (in): %f\r\n", ultrasonicGet(ultra) / 2.54);

		toggleBtnUpdateAll();

		// drive
		xSpeed = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, STRAFE_AXIS);
		ySpeed = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, DRIVE_AXIS);
		rotation = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, ROTATION_AXIS) / 2;

		if (abs(ySpeed) < DIAGONAL_DRIVE_DEADBAND) {
			ySpeed = 0;
		}

		if (abs(xSpeed) < DIAGONAL_DRIVE_DEADBAND) {
			xSpeed = 0;
		}

		drive(xSpeed, ySpeed, rotation, false);

		// lifter up down
		if (joystickGetDigital(JOYSTICK_SLOT, LIFTER_BUTTON_GROUP, JOY_UP)) {
			lifterSpeed = LIFTER_SPEED;
		} else if (joystickGetDigital(JOYSTICK_SLOT, LIFTER_BUTTON_GROUP, JOY_DOWN)) {
			lifterSpeed = -LIFTER_SPEED;
		} else {
			lifterSpeed = 0;
		}

		lifter(lifterSpeed);
		takeInInternal(lifterSpeed);

		if (isShooterOn) {
			if (isAutoShootOn) {
				shooterSpeed = calculateShooterSpeed();
			} else {
				// shooter increase speed
				if (toggleBtnGet(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_UP) == BUTTON_PRESSED) {
					shooterSpeed += SHOOTER_SPEED_INCREMENT;

					if (shooterSpeed > SHOOTER_MAX_SPEED) {
						shooterSpeed = SHOOTER_MAX_SPEED;
					}
				}

				// shooter decrease speed
				if (toggleBtnGet(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
					shooterSpeed -= SHOOTER_SPEED_INCREMENT;

					if (shooterSpeed < SHOOTER_MIN_SPEED) {
						shooterSpeed = SHOOTER_MIN_SPEED;
					}
				}
			}

//			 auto shooter on off
			if (toggleBtnGet(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_RIGHT) == BUTTON_PRESSED) {
				isAutoShootOn = !isAutoShootOn;
			}
		}

		// shooter on off
		if (toggleBtnGet(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
			isShooterOn = !isShooterOn;
			shooterSpeed = isShooterOn ? DEFAULT_SHOOTER_SPEED : 0;
		}

		shooter(shooterSpeed);

		// intake mode
		if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_LEFT) == BUTTON_PRESSED
			|| toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_RIGHT) == BUTTON_PRESSED) {
			frontIntakeSpeed = 0;
		} else if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_UP) == BUTTON_PRESSED) {
			frontIntakeSpeed = -INTAKE_SPEED;
		} else if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
			frontIntakeSpeed = INTAKE_SPEED;
		}

		takeInFront(frontIntakeSpeed);

		delay(20);
	}
#else
	int8_t xSpeed, ySpeed, rotation;
	int8_t lifterSpeed/*, intakeSpeed*/;
	int8_t defaultPreset = 0;
	int8_t currentPreset = defaultPreset;

	int16_t shooterSpeed = shooterSpeedPresets[defaultPreset]; //shooter is on when robot starts
	int8_t frontIntakeSpeed = INTAKE_SPEED;
	bool isShooterOn = true;

	//lfilterClear();

	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_UP);		// intake forward
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_LEFT);	// intake off
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_RIGHT);	// intake off
	toggleBtnInit(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_DOWN);	// intake backward
	toggleBtnInit(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_DOWN);   // shooter on off
	toggleBtnInit(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_UP);   // shooter speed up
	toggleBtnInit(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_DOWN);   // shooter speed down

	while (true) {
		printf("ultra distance (in): %f\r\n", ultrasonicGet(ultra) / 2.54);

		toggleBtnUpdateAll();

		// drive
		xSpeed = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, STRAFE_AXIS);
		ySpeed = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, DRIVE_AXIS);
		rotation = (int8_t) joystickGetAnalog(JOYSTICK_SLOT, ROTATION_AXIS) / 2;

		if (abs(ySpeed) < DIAGONAL_DRIVE_DEADBAND) {
			ySpeed = 0;
		}

		if (abs(xSpeed) < DIAGONAL_DRIVE_DEADBAND) {
			xSpeed = 0;
		}

		drive(xSpeed, ySpeed, rotation, false);

		// lifter up down
		if (joystickGetDigital(JOYSTICK_SLOT, LIFTER_BUTTON_GROUP, JOY_UP)) {
			lifterSpeed = LIFTER_SPEED;
		} else if (joystickGetDigital(JOYSTICK_SLOT, LIFTER_BUTTON_GROUP, JOY_DOWN)) {
			lifterSpeed = -LIFTER_SPEED;
		} else {
			lifterSpeed = 0;
		}

		lifter(lifterSpeed);
		takeInInternal(lifterSpeed);

		if (isShooterOn) {
			// shooter increase speed
			if (toggleBtnGet(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_UP) == BUTTON_PRESSED) {
				++currentPreset;

				if (currentPreset >= NUM_SHOOTER_SPEED_PRESETS) {
					currentPreset = NUM_SHOOTER_SPEED_PRESETS - 1;
				}
			}

			// shooter decrease speed
			if (toggleBtnGet(JOYSTICK_SLOT, SHOOTER_ADJUST_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
				--currentPreset;

				if (currentPreset < 0) {
					currentPreset = 0;
				}
			}

			shooterSpeed = shooterSpeedPresets[currentPreset];
		}

		// shooter on off
		if (toggleBtnGet(JOYSTICK_SLOT, CONTROL_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
			isShooterOn = !isShooterOn;
			shooterSpeed = isShooterOn ? shooterSpeedPresets[defaultPreset] : 0;
		}

		shooter(shooterSpeed);

		// intake mode
		if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_LEFT) == BUTTON_PRESSED
			|| toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_RIGHT) == BUTTON_PRESSED) {
			frontIntakeSpeed = 0;
		} else if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_UP) == BUTTON_PRESSED) {
			frontIntakeSpeed = -INTAKE_SPEED;
		} else if (toggleBtnGet(JOYSTICK_SLOT, INTAKE_BUTTON_GROUP, JOY_DOWN) == BUTTON_PRESSED) {
			frontIntakeSpeed = INTAKE_SPEED;
		}

		takeInFront(frontIntakeSpeed);

		delay(20);
	}
#endif
}
void DifferentialPilot::drive
    (Robot* rob, Point goalPoint, float theta_goal, MoveType moveType)
{
    return drive(rob, goalPoint.x, goalPoint.y, theta_goal, moveType);
}
Example #10
0
void Robot::writeMotorsSpeed(int motorLeft, int motorRight)
{
	motorLeft = (float)motorLeft * motorsDiffMultiplier;

	drive(motorLeft, motorRight);
}
Example #11
0
void AFK_Camera::driveAndUpdateProjection(const Vec3<float>& velocity, const Vec3<float>& axisDisplacement)
{
    drive(velocity, axisDisplacement);
    updateProjection();
}
task main() {
    //Code: drive(auto_command,time);
    //replace auto_command and time with values necessary (if you don't replace them, code won't run)
    //auto_command values are: "rpoint", "lpoint", "up", "down", "rswing", "lswing", "rswingback", "lswingback"
    //time values is the time, in milliseconds, you want the robot to be doing the action specified in auto_command

    //Use the sonar sensor by: SensorValue[sonarSensor].  It can get a distance from 0cm to 80cm
    //drive("up", 10000);      move forward 10000 milliseconds (10sec)
    //drive("lpoint", 1000);   left point turn for 1000 milliseconds (1sec)
    //drive("up", 10000);      move forward again for 10000 milliseconds (10sec)


    waitForStart();

    /*
    int count = 0;

    string BatteryLevel = externalBatteryAvg;
    string selection = "";


    nxtDisplayCenteredBigTextLine (3, BatteryLevel);
    wait1Msec(3000);
    */


//Drive forward off of home red cliff
    drive(0,4596);
    drive(65535,100);

//Turn left 90 degrees
    drive(6,3185);
    drive(65535,100);

//Drive forward to bowling ball
    drive(0,1036);
    drive(65535,100);

//Turn left 90 degrees
    drive(6,4037);
    drive(65535,100);

//Turn left a bit
    drive(6,516);
    drive(65535,100);
    drive(0,657);//Drive past bowling ball
    drive(65535,100);
    drive(2,188);//Turn right into bowling ball
    drive(65535,100);
    drive(2,237);//Turn right into bowling ball
    drive(65535,100);
    drive(0,425);//Drive forward
    drive(65535,100);
    drive(2,279);//Turn right into bowling ball
    drive(65535,100);
    drive(2,424);//Turn right into bowling ball
    drive(65535,100);
    drive(0,799);//Drive forward a bit
    drive(65535,100);
    drive(2,468);//Turn right into bowling ball
    drive(65535,100);
    drive(0,516);//Drive forward a bit
    drive(65535,100);
    drive(2,2065);//Turn right into bowling ball
    drive(65535,100);
    drive(0,1409);//Drive forward
    drive(65535,100);
    drive(2,8299);//Turn right, line up with bowling ball
    drive(65535,100);
    drive(2,424);//Turn right, line up with bowling ball

//Drive bowling ball into front zone
    drive(65535,100);
    drive(0,4408);//Drive forward
    drive(65535,100);
    drive(2,424);//Realign with bowling ball
    drive(65535,100);
    drive(0,2908);//Drive forward
    drive(65535,100);
    drive(2,608);//Realign with bowling ball
    drive(65535,100);
    drive(0,1312);//Drive forward
    drive(0,1920);//Drive forward
    drive(65535,100);
    drive(0,424);//Drive forward
    drive(65535,100);

    drive(4,9756);//Drive backwards
    drive(65535,100);
    drive(4,376);//Drive backwards
    drive(4,3516);//Drive backwards

}
Example #13
0
task main()
{
	bDisplayDiagnostics=false;
	nMotorEncoder[sense]=0;
	/*
	motor[sense]=5;
	while(SensorValue[ir]!=5);
	motor[sense]=0;
	nxtDisplayCenteredBigTextLine(0,"%d",nMotorEncoder[sense]);
	motor[sense]=-5;
	while(nMotorEncoder[sense]>0);
	motor[sense]=0;
	wait1Msec(100000);
	StopAllTasks();
	*/

	init();
	theta=0;
	//downRamp();
	waitForStart();
	//wait1Msec(13000);
	StartTask(gyroThread);
	StartTask(graph);
	StartTask(grabber);
	//wait1msec(2000);
	//servo[bucket]=160;
//wait1Msec(100000);
	/*
forwardToLine();
	rotateLeft(20,20);
	drive(0);
	wait1Msec(250);
//	forwardToTube();
*/
//	servo[grab]=210;

//	wait1Msec(200);
//	bringTubeBack();


//servo[grab]=255;
//wait1Msec(1000);
//drive(50);
//wait1msec(2500);
if(STARTINGPOS==0){
	drive(0);
	grabState=2;
	forwardToTube2();
	bringTubeBack();
	wait1Msec(1000);
	//dump();
}
else{
	grabState=1;
	drive(50);
	wait1Msec(2000);
	drive(30);
	grabState=0;
	wait1Msec(1000);
	forwardToTube2();
	backToZone();
}
//backToZone();
//		while(true)readAnalogInput(HTPB,0);//before edge
	//downRamp();
	//clearTimer(T1);
	/*
	motor[claw]=50;
	wait1Msec(250);
	motor[claw]=5;
	motor[right]=50;
	motor[left]=0;
	wait1Msec(1000);
	motor[left]=-50;
	wait1Msec(8000);
	drive(0);*/
	while(true);
}
Example #14
0
void timedDrive(int direction, float seconds) {
	drive(direction);
	Wait(seconds);
	drive(NO_WHERE);
}
Example #15
0
void backwardTouch(int speed)
{
    drive(speed);
    while(!TOUCH_BACK_OR);
    create_stop();
}
Example #16
0
task main(){
	//Code: drive(auto_command,time);
	//replace auto_command and time with values necessary (if you don't replace them, code won't run)
	//auto_command values are: "rpoint", "lpoint", "up", "down", "rswing", "lswing", "rswingback", "lswingback"
	//time values is the time, in milliseconds, you want the robot to be doing the action specified in auto_command

	//Info:
	//Motor at 75% power travels at 2 feet per second = 60.96 cm
	//Lpoint turn takes 1560 ms to turn 90 degrees
	//Ultrasonic sensor is 9cm away from back

	//Use the sonar sensor by: SensorValue[sonarSensor].  It can get a distance from 0cm to 80cm
	//drive("up", 10000);      move forward 10000 milliseconds (10sec)
	//drive("lpoint", 1000);   left point turn for 1000 milliseconds (1sec)
	//drive("up", 10000);      move forward again for 10000 milliseconds (10sec)

	string program_type="Red";
	int offset_back = 0;
	int offset_right = 0;
	int robot_length = 667; //In milliseconds
	int distance = 0;


	if (program_type=="Red") {
		//1) Measure offset from walls
		//!IMPORTANT START ROBOT SIDEWAYS facing left to reduce time it takes to measure
		//!IMPORTANT Ultrasonic measurer should be placed facing the back with the edge lined up with the robot's back
		//Convert offset distance into milliseconds

	  //Measure
		offset_right = (SensorValue[sonarSensor] - 9)/60.96;
		// Turn right 90 degreees
		distance = 1560;
		drive("rpoint", distance);
		//Remeasure
		offset_back = (SensorValue[sonarSensor] - 9)/60.96;


		//2) Move forward ((Four Feet Seven Inches=139.7 cm)-offset_back)

		distance = 2291.66666 - offset_back;
		drive("up", distance);

		//3) Point turn -90 degrees

		distance = 1560;
		drive("lpoint", distance);

		//4) Move forward ((Four Feet Eight Inches=142.24 cm)-(the robot's length)-offset_right)

		distance = 2333.333333 - robot_length - offset_right;
		drive("up", distance);

		//5) Point turn -33.7 degrees

		distance = 584.13333333;
		drive("lpoint", distance);

		//6) Move forward ((Nine Feet Two Inches=279.4 cm)-(the robot's length))

		distance = 4583.333333 - robot_length;
		drive("up", distance);

		//7) Pause 1 second

		wait1Msec(1000);

		//8) Move backward (Three Inches=7.62 cm)

		distance = 125;
		drive("down", distance);

		//9) Point turn 33.7 degrees

		distance = 584.13333333;
		drive("rpoint", distance);

		//10) Measure offset from RED base wall (should be from 5' - 7' = 152.4-213.36 cm)
		offset_right = (SensorValue[sonarSensor] - 9)/60.96;

		//11) Move backward until (offset=(Two Feet Six Inches = 76.2 cm))
		//OR Move backward (Two Feet Four Inches = 71.12 cm)
		//Robot will move into RED Low Zone

		//while offset_right > 857 {
		//  drive("down", 500);
		//  offset_right = (SensorValue[sonarSensor] - 9)/60.96;
		//}
		//OR
		distance = 857;
		drive("down", distance);

		//12) Point Turn 90 degrees

		distance = 1560;
		drive("rpoint", distance);

		//13) Measure offset
		offset_back = (SensorValue[sonarSensor] - 9)/60.96;

		//14) Move until (offset=(Ten Feet Six Inches = 320.04 cm)-(half the robot's length))
		//OR Move forward (Nine Feet Eight Inches = 294.64 cm)

		//while offset_back > 5250 {
		//  drive("up", 500);
		//  offset_right = (SensorValue[sonarSensor] - 9)/60.96;
		//}
		//OR
		distance = 4833.33333;
		drive("up", distance);

		//15) Point Turn 90 Degrees

		distance = 1560;
		drive("rpoint", distance);

		//16) Move forward (Five Feet Six Inches = 167.64 cm)

		distance = 2750;
		drive("up", distance);

  	}else {   //BLU side
		
	}

}
Example #17
0
void forwardTouch(int speed)
{
    drive(-speed);
    while(!TOUCH_FRONT);
    create_stop();
}
Example #18
0
task usercontrol ()
{
	while(1){
	drive();
}
}
Example #19
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

	bool button=1;

	struct sensor s[6];
	
	int64_t min_avg[6]={23, 14, 15, 15, 18, 23};
	int64_t max_avg[6]={1000, 193, 172, 170, 160, 550};
	int i;
	int64_t error;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  //Initializeaza timer-ul
  CountTimer_Init((LDD_TUserData *)NULL);
  //Opreste motoarele
  motor(0, 0);
  //Activeaza PWM-ul pentru motoare
  PWM_stanga_Enable();
  PWM_dreapta_Enable();
  
  IR_LED_PutVal(0);
  while(button)
	button=Button_GetVal();
  WAIT1_Waitms(500);
  IR_LED_PutVal(1);

  while(1){
	  
	  readSensors(min_avg, max_avg, s);
	  WAIT1_Waitms(1);
#if DEBUG==TRUE
	  for(i=0; i<6; i++){
		  Term1_SendNum(s[i].value);
		  Term1_SendStr("  ");
	  }
	  for(i=0; i<6; i++){
		  Term1_SendNum(s[i].seen);
		  Term1_SendStr("  ");
	  }
#endif
	  error=propder(s);
#if DEBUG==TRUE
	  Term1_SendNum(error);
	  Term1_SendChar('\n');
	  Term1_SendChar('\r');
#endif
	  drive(error);

  }




  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Example #20
0
void Robot::startActing()
{
	std::thread newRobotThread( [this]
	{	stop = false; drive();});
	robotThread.swap( newRobotThread);
}
Example #21
0
EXPORT_C CPrinterModelList* CPrintSetup::ModelNameListL(RFs& aFs)
/** Gets the names of all printer models supported.

The function scans all directories in the search path list which were added 
using AddPrinterDriverDirL(). It returns a list of the printer models supported 
by the .pdr files found in those directories.

@param aFs A connection to a file server session.
@leave KErrNoMemory There is insufficient memory to perform the operation. 
@return The list of printer models supported. */
	{
	__ASSERT_ALWAYS(iDriverDirList->Count()>0,Panic(EPanicNoPrinterDirs));
	//
	if (!iModelList)
		{
		CPdrModelList* modelList = CPdrModelList::NewL();
		CleanupStack::PushL(modelList);
		// define some variables that are used in the loops, so it only gets done once
		TDriveList driveList;
		TDriveInfo driveInfo;
		TEntry entry;
		TParse parser;
		// get a list of available drives
		User::LeaveIfError(aFs.DriveList(driveList));
		for (TInt i=iDriverDirList->Count()-1 ; i>=0 ; i--)
			{
			TInt err = parser.Set((*iDriverDirList)[i],NULL,NULL);
			if (err==KErrNone)
				{
				if (parser.DrivePresent())
					{// if there is a drive present add the path straight
					err = aFs.Entry(parser.DriveAndPath(),entry);
					if (err==KErrNone)
						modelList->AddDirectoryL(parser.DriveAndPath()); // add dir
					}
				else
					{
					for (TInt n=0 ; n<KMaxDrives ; n++)
						{// if there's no drive scan all drives for matching directories
						if (driveList[n]!=0)
							{
							aFs.Drive(driveInfo,n);
							if (driveInfo.iType!=EMediaNotPresent && driveInfo.iType!=EMediaRemote)
								{
								TDriveUnit drive(n);
								err = parser.Set(drive.Name(),&(*iDriverDirList)[i],NULL);
								if (err==KErrNone)
									err = aFs.Entry(parser.DriveAndPath(),entry);
								if (err==KErrNone)
									modelList->AddDirectoryL(parser.DriveAndPath()); // add dir
								}
							}
						}
					}
				}
			}
		CleanupStack::Pop(); // modelList
		iModelList = modelList;
		}
	return iModelList->ScanForModelsL();
	}
Example #22
0
task main()
{
	waitForStart();
	servoChangeRate[handJoint] = 10;
	int maxVal = 40;

	while (true)
	{
		getJoystickSettings(joystick);

		int cont1_left_yval = avoidWeird(joystick.joy1_y1, 20); //y coordinate for the left joystick on controller 1
		int cont1_left_xval = avoidWeird(joystick.joy1_x1, 75); //x coordinate for the left joystick on controller 1
		int cont1_right_yval = avoidWeird(joystick.joy1_y2, 20);
		int cont1_dPad = joystick.joy1_TopHat; //Value of the dPad for controller 2

		if (joy1Btn(4) == 1)
		{
			if ((ServoValue[handJoint] + 5) < maxHandValue)
			{
				servo[handJoint] = ServoValue[handJoint] + 5;
			}
		}
		if (joy1Btn(2) == 1)
		{
			if ((ServoValue[handJoint] - 5) > minHandValue)
			{
				servo[handJoint] = ServoValue[handJoint] - 5;
			}
		}
		if (joy1Btn(6) == 1)
		{
			fold_arm(false);
		}
		if (joy1Btn(5) == 1)
		{
			fold_arm(true);
		}

		if (joy1Btn(1) == 1)
		{
			maxVal = 100;
		}

		if (joy1Btn(1) != 1)
		{
			maxVal = 40;
		}

		if (joy2Btn(1) == 1)
		{
			servo[ramp] = 0;
		}
		if (joy2Btn(3) == 1)
		{
			servo[ramp] = 255;
		}
		if (joy2Btn(1) != 1 && joy2Btn(3) != 1)
		{
			servo[ramp] = 128;
		}

		drive(cont1_left_yval, cont1_left_xval, maxVal);
		shoulderMovement(cont1_right_yval);
		handMovement(cont1_dPad);
	}
}
Example #23
0
void loop() {
  
//  drive(1, false);
//  return;
  
  Robot.updateIR();
  
  static int turnTestTime = 0;
  static int turnTestTimeLast = 0;
  static int turnTimeMod = 1;

  switch(state) {
    case DRIVE:
      if(detectEdge()) {
         Robot.motorsStop();
         state = BACKUP;
         time = 0;
         //Robot.background(0, 255, 0);
      }
      else {
        if(0 && random(0, 50) == 0) {
          Robot.motorsStop();
         state = TURN;
         
         turnTestTime = 0;
         turnTestTimeLast = 0;
         
         turnTime = 1*random(5, 25);
         turnDir = random(0, 1);
         if(turnDir == 0)
           turnDir = -1;
         Robot.beep(BEEP_SIMPLE);
         time = 0;
         //Robot.background(255, 0, 0);
        }
        else
          drive(1);
      }
      break;
    case BACKUP:
      if(time < 45) {
        drive(-1, true);
      }
      else {
         Robot.motorsStop();
         state = TURN;
         
         turnTestTime = 0;
         turnTestTimeLast = 0;
         
         turnTime = 1*random(5, 25);
         turnDir = random(0, 1);
         if(turnDir == 0)
           turnDir = -1;
         Robot.beep(BEEP_SIMPLE);
         time = 0;
         
         //Robot.background(255, 0, 0);
      }
      break;
    case TURN:
      if(time < turnTime) {
    //    if(turnTestTime >= 2*turnTestTimeLast + 1) {
   //       turnTestTimeLast = turnTestTime;
  //        turnTestTime = 0;
   //       turnTimeMod *= -1;
    //    } else
  //        turnTestTime++;
        Robot.motorsWrite(255 * turnDir * turnTimeMod, -255 * turnDir * turnTimeMod);
      }
      else {
        state = DRIVE;
        Robot.motorsStop();
        //Robot.background(0, 0, 255);
      }
      break; 
  }
  
  time++;
  delay(5);
}
Example #24
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1130
@SYMTestCaseDesc	    Tests copying from one stream to another stream
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for copying using different transfer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1130 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
//
	test.Next(_L("Opening source (root) store"));
	TStreamId root=file->Root();
	RStoreReadStream src;
	src.OpenLC(*file,root);
	RDecryptStream decrypt;
	decrypt.OpenLC(src,*thePBEKey);

	TBuf8<5> b;
	TStreamId embed;
	decrypt>>b>>embed;
	test(b==_L8(" root"));
	CleanupStack::PopAndDestroy(2); // src, decrypt
	src.OpenL(*file,embed);
	CEmbeddedStore* source=CEmbeddedStore::FromLC(src);
	CSecureStore* ssource=NULL;
	ssource=CSecureStore::NewLC(*source,*thePBEKey);

	test.Next(_L("Creating target store"));
	RStoreWriteStream trg;
	trg.CreateL(*file);
	CEmbeddedStore* target=CEmbeddedStore::NewLC(trg);
	CSecureStore* starget=NULL;
	starget=CSecureStore::NewLC(*target,*thePBEKey);

	test.Next(_L("Copying using small transfers"));
	RStoreReadStream in;
	in.OpenL(*ssource,source->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*ssource,copyId);
	RStoreWriteStream out;
	TStreamId id=out.CreateL(*starget);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	CleanupStack::PopAndDestroy(5);
	}
Example #25
0
int main() {

	void *virtual_base;
	volatile uint32_t *hps_saber = NULL;
	int fd;

	if(init_i2c(I2C_1) != 0){
		printf("Init I2C 100kHz Failed\n");
		return -1;
	} else {
		printf("Init I2C 100kHz successful\n");
	}

	if(init_i2c(I2C_2) != 0){
		printf("Init I2C 100kHz Failed\n");
		return -1;
	} else {
		printf("Init I2C 100kHz successful\n");
	}

	init_itg();

	if( ( fd = open( "/dev/mem", ( O_RDWR | O_SYNC ) ) ) == -1 ) {
		printf( "ERROR: could not open \"/dev/mem\"...\n" );
		return( 1 );
	}

	virtual_base = mmap( NULL, HW_REGS_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd, HW_REGS_BASE );

	if( virtual_base == MAP_FAILED ) {
		printf( "ERROR: mmap() failed...\n" );
		close( fd );
		return( 1 );
	}

	hps_saber = virtual_base + ( (uint32_t)( ALT_LWFPGASLVS_OFST + MOTOR_MODUL_BASE ) & (uint32_t)( HW_REGS_MASK ) );

	usleep(10*1000*1000);

	drive(hps_saber, 125, 600);

	usleep(2000*1000);

	drive_turn_w_offset(hps_saber, 60, 90);

	usleep(2000*1000);

	drive_turn_w_offset(hps_saber, 60, -180);

	usleep(2000*1000);

	drive_curve_steps(hps_saber, 180, 130, 600, 5);

	if( munmap( virtual_base, HW_REGS_SPAN ) != 0 ) {
		printf( "ERROR: munmap() failed...\n" );
		close( fd );
		return( 1 );
	}

	close( fd );

	return( 0 );
}
void bringback2cube(){
	//claw up
	motor(Motor_Up,Motor_up_speed);
	//zurück 1s 
	drive(1000,-Drivespeed,-Drivespeed);
	//turn right 90
	drive(970,Turnspeed,-Turnspeed);
	//vor to calibrate
	drive(1000,Drivespeed,Drivespeed);
	//back
	drive(500,-Drivespeed,-Drivespeed);
	//turn so little bit b4 cubes
	drive(1130,Turnspeed,-Turnspeed);
	//vor
	drive(900,Drivespeed,Drivespeed);
	//wait for claw up
	claw_up();
	//camera fix
	camera_update();
	//hide your cubes
	cube_is_near();
	//back
	drive(1000,-Drivespeed,-Drivespeed);
	//turn left more than 90 idk
	drive(1330,-Turnspeed,Turnspeed);
	//start to down motor
	motor(Motor_Up,Motor_down_speed);
	//vor to calibrate
	drive(1000,Drivespeed,Drivespeed);
	
	//langsamer weil wackeldackel
	drive(2000,Drivespeed_middle+20,Drivespeed_middle+20);
	//back
	drive(400,-Drivespeed,-Drivespeed);
	//turn more than 90 lulz
	drive(980,-Turnspeed,Turnspeed);
	//light left and shit
	drive(5000,Drivespeed_middle*2,(Drivespeed_middle*2)-7);
	//light back and shit
	drive(1000,-Drivespeed_middle*2,(-Drivespeed_middle*2)+7);
	//wait for claw down
	while(!digital(Sensor_Down)){
		if(seconds()>start+113){
			claw_open();
			disable_servos();
		}
	}
	freeze(Motor_Up);
	msleep(2000);
	claw_open();
	disable_servos();
}
void FourWheelOmniPilot::drive (Robot* rob, Point goalPoint, float theta_goal, Point goal2Point, MoveType moveType)
{
    drive(rob, goalPoint.x, goalPoint.y, theta_goal, goal2Point.x, goal2Point.y, moveType);
}
void CHttpCacheManager::ApplyCacheOverridesL(CRepository& aRepository, const TUint32& aSecIdInt, TBool& aCacheEnabled, TInt& aCacheSize, TBool& aOpCacheEnabled, TBool& aVssCacheEnabled, TDes& aPath, const TDesC& aDefaultDrive)
    {
    TDriveUnit drive(aDefaultDrive);
    
    // set defaults
    if(aSecIdInt == KUIDBROWSERNG)       // for the browser, force use of Operator and VSS caches
        {
        aOpCacheEnabled = ETrue;
        aVssCacheEnabled = ETrue;
        }
    
    // read override string from centrep
    HBufC16 *overrideBuf = HBufC16::NewLC(64);
    TPtr overrideStr(overrideBuf->Des());
    TInt strLen;
    TInt err = aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
    if(strLen > overrideBuf->Length())
        {
        overrideBuf = overrideBuf->ReAllocL(strLen);
        // make sure cleanup stack contains correct pointer since ReAllocL always allocates a new des for larger space.
        CleanupStack::Pop();
        CleanupStack::PushL(overrideBuf);
        // reassign the TPtr
        overrideStr.Set(overrideBuf->Des());
        // pull in the whole string
        aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
        }
    // if we failed to load an override string, use the default.
    if( overrideStr.Length() == 0 )
        {
        CleanupStack::PopAndDestroy( overrideBuf );
        overrideBuf = KDefaultOverrideString().AllocLC();
        overrideStr.Set( overrideBuf->Des() );
        }
    // Built in Lex likes white space to separate strings, but easier to enter with ; separators.  Replace all ; with spaces.
    TInt pos=0;
    do{
        if(overrideStr[pos] == ';')
            {
            overrideStr[pos] = ' ';
            }
        pos++;
    }while(pos < overrideStr.Length());
    
    TLex overrideLex(overrideStr);
    do{
        TUint32 tempId;
        User::LeaveIfError(overrideLex.BoundedVal(tempId,EHex,KMaxTUint32));
        if(overrideLex.TokenLength() != 8)  // if we're not pointing at an SID in the string, we are incorrect and the override is broken.
            User::Leave(KErrCorrupt);
        overrideLex.SkipSpace();
        TInt32 tempCacheEnabled;
        User::LeaveIfError(overrideLex.BoundedVal(tempCacheEnabled,KMaxTInt32));
        overrideLex.SkipSpace();
        TInt32 tempCacheSize;
        User::LeaveIfError(overrideLex.BoundedVal(tempCacheSize,KMaxTInt32));
        overrideLex.SkipSpace();
        TDriveUnit tempDrive(overrideLex.NextToken());
        overrideLex.SkipSpaceAndMark();
        // found a hex SID matching ours, use the parameters.
        if(tempId == aSecIdInt)
            {
            aCacheEnabled = tempCacheEnabled;
            aCacheSize = tempCacheSize * 1024; // conf is in KB
            drive = tempDrive;
            break;
            }
    }while(!overrideLex.Eos());

    // Modify drive letter on aPath to match
    TParsePtr parsePath(aPath);
    TPtrC pathStr(parsePath.Path());
    TPath tempPath;
    tempPath.Format(_L("%c:%S"), TInt(drive)+'A', &pathStr);
    aPath.Copy(tempPath);
    HttpCacheUtil::EnsureTrailingSlash( aPath );
    
    CleanupStack::PopAndDestroy(overrideBuf);
    }
Example #29
0
void process_cmd(unsigned char cmd, unsigned char par[])
{
	unsigned char i;
    for (i=0; i<MAX_RESPONSE_LENGTH; i++) {
    	res[i] = RES_ERROR;
    }
    response_len = 0;
    unsigned char pin_num = 0x00;
    unsigned int pwm_freq = 0;
    unsigned params_dummy[3];
    switch(cmd) {
    case CMD_TEST_LED_ON:
//    	P2SEL &= ~BIT0;
//    	P2DIR |= BIT0;
//    	P2OUT |= BIT0;
//    	cmd = CMD_PASS;
    	cmd = CMD_GPIO_DIR;
    	par[0] = PAR_PORT2;
    	par[1] = PAR_PIN0;
    	par[2] = PAR_DIR_OUT;
    	process_cmd(cmd, par);
    	cmd = CMD_GPIO_SET;
    	par[0] = PAR_PORT2;
    	par[1] = PAR_PIN0;
    	par[2] = PAR_STATE_HIGH;
    	process_cmd(cmd, par);
    	cmd = CMD_PASS;
        break;
    case CMD_TEST_LED_OFF:
    	P2SEL &= ~BIT0;
    	P2DIR |= BIT0;
    	P2OUT &= ~BIT0;
    	cmd = CMD_PASS;
    	break;
    case CMD_TEST_MOTORS_ON:
    		flstop=0;
    		drive();
            break;
    case CMD_TEST_MOTORS_OFF:
    	stop();
            break;
    case CMD_PASS:
    	cmd = CMD_PASS;
            break;
    case CMD_GPIO_DIR:
    {
    	pin_num = (0x01 << par[1]);
        if(par[0] == PAR_PORT1) {
        	//set bit to 0 for i/o
        	P1SEL &= ~pin_num;
            if (par[2] == PAR_DIR_IN) {
            	//set bit to 0 for input
            	P1DIR &= ~pin_num;
            } else {
            	//set bit to 1 for output
            	P1DIR |= pin_num;
            }
        } else if (par[0] == PAR_PORT2) {
        	P2SEL &= ~pin_num;
            if (par[2] == PAR_DIR_IN) {
            	//set bit to 0 for input
            	P2DIR &= ~pin_num;
            } else {
            	//set bit to 1 for output
            	P2DIR |= pin_num;
            }
        } else if (par[0] == PAR_PORT3) {
        	P3SEL &= ~pin_num;
            if (par[2] == PAR_DIR_IN) {
            	//set bit to 0 for input
            	P3DIR &= ~pin_num;
            } else {
            	//set bit to 1 for output
            	P3DIR |= pin_num;
            }
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    }
    case CMD_GPIO_SET:
    	pin_num = (0x01 << par[1]);
        if(par[0] == PAR_PORT1) {
        	P1SEL &= ~pin_num;
        	if (par[2] == PAR_STATE_LOW) {
        		P1OUT &= ~pin_num;
        	} else if (par[0] == PAR_STATE_HIGH) {
        		P1OUT |=  pin_num;
        	} else {
        		//bad digital state
        	}
        } else if (par[0] == PAR_PORT2) {
        	P2SEL &= ~pin_num;
        	if (par[2] == PAR_STATE_LOW) {
        		P2OUT &= ~pin_num;
        	} else if (par[2] == PAR_STATE_HIGH) {
        		P2OUT |=  pin_num;
        	} else {
        		//bad digital state
        	}
        } else if (par[0] == PAR_PORT3) {
        	P3SEL &= ~pin_num;
        	if (par[2] == PAR_STATE_LOW) {
        		P3OUT &= ~pin_num;
        	} else if (par[0] == PAR_STATE_HIGH) {
        		P3OUT |=  pin_num;
        	} else {
        		//bad digital state
        	}
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    case CMD_GPIO_GET:
    	pin_num = (0x01 << par[1]);
    	if (par[0] == PAR_PORT1) {
    		P1SEL &= ~pin_num;
    		if (P1IN & pin_num == 0x00) {
    			res[++response_len - 1] = 0x00;
    		} else {
    			res[++response_len - 1] = 0x01;
    		}
    	} else if (par[0] == PAR_PORT2) {
    		P2SEL &= ~pin_num;
    		if (P2IN & pin_num == 0x00) {
    			res[++response_len - 1] = 0x00;
    		} else {
    			res[++response_len - 1] = 0x01;
    		}
    	} else if (par[0] == PAR_PORT3) {
    		P3SEL &= ~pin_num;
    		if (P3IN & pin_num == 0x00) {
    			res[++response_len - 1] = 0x00;
    		} else {
    			res[++response_len - 1] = 0x01;
    		}
    	} else {
    		// bad port number
    	}
    	cmd = CMD_PASS;
    	break;
    case CMD_GPIO_SETPWM:
    	pin_num = (0x01 << par[1]);
    	pwm_freq = 1020; //>=1.1kHz
    	//max or min pwm = high or low
    	if (par[2] == 0x00 || par[2] == 0xFF) {
    		if (par[2] == 0xFF) {
    			par[2] = 0x01;
    		}
    		process_cmd(CMD_GPIO_SET, par);
    		break;
    	}
    	if (par[0] == PAR_PORT1) {
    		//set the pin as output
    		P1SEL |= pin_num;
    		P1SEL2 &= ~pin_num;
    		P1DIR |= pin_num;
    	} else if (par[0] == PAR_PORT2) {
    		//set the pin as output
    		P2SEL |= pin_num;
    		P2SEL2 &= ~pin_num;
    		P2DIR |= pin_num;
    	} else if (par[0] == PAR_PORT3) {
    		//set the pin as output
    		P3SEL |= pin_num;
    		P3SEL2 &= ~pin_num;
    		P3DIR |= pin_num;
    	} else {
    		// bad port number
    	}
    	//set pwm period in respect to SMCLK
    	TA0CCR0 = pwm_freq - 1;
    	//output is reset when timer counts to TACCRx value
    	TA0CCTL1 = OUTMOD_7;
    	//pwm duty cycle
    	TA0CCR1 = par[2]*4;
    	//choose SMCLK and up mode
    	TA0CTL = TASSEL_2 + MC_1;
    	cmd = CMD_PASS;
    	break;
    case CMD_GPIO_GETPWM:
    	pin_num = (0x01 << par[1]);

    	n = 0;
    	duty_cycle = 0;
    	percent_on = 0;
    	time_stamp[0].time = 0;
    	time_stamp[1].time = 0;
    	time_stamp[2].time = 0;
    	time_stamp[0].edge = 0;
    	time_stamp[1].edge = 0;
    	time_stamp[2].edge = 0;

    	if (par[0] == PAR_PORT1) {
    		P1SEL |= pin_num;                            // TA0.1 option select
    	} else if (par[0] == PAR_PORT2) {
    		P2SEL |= pin_num;
    	} else if (par[0] == PAR_PORT3) {
    		P3SEL |= pin_num;
    	} else {
    		// bad port number
    	}
    	TACTL |= TASSEL_2 + MC_2 + ID_0;    // SMCLK + Continuous mode
    	TACCTL0 |= CM_3 + CCIS_0 + SCS + CAP + CCIE ;    // Raising Edge/Falling + CCI0A + Sync + Capture Mode + Interrupt enable
    	//__enable_interrupt();
    	unsigned char loc_err_cnt = 0;
    	while(loc_err_cnt < 3){
        	if (n > 2){
        		if (time_stamp[0].edge == RISING &&
        				time_stamp[1].edge == FALLING &&
						time_stamp[2].edge == RISING) {
        			duty_cycle = time_stamp[1].time - time_stamp[0].time;
        			period = time_stamp[2].time - time_stamp[0].time;
        			break;
        		} else if (time_stamp[0].edge == FALLING &&
        				time_stamp[1].edge == RISING &&
						time_stamp[2].edge == FALLING) {
        			duty_cycle = (unsigned long)(time_stamp[2].time - time_stamp[1].time);
        			period = (unsigned long)(time_stamp[2].time - time_stamp[0].time);
        			break;
        		} else {
        			//error handler implement!
        			loc_err_cnt++;
        			continue;
        			}
        			n = 0;
        		}
        		n = 0;
        	}
		if (!period){
			percent_on = 0;
	    	cmd = CMD_PASS;
	    	break;
		}
    	n = 0;
    	TACCTL0 &= ~CCIE;
    	duty_cycle = period = 0;
        percent_on = (unsigned char)((duty_cycle*100)/period);
    	//res[++response_len - 1] = percent_on;
    	cmd = CMD_PASS;
    	break;
    case CMD_GPIO_GETFREQ:
        //TODO and check
//    	pwm_freq = CCR0;
//    	int i;
//    	for(i=0; i < sizeof(unsigned int); i++) {
//    		res[++response_len - 1] = (unsigned char)((pwm_freq));
//    	}
    	cmd = CMD_PASS;
    	break;
    case CMD_SET_PORT:
        if (par[0] == PAR_PORT1) {
        	P1DIR |= 0xFF;
        	P1OUT = par[1];
        } else if (par[0] == PAR_PORT2) {
        	P2DIR |= 0xFF;
        	P2OUT = par[1];
        } else if (par[0] == PAR_PORT3) {
        	P3DIR |= 0xFF;
        	P3OUT = par[1];
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    case CMD_GET_PORT:
        if (par[0] == PAR_PORT1) {
        	P1DIR &= 0x00;
        	res[++response_len - 1] = P1IN;
        } else if (par[0] == PAR_PORT2) {
        	P2DIR &= 0x00;
        	res[++response_len - 1] = P2IN;
        } else if (par[0] == PAR_PORT3) {
        	P3DIR &= 0x00;
        	res[++response_len - 1] = P3IN;
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    //be carefull with pins 1.6 und 1.7 (SDA and SCL)
    case CMD_SET_SEL:
        if (par[0] == PAR_PORT1) {
        	P1SEL = par[1];
        } else if (par[0] == PAR_PORT2) {
        	P2SEL = par[1];
        } else if (par[0] == PAR_PORT3) {
        	P3SEL = par[1];
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    case CMD_GET_SEL:
        if (par[0] == PAR_PORT1) {
        	res[++response_len - 1] = P1SEL;
        } else if (par[0] == PAR_PORT2) {
        	res[++response_len - 1] = P2SEL;
        } else if (par[0] == PAR_PORT3) {
        	res[++response_len - 1] = P3SEL;
        } else {
        	//bad port number
        }
        cmd = CMD_PASS;
        break;
    case CMD_SET_INTERRUPT:
    	//TODO
        cmd = CMD_PASS;
        break;
    case CMD_SPI_WRITE:
    	//TODO
        cmd = CMD_PASS;
        break;
    case CMD_SPI_READ:
    	//TODO
        cmd = CMD_PASS;
        break;
    default:
    	//TODO
        cmd = CMD_PASS;
        break;
    }
}
Example #30
0
 QDir windows(const QString &prefixHash)
 {
     return drive(prefixHash).absoluteFilePath("windows");
 }