//---------------------------------------------
void CLaser::ActivateLaser(bool activate)
{
	if(activate)
		TurnOnLaser(true);
	else
		TurnOffLaser(true);
}
Example #2
0
static void LaserTest() {
    InitMotorBoard();
    continueTest = true;

    while (continueTest) {
        TurnOnLaser();
        MB_Sleep(1000);
        TurnOffLaser();
        MB_Sleep(1000);
    }
}
//-----------------------------------------------
void CLaser::OnParentSelect(bool select)
{
	if(select)
	{
		TurnOnLaser();
	}
	else
	{
		TurnOffLaser();
	}
}
//---------------------------------------------
void CLaser::OnEnterThirdPerson()
{
	CAccessory::OnEnterThirdPerson();

	m_laserBeam.SetGeometrySlot(eIGS_ThirdPerson);

	if (m_laserBeam.IsLaserActivated())
	{	
		TurnOffLaser();
		TurnOnLaser();
	}
}
//-------------------------------------------------
void CLaser::OnAttach(bool attach)
{	
	if(attach)
	{
		CWeapon* pParent = GetWeapon();

		if((pParent == NULL) || pParent->GetStats().selected)
		{
			TurnOnLaser();
		}
	}
	else
	{
		TurnOffLaser();
	}
}
Example #6
0
static void MotorPatternTest() {
    InitMotorBoard();
    TurnOnLaser();
    EnablePanServo();
    EnableTiltServo();

    continueTest = true;

    while (continueTest) {
        for (int i = -60; i < 0; i++) {
            SetPanAngle(i);
            SetTiltAngle(i + 60);
            MB_Sleep(15);
        }
        MB_Sleep(20);

        for (int i = 0; i < 60; i++) {
            SetPanAngle(i);
            SetTiltAngle(60 - i);
            MB_Sleep(15);
        }
        MB_Sleep(20);

        for (int i = 60; i > 0; i--) {
            SetPanAngle(i);
            SetTiltAngle(i - 60);
            MB_Sleep(15);
        }
        MB_Sleep(20);

        for (int i = 0; i > -60; i--) {
            SetPanAngle(i);
            SetTiltAngle(-60 - i);
            MB_Sleep(15);
        }
        MB_Sleep(20);
    }

    TurnOffLaser();
    DisablePanServo();
    DisableTiltServo();
}
Example #7
0
void ManualMainLoop(void) {
    // Set up the turret control IP.
    InitMotorBoard();
    TurnOnLaser();
    EnablePanServo();
    EnableTiltServo();
    SetTiltAngle(0);
    SetPanAngle(0);

    continueTest = true;
    xil_printf("Entering manual mode.\r\n");
    while(continueTest) {
        // We allow users to press more than one button at a time.
        if (sButtonState & BUTTON_LEFT) {
            PanLeft(1);
        }

        if (sButtonState & BUTTON_RIGHT) {
            PanRight(1);
        }

        if (sButtonState & BUTTON_UP) {
            TiltUp(1);
        }

        if (sButtonState & BUTTON_DOWN) {
            TiltDown(1);
        }

        MB_Sleep(7);
    }

    SetTiltAngle(0);
    SetPanAngle(0);
    MB_Sleep(100);
    DisableTiltServo();
    DisablePanServo();
    TurnOffLaser();
}
Example #8
0
static void AutoMainLoop(void) {
    int x_diff;
    int y_diff;
    int x_adj;
    int y_adj;

    InitMotorBoard();
    TurnOnLaser();
    EnablePanServo();
    EnableTiltServo();
    SetTiltAngle(DEFAULT_X_POS);
    SetPanAngle(DEFAULT_Y_POS);

    int acquired = 0;
    int sleep_interval;

    continueTest = true;
    xil_printf("Entering auto mode.\r\n");
    while(continueTest) {
        runImageProcessing();

        SetObjIdValue(1);
        TargetingState state = get_targeting_state();
        int target_x = state.target_loc.x;
        int target_y = state.target_loc.y;
        u32 target_size = state.target_size;

        xil_printf(
                "Targeting state: Laser = (%d,%d); Obj = (%d, %d) [sz=%d]\n\r",
                state.laser.x, state.laser.y, target_x, target_y, target_size);

        if (state.laser.x == 0 && state.laser.y == 0) {
            SetPanAngle(DEFAULT_X_POS);
            SetTiltAngle(DEFAULT_Y_POS);
            playNeg();
            goto loop_sleep;
        }

        // Get the diffs in both dimensions.
        //x_diff = X_MIDDLE;
        //y_diff = Y_MIDDLE;
        x_diff = (target_x - state.laser.x);
        y_diff = (state.laser.y - target_y);

        // Determine how much to adjust the angles.
        x_adj = (x_diff > 0) ? x_diff : -x_diff;
        x_adj /= 16;

        int MAX_ANGLE = 10;
        if (x_adj > MAX_ANGLE) {
            x_adj = MAX_ANGLE;
        } else if (x_adj == 0 && x_diff != 0) {
            x_adj = 1;
        }

        y_adj = (y_diff > 0) ? y_diff : -y_diff;
        y_adj /= 16;

        if (y_adj > MAX_ANGLE) {
            y_adj = MAX_ANGLE;
        } else if (y_adj == 0 && y_diff != 0) {
            y_adj = 1;
        }

        // Adjust laser position to correct for these diffs.
        if (x_diff > LASER_TOLERANCE) {
            xil_printf("Need to move laser right by %d deg\r\n", x_adj);
            PanRight(x_adj);
        } else if (x_diff < -LASER_TOLERANCE) {
            xil_printf("Need to move laser left by %d deg\r\n", x_adj);
            PanLeft(x_adj);
        } else {
            xil_printf("X location on target!\r\n");
        }

        if (y_diff > LASER_TOLERANCE) {
            xil_printf("Need to move laser up by %d deg\r\n", y_adj);
            TiltUp(y_adj);
        } else if (y_diff < -LASER_TOLERANCE) {
            xil_printf("Need to move laser down by %d deg\r\n", y_adj);
            TiltDown(y_adj);
        } else {
            xil_printf("Y location on target!\r\n");
        }

        if (x_diff <= LASER_TOLERANCE && x_diff >= -LASER_TOLERANCE &&
                y_diff <= LASER_TOLERANCE && y_diff >= -LASER_TOLERANCE) {
            if (acquired) {
                playPortalGunSound();
            } else {
                playPos();
                acquired = 1;
            }
        } else {
            acquired = 0;
        }

loop_sleep:
        sleep_interval = sDebugOutputEnabled ? 3000 : 500;
        MB_Sleep(sleep_interval);
    }
    SetTiltAngle(0);
    SetPanAngle(0);
    MB_Sleep(100);
    DisableTiltServo();
    DisablePanServo();
    TurnOffLaser();
}
Example #9
0
static void LaserOn() {
    TurnOnLaser();
}