Exemplo n.º 1
0
void EnhancedRobotDrive::doControls() {
    if((std::fabs(driver -> GetRawAxis(DRIVER_LEFT_DRIVE_AXIS)) > EnhancedJoystick::JOYSTICK_ZERO_TOLERANCE) || (std::fabs(driver -> GetRawAxis(DRIVER_RIGHT_DRIVE_AXIS)) > EnhancedJoystick::JOYSTICK_ZERO_TOLERANCE))
    {
        //Skyler Driving
        TankDrive((driver -> GetRawAxis(DRIVER_LEFT_DRIVE_AXIS) * drivePower),(driver -> GetRawAxis(DRIVER_RIGHT_DRIVE_AXIS) * drivePower));
    }
    else if((gunner -> GetRawButton(GUNNER_SWIVEL_RIGHT) || gunner -> GetRawButton(GUNNER_SWIVEL_LEFT)) && *robotState == robot_class::NORMAL)
    {
        //Ben Swivel
        if(gunner -> GetRawButton(GUNNER_SWIVEL_RIGHT))
        {
            swivel(RIGHT);
        }
        else
        {
            swivel(LEFT);
        }
    }
    else if(driver -> GetRawButton(DRIVER_SWIVEL_RIGHT) || driver -> GetRawButton(DRIVER_SWIVEL_LEFT))
    {
        //Skyler Swivel
        if(driver -> GetRawButton(DRIVER_SWIVEL_RIGHT))
        {
            swivel(RIGHT);
        }
        else
        {
            swivel(LEFT);
        }
    }
    else
        TankDrive(0.0f,0.0f);
}
Exemplo n.º 2
0
void SimpleDrive::TankDrive(float leftValue, float rightValue, bool squaredInputs) {
	if (squaredInputs) {
		leftValue = Tools::SquareMagnitude(leftValue);
		rightValue = Tools::SquareMagnitude(rightValue);
	}
	TankDrive(leftValue, rightValue);
}
Exemplo n.º 3
0
    void OperatorControl(void)
    {
        OperatorControlInit();
        compressor.Start();
        testActuator.Start();

        while (IsOperatorControl())
        {
            ProgramIsAlive();
            //No need to do waits because ProgramIsAlive function does a wait. //Wait(0.005);

            bool isButtonPressed = stick.GetRawButton(3);
            SmartDashboard::PutNumber("Actuator Button Status",isButtonPressed);
            if (isButtonPressed)
            {
                testActuator.Go();
            }


            float leftYaxis = stick.GetY();
            float rightYaxis = stick.GetRawAxis(5);	//RawAxis(5);
            TankDrive(leftYaxis,rightYaxis); 	// drive with arcade style (use right stick)for joystick 1
            SmartDashboard::PutNumber("Left Axis",leftYaxis);
            SmartDashboard::PutNumber("Right Axis",rightYaxis);
        }
    }
Exemplo n.º 4
0
/**
 * Provide tank steering using the stored robot configuration.
 * Drive the robot using two joystick inputs. The Y-axis will be selected from
 * each Joystick object.
 * @param leftStick The joystick to control the left side of the robot.
 * @param rightStick The joystick to control the right side of the robot.
 */
void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick,
                           bool squaredInputs) {
  if (leftStick == nullptr || rightStick == nullptr) {
    wpi_setWPIError(NullParameter);
    return;
  }
  TankDrive(leftStick->GetY(), rightStick->GetY(), squaredInputs);
}
Exemplo n.º 5
0
/**
 * Provide tank steering using the stored robot configuration.
 * Drive the robot using two joystick inputs. The Y-axis will be selected from
 * each Joystick object.
 * @param leftStick The joystick to control the left side of the robot.
 * @param rightStick The joystick to control the right side of the robot.
 */
void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick)
{
	if (leftStick == NULL || rightStick == NULL)
	{
		wpi_fatal(NullParameter);
		return;
	}
	TankDrive(leftStick->GetY(), rightStick->GetY());
}
Exemplo n.º 6
0
/**
 * Provide tank steering using the stored robot configuration.
 * This function lets you pick the axis to be used on each Joystick object for the left
 * and right sides of the robot.
 * @param leftStick The Joystick object to use for the left side of the robot.
 * @param leftAxis The axis to select on the left side Joystick object.
 * @param rightStick The Joystick object to use for the right side of the robot.
 * @param rightAxis The axis to select on the right side Joystick object.
 */
void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis,
		GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs)
{
	if (leftStick == NULL || rightStick == NULL)
	{
		wpi_setWPIError(NullParameter);
		return;
	}
	TankDrive(leftStick->GetRawAxis(leftAxis), rightStick->GetRawAxis(rightAxis), squaredInputs);
}
Exemplo n.º 7
0
/**
 * Provide tank steering using the stored robot configuration.
 * This function lets you pick the axis to be used on each Joystick object for the left
 * and right sides of the robot.
 * @param leftStick The Joystick object to use for the left side of the robot.
 * @param leftAxis The axis to select on the left side Joystick object.
 * @param rightStick The Joystick object to use for the right side of the robot.
 * @param rightAxis The axis to select on the right side Joystick object.
 */
void RobotDrive::TankDrive(GenericHID *leftStick, UINT32 leftAxis,
		GenericHID *rightStick, UINT32 rightAxis)
{
	if (leftStick == NULL || rightStick == NULL)
	{
		wpi_fatal(NullParameter);
		return;
	}
	TankDrive(leftStick->GetRawAxis(leftAxis), rightStick->GetRawAxis(rightAxis));
}
Exemplo n.º 8
0
bool DriveTrain::NewSpinCW(double speed, double angle)
{
	if(mGyro->IsWorking())
	{
		if(mIsDoneDriving)
		{
			mIsDoneDriving = false;
			ResetGyro();
			TankDrive(speed, -speed);
		}
		else if(fabs(mGyro->GetZ()) >= angle)
		{
			StopDriving();
			mIsDoneDriving = true;
		}
		else
		{
			TankDrive(speed, -speed);
		}
	}
	else
	{
		if (mIsDoneDriving)
		{
			mIsDoneDriving = false;
			ResetEncoders();
			TankDrive(speed, -speed);
		}
		else if (fabs(mLeftMaster->GetPosition()) >= (angle / 360.0) * WHEEL_BASE_CIRCUMFERENCE || fabs(mRightMaster->GetPosition()) >= (angle / 360.0) * WHEEL_BASE_CIRCUMFERENCE)
		{
			StopDriving();
			ResetEncoders();
			mIsDoneDriving = true;
		}
		else
		{
			TankDrive(speed, -speed);
		}
	}

	return mIsDoneDriving;
}
Exemplo n.º 9
0
bool DriveTrain::AutoTurn(double target, double kP){ // THIS IS WORKING!! DO NOT OVERWRITE!!!!!!!!!!!!!!!!!!!!!!!

	SmartDashboard::PutString("Current Task", "auto turn");

	int angleDiff = ((int)(GetGyro()-target)) % 360 ; //angle diff
	double error = (1 - (( (double) abs( abs(angleDiff) - 180 ) / 180.0))) * kP;

	if(((angleDiff > 0 && angleDiff <= 180) || (angleDiff < -180))){
		TankDrive(((0.1 * error) + 0.9), -(0.1 * error + 0.9));
	}
	else if(((angleDiff < 0 && angleDiff >= -180) || (angleDiff > 180))){
		TankDrive(-(0.1 * error + 0.9), (0.1 * error + 0.9));
	}
	else{
		TankDrive(0.0f, 0.0f);
		return true;
	}

	return false;
}
Exemplo n.º 10
0
bool DriveTrain::GoUltraForward(double distance, float baseSpeed, double target, double kP, double source){ // THIS IS WORKING!! DO NOT OVERWRITE!!!!!!!!!!!!!!!!!!!!!!!

	double absoluteTolerance = 5; //in cms
	SmartDashboard::PutString("Current Task", "automove");

	double currentDistance = source; //return value in meteres with temp compensation

	double directionSpeed;
	double goingBack; //i'm confused which way is front, but i'm glad that I'm not the only one
	if(distance < currentDistance){
		goingBack = 1;
		directionSpeed = -baseSpeed;
	}else{
		directionSpeed = baseSpeed; //don't ask
		goingBack = 0;
	}

	SmartDashboard::PutNumber("abs", abs(currentDistance*10 - distance*10));
	SmartDashboard::PutNumber("absoluteTolerance", absoluteTolerance);


	int angleDiff = ((int)(GetGyro() - target)) % 360;

	double error = (((double)abs(abs(angleDiff) - goingBack * 180)/180.0) * 2 - 1.0) * kP; //1.0 - -1.0 //kP must be =< 1.0

	if(((angleDiff > 0 && angleDiff <= 180) || (angleDiff < -180)) && abs(currentDistance*100 - distance*100)>=absoluteTolerance){
		TankDrive(directionSpeed * error, directionSpeed);
	}
	else if(((angleDiff < 0 && angleDiff >= -180) || (angleDiff > 180)) && abs(currentDistance*100 - distance*100)>=absoluteTolerance){
		TankDrive(directionSpeed, directionSpeed * error);
	}
	else if(angleDiff == 0  && abs(currentDistance*100 - distance*100)>=absoluteTolerance){
		TankDrive(directionSpeed, directionSpeed);
	}
	else{
		TankDrive(0.0f, 0.0f);
		return true;
	}
	return false;

}
Exemplo n.º 11
0
bool DriveTrain::GoForward(double distance, float baseSpeed, double target, double kP){ // THIS IS WORKING!! DO NOT OVERWRITE!!!!!!!!!!!!!!!!!!!!!!!

	double absoluteTolerance = 10;
	SmartDashboard::PutString("Current Task", "automove");
	double currentDistance = GetRightEncoderValue();

	double directionSpeed;
	double goingBack; //i'm confused which way is front, but i'm glad that I'm not the only one
	if(distance > currentDistance){
		goingBack = 1;
		directionSpeed = -baseSpeed;
	}else{
		directionSpeed = baseSpeed; //don't ask
		goingBack = 0;
	}

	SmartDashboard::PutNumber("EncoderReading", currentDistance);
	SmartDashboard::PutNumber("Goalz", distance);


	int angleDiff = ((int)(GetGyro() - target)) % 360;

	double error = (((double)abs(abs(angleDiff) - goingBack * 180)/180.0) * 2 - 1.0) * kP; //1.0 - -1.0 //kP must be =< 1.0

	if(((angleDiff > 0 && angleDiff <= 180) || (angleDiff < -180)) && abs(currentDistance - distance)>=absoluteTolerance){
		TankDrive(directionSpeed * error, directionSpeed);
	}
	else if(((angleDiff < 0 && angleDiff >= -180) || (angleDiff > 180)) && abs(currentDistance - distance)>=absoluteTolerance){
		TankDrive(directionSpeed, directionSpeed * error);
	}
	else if(angleDiff == 0  && abs(currentDistance - distance)>=absoluteTolerance){
		TankDrive(directionSpeed, directionSpeed);
	}
	else{
		TankDrive(0.0f, 0.0f);
		return true;
	}
	return false;

}
Exemplo n.º 12
0
bool DriveTrain::NewDriveDistance(double speed, double distance)
{
	if (mIsDoneDriving)
	{
		mIsDoneDriving = false;
		ResetEncoders();
		TankDrive(speed, speed);
		std::cout << distance << '\n';
	}
	else if (fabs(mLeftMaster->GetPosition()) >= distance || fabs(mRightMaster->GetPosition()) >= distance)
	{
		StopDriving();
		ResetEncoders();
		mIsDoneDriving = true;
	}
	else
	{
		TankDrive(speed, speed);
	}

	return mIsDoneDriving;
}
Exemplo n.º 13
0
// Spin clockwise
bool DriveTrain::SpinCW(double speed, double angle)
{
	if (mIsDoneDriving)
	{
		mIsDoneDriving = false;
		ResetEncoders();
		Wait(0.1);
		TankDrive(speed, -speed);
	}
	else if (GetDistance() >= (angle / 360.0) * WHEEL_BASE_CIRCUMFERENCE)
	{
		StopDriving();
		ResetEncoders();
		Wait(0.1);
		mIsDoneDriving = true;
	}

	return mIsDoneDriving;
}
task main()
{
	//false=off
	servo[basketServo]=basketServoUp;

	while(true)
	{
		getJoystickSettings(joystick);

		//Calls the tank drive function
		TankDrive();

		//Calls the sweeper function
		Sweeper();

		//Moving the arm up or down
		if(ARMJOYSTICK>deadZone && armEnabled==true)
		{
			motor[armMotor]=armMotorUp;
		}
		else if(ARMJOYSTICK<-deadZone && armEnabled==true)
		{
			//Checks if touchsensor is pressed before moving the arm
			if(SensorValue[touchSensor]==touchUnpressed)
			{
				motor[armMotor]=-armMotorUp;
			}
			else
			{
				motor[armMotor]=off;
			}
		}
		else
		{
			motor[armMotor]=off;
		}

		//Calls the functions
		BasketStateMachine();
		FlagMotor();
	}
}
Exemplo n.º 15
0
// Drives certain distance
bool DriveTrain::DriveDistance(double speed, double distance)
{
	if (mIsDoneDriving)
	{
		mIsDoneDriving = false;
		ResetEncoders();
		Wait(0.1);
		TankDrive(speed, speed);
	}
	else if (GetDistance() >= distance)
	{
		StopDriving();
		ResetEncoders();
		Wait(0.1);
		mIsDoneDriving = true;
	}



	return mIsDoneDriving;
}
Exemplo n.º 16
0
/*******************************************************************************
*
*	FUNCTION:		Teleop()
*
*	PURPOSE:		This is where you put code that you want to execute while
*					your robot is in teleoperation mode. While in teleoperation
*					mode, this function is called every	26.2ms after new data
*					is received from the master processor.
*
*	CALLED FROM:	main() in ifi_frc.c
*
*	PARAMETERS:		None
*
*	RETURNS:		Nothing
*
*	COMMENTS:		While in this mode, all operator interface data is valid
*					and all robot controller outputs are enabled.
*
*******************************************************************************/
void Teleop(void)
{
    static int launch_stick = 0;
    static unsigned char out=127;
   //printf("in loop\r\n");

    TankDrive();


    if(p2_sw_top) ShiftHigh();
    if(p2_sw_trig) ShiftLow();

    if(p1_sw_top) OrientationFwd();
    if(p1_sw_trig) OrientationRev();

    DriveHandler();
    Compressor_Handler();





    // Launcher Control
    /*launch_stick = (int)(p4_y) - 127;
    if( launch_stick >=0) launch_stick = launch_stick;
    else launch_stick = launch_stick;
    out = (unsigned char)LimitChar(launch_stick);
    //LAUNCHER_PWM  = out;
    */
    //
    //printf("Top: %d | Trig: %d | aux1: %d | aux2: %d | y: %d \r\n",p3_sw_top,p3_sw_trig,p3_sw_aux1,p3_sw_aux2,p3_y);


   Launcher_Handler();


	// update the state of the LEDs on the operator interface
	Update_OI_LEDs();		// located in ifi_code.c

}
Exemplo n.º 17
0
// Stops Driving
void DriveTrain::StopDriving()
{
	TankDrive(0, 0);
}
Exemplo n.º 18
0
void RobotDrive::TankDrive(GenericHID &leftStick, uint32_t leftAxis,
		GenericHID &rightStick, uint32_t rightAxis, bool squaredInputs)
{
	TankDrive(leftStick.GetRawAxis(leftAxis), rightStick.GetRawAxis(rightAxis), squaredInputs);
}
Exemplo n.º 19
0
void PidSimpleDrive::TankDrive(float leftValue, float rightValue) {
	TryToggling(Rate);
	TankDrive(leftValue, rightValue, false);
}
Exemplo n.º 20
0
void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick, bool squaredInputs)
{
	TankDrive(leftStick.GetY(), rightStick.GetY(), squaredInputs);
}
Exemplo n.º 21
0
void EnhancedRobotDrive::swivel(dir d) {
    if(d == LEFT)
        TankDrive(DRIVE_TURN_SPEED,-1.0 * DRIVE_TURN_SPEED);
    else
        TankDrive(-1.0 *DRIVE_TURN_SPEED,DRIVE_TURN_SPEED);
}
Exemplo n.º 22
0
/**
 * Tells the robot to stop moving, accounting for things like
 * slipping and sliding.
 * 
 * On the SimpleDrive, this is equivalent to calling 
 * SimpleDrive::StopMoving.
 */
void SimpleDrive::Brake() {
	TankDrive(0.0, 0.0);
}
Exemplo n.º 23
0
void RobotDrive::TankDrive(GenericHID &leftStick, UINT32 leftAxis,
		GenericHID &rightStick, UINT32 rightAxis)
{
	TankDrive(leftStick.GetRawAxis(leftAxis), rightStick.GetRawAxis(rightAxis));
}
Exemplo n.º 24
0
void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick)
{
	TankDrive(leftStick.GetY(), rightStick.GetY());
}