コード例 #1
0
ファイル: ArmLower.cpp プロジェクト: FRC1280/2016Stronghold
//------------------------------------------------------------------------------
// METHOD:  ArmLower::GoToPotTarget()
// Type:	Private method
//------------------------------------------------------------------------------
// Moves the arm Arm until it reaches the target position, or activates
// the upper or lower limit switches.
// *** NOTE TO ALLOW THE LIMIT SWITCHES TO READ THE WAY WE WANT THEM TO IN THE
// **  CODE - WIRE THEM "NORMAL CLOSED" OR NC.
//------------------------------------------------------------------------------
bool  ArmLower::GoToPOTTarget(double inputPotValue)
{
	bool   potTargetFound  = false;
	double targetLowValue  = inputPotValue - TARGET_TOLERANCE;
	double targetHighValue = inputPotValue + TARGET_TOLERANCE;

	if ( pArmPot->Get() >= targetLowValue  &&
		 pArmPot->Get() <= targetHighValue )
	{
		StopArm();
		potTargetFound   = true;
	}
	else
	{
		if ( pArmPot->Get() > targetHighValue )  // Arm moving down
		{
			MoveArmUp();
		}
		else
		{
			if ( pArmPot->Get() < targetLowValue )  // Arm moving up
			{
					MoveArmDown();
			}
		}
	}

	return potTargetFound;
}
コード例 #2
0
//////////////////////////////////////SETS 4-BAR POSITION////////////////////////////////////////////////////////////////
void fourbarlift()
{
	fourbarpower = joystick.joy2_y2;
	if(abs(fourbarpower) > 8)			//deadband with threshold of 8
	{
		if (fourbarpower > 0) {
			fourbarposition = MoveArmUp(fourbarposition, 100);
		}
		//if we're going down
		if (fourbarpower < 0) {
			fourbarposition = MoveArmDown(fourbarposition, 100);
		}
	}
	//if(debug) {nxtDisplayString(2, "encoder: %i", nMotorEncoder[FourBar]);}
}