Skip to content

Turret should use a deadband to stop motor if the turret is already "close enough" #249

Description

@jamesdooley4

To avoid turret jitter and energy loss from the PID trying to get the turret to sub-degree accuracy but actually just causing it to jitter, the TurretSubsystem should have a distance-to-target scaled deadband where the turret motor is set to NeutralOut.

Similar to the turretAtTarget in the LauncherSubsystem, in rotateToTargetWithCalc the turret should get the current distance to the target, use Math.atan() to determine the radian size of a ~2cm (or similar size much smaller than the LauncherSubsystem 'at target' size). It should then send a NeutralOut request to the turret if the current position is within that range of the requested finalTarget and the FFV value is "small" (say, 0.05 radians / sec). The deadband should have fixed minimum and maximum sizes (in degrees) to ensure its size is reasonable at very far distances and very short distances, such as 0.1 and 1.0.

If jitter is still seen from the turret frequency crossing over the deadband and flipping between NeutralOut and PositionVoltage, consider adding some hysteresis where the turret exits the deadband if the error is 1.5x of the deadband size and enters it when the error is smaller than the deadband size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions