SetAngle for turret not working properly

Hello, so I’m testing this system with a turret from another robot, to where when it reaches the max angle of the turret, it goes all the way around to the min angle, and when it’s done with that it goes back to tracking the target. However, for some reason, when it goes to turn to the max angle, it doesn’t go all the way and just stops midway for some reason. Could someone take a look at it and see if I’m just missing something? I’ve checked the PIDs, and they’re all working fine, and the setAngle and set methods are working fine too.

public void trackTarget(double measure) {

    // set(aimingPID.calculate(measure, 0));
    if (getPosition() >= MAX_ANG || !maxchanging)
    {
        maxchanging = true;
        setAngle(-30);
        if (getPosition() <= -30) {
            maxchanging = false;
        }
    }
    else if (getPosition() <= MIN_ANG || !minchanging)
    {
        minchanging = true;
        setAngle(253);
        if (getPosition() >= 253) {
            minchanging = false;
        }
    }
    if (!maxchanging && !minchanging)
    {
        setAngle(getPosition() - measure);
    }
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.