Пример #1
0
task buttons(){
	if(strafe){
		if(vexRT[Btn8L] == 1){
			driveEnable = false;
			setDrive(strafeSpeed*-1);
		}
		else if(vexRT[Btn8R] == 1){
			driveEnable = false;
			setDrive(strafeSpeed);
		}
		else if(vexRT[Btn8U] == 1){
			driveEnable = false;
			runExpansion();
		}
		else driveEnable = true;
	}
	if(vexRT[Btn7D] == 1) strafe = true;
	if(vexRT[Btn8D] == 1) strafe = false;

	if(vexRT[Btn5U] == 1) armState = 1;
	else if(vexRT[Btn5D] == 1) armState = 2;
	else armState = 0;

	if(vexRT[Btn6U] == 1) setIntake(intakeSpeed);
	else if(vexRT[Btn6D] == 1) setIntake(intakeSpeed*-1);
	else setIntake(0);
}
Пример #2
0
task usercontrol()
{
	float maxRPM = 230;
	// Start the flywheel control task
	startTask( FwControlTask );
	while (true)
	{
	// Different speeds set by buttons
        if( vexRT[ Btn8U ] == 1 )
            FwVelocitySet( .9*maxRPM, 0.80 );//Test These Numbers
        if( vexRT[ Btn8L ] == 1 )
            FwVelocitySet( .8*maxRPM, 0.70 );
        if( vexRT[ Btn8R ] == 1 )
            FwVelocitySet( .7*maxRPM, 0.60 );
        if( vexRT[ Btn8D ] == 1 )
            FwVelocitySet( 00, 0 );
		int driveX = -vexRT[Ch2];
		int driveY = vexRT[Ch1] ;
		int intakeForward = vexRT[Btn5U];
		int intakeBackwards = vexRT[Btn5D];
		driveArcade(driveY * 127 / 128, driveX * 127 / 128);
		setIntake(intakeForward*127, intakeBackwards*127);
		wait1Msec(10);
	}
}
Пример #3
0
	task usercontrol()
	{
		// User control code here, inside the loop

		while (true)
		{
			//All the floats
			float xL = vexRT[Ch4];
			float yL = vexRT[Ch3];
			float xR = vexRT[Ch1];
			float yR = vexRT[Ch2];
			int deadBand = 5;
			int intakeForward = vexRT[Btn6U];
			int intakeBackwards = vexRT[Btn6D];
			setIntake(intakeForward*75, intakeBackwards*75);
			//Drive Code
			motor[frontLeft] = xR + yR;
			motor[backRight] =  xR - yR;
			motor[backLeft] = xL + yL;
			motor[frontRight] =  xL - yL ;
			//Deadband
			if(xL > deadBand || xL < -deadBand)
			{
				xL = xL;
			}
			else
			{
				xL = 0;
			}
			if(yL > deadBand || yL < -deadBand)
			{
				yL = yL;
			}
			else
			{yL = 0;
			}
			if(xR > deadBand || xR < -deadBand)
			{
				xR = xR;
			}
			else
			{xR = 0;
			}
			if(yR > deadBand || yR < -deadBand)
			{
				yR = yR;
			}
			else
			{
				yR = 0;
			}
		}
	}
/* Autonomous */
task autonomous(){

	bool blueSide = true;
	initMotor(&motorLeftShooter, leftShooter1, leftShooter2, leftShooterSensor);
	initMotor(&motorRightShooter, rightShooter1, rightShooter2, rightShooterSensor);
	clearAll(actOnSensors);
	startTask(autonShooterControl);
	if(blueSide)
	{
		autonTargetSpeed = 75;

		wait1Msec(1200);
		for(int i = 0; i < 5; i++)
		{
			wait1Msec(2000);
			setIntake(120);
			wait1Msec(500);
			setIntake(0);
		}
	}
	while(true){}

}
task usercontrol()
{
	// User control code here, inside the loop

	while (true)
	{
		// This is the main execution loop for the user control program. Each time through the loop
		// your program should update motor + servo values based on feedback from the joysticks.

		// .....................................................................................
		// Insert user code here. This is where you use the joystick values to update your motors, etc.
		// .....................................................................................
		int intakeForward = vexRT[Btn5U];
		int intakeBackwards = vexRT[Btn5D];
		float setPoint = 98;
				int window = 25;
		int x = vexRT[Ch3];
		if(abs(x) < window)
			x = 0;
		int y = vexRT[Ch4];
		if(abs(y) < window)
			y = 0;
		int r = vexRT[Ch1];
		int shooting = 1;
		int motorShoot = 0;
		if(abs(r) < window)
			r = 0;
		drive(x, y, r);
		setIntake(intakeForward*127, intakeBackwards*127);
		float scaleFactor = 1.0;
		if (vexRT[Btn7U] == 1){
			setPoint = 98;
			scaleFactor = .90;
		} else if (vexRT[Btn7L] == 1){
			setPoint = 91;
			scaleFactor = .85;
		} else if (vexRT[Btn7R] == 1){
			setPoint = 83;
			scaleFactor = .80;
		} else if (vexRT[Btn7D] == 1){
			setPoint = 78;
			scaleFactor = 0.75;
		} else if (vexRT[Btn8U] == 1){
			setPoint = 73;
			scaleFactor = 0.70;
		} else if (vexRT[Btn8L] == 1){
			setPoint = 68;
			scaleFactor = 0.65;
		} else if (vexRT[Btn8R] == 1){
		  setPoint = 61;
			scaleFactor = 0.60;
		} else if (vexRT[Btn8D] == 1){
		  setPoint = 54;
			scaleFactor = 0.55;
		} else {
			shooting = 0;
		}
		float diffRPM = setPoint - getMotorVelocity(rightShoot1);
		//////////////////////////////////////////////////////////
		/*
		if (shooting && getMotorVelocity(rightShoot1) < setPoint )
		{
			motorShoot = 100 * scaleFactor;
		}
		else if (shooting == 1 && getMotorVelocity(rightShoot1) > setPoint )
		{
			motorShoot = 40 * scaleFactor;
		}
		else if (shooting == 1 && getMotorVelocity(rightShoot1) == setPoint)
		{
			motorShoot = 80 * scaleFactor;
		}
		*/
		if (shooting == 1) {
			motorShoot = scaleFactor*127.0;
		}
		else if(shooting == 0)
		{
			motorShoot = 0;
		}
		motor[leftShoot1] = motor[leftShoot2] = motor[rightShoot1] = motor[rightShoot2] = motorShoot;
		// This is the main execution loop for the user control program. Each time through the loop
		// your program should update motor + servo values based on feedback from the joysticks.

		// .....................................................................................
		// Insert user code here. This is where you use the joystick values to update your motors, etc.
		// .....................................................................................
	}
}
Пример #6
0
task usercontrol()
{
	slaveMotor(shooterLB, shooterL);
	slaveMotor(shooterRB, shooterR);
	while(true)
	{
		//Warning Killer
		if (0 == 1)
		{
			warningKiller();
			rotateL(0);
			rotateR(0);
		}
		//All the ints
		int intakeForward = vexRT[Btn6U];
		int intakeBackwards = vexRT[Btn5U];
		int deadBand = 10;
		//All the floats
		float xL = vexRT[Ch4];
		float yL = vexRT[Ch3];
		float xR = vexRT[Ch1];
		float yR = vexRT[Ch2];
		//Intake & Shooter
		if (vexRT[Btn7U])
		{
			motor[shooterL] = 100;//These numbers are abritrary. i.e. 100 = fast, 10 = slow, 0 = no power
			motor[shooterR] = 100;
		}
		else
		{
			motor[shooterL] = 0;
			motor[shooterR] = 0;
		}
		setIntake(intakeForward*75, intakeBackwards*75);
		//Drive Code
		motor[leftFront] = xR + yR;
		motor[rightRear] =  xR - yR;
		motor[leftRear] = xL + yL;
		motor[rightFront] =  xL - yL ;
		//Deadband
		if(xL > deadBand || xL < -deadBand)
		{
			xL = xL;
		}
		else
		{
			xL = 0;
		}
		if(yL > deadBand || yL < -deadBand)
		{
			yL = yL;
		}
		else
		{
			yL = 0;
		}
		if(xR > deadBand || xR < -deadBand)
		{
			xR = xR;
		}
		else
		{
			xR = 0;
		}
		if(yR > deadBand || yR < -deadBand)
		{
			yR = yR;
		}
		else
		{
			yR = 0;
		}
	}
}