Drive
This interface represents one of the two major components of a robot in Pathfinder: the drive train. It defines the contract for how Pathfinder interacts with and controls the robot's movement.
Key Concepts
- Robot State (Translation): The robot's movement is described by a
Translationobject, which has three components:- Y: Forwards/backwards movement.
- X: Right/left movement.
- Z: Turning (rotation around the center of the robot).
- Relative Translations: All translations provided to the
Driveinterface are expected to be relative to the robot's current orientation. If you have an absolute translation, you should convert it usingTranslation.absoluteToRelative()orTranslation.toRelative(). - Motor Control: Implementations of this interface are responsible for physically setting power to the robot's motors to achieve the desired translation.
Methods
getTranslation()
Returns the drive train's current translation. This value should reflect the last translation that was set to the drive train via setTranslation(), not necessarily the robot's actual instantaneous movement.
setTranslation(Translation translation)
Sets a new translation for the drive train. This method should cause the robot to move according to the provided relative translation. The internal state of the Drive implementation should be updated to reflect this new translation.
getDriveModifier()
Returns a Function that can modify the drive's translation. By default, this method throws an UnsupportedOperationException, indicating that the current Drive implementation does not support modifiers.
setDriveModifier(Function<Translation, Translation> modifier)
Sets a Function to modify the drive's translation. By default, this method throws an UnsupportedOperationException, indicating that the current Drive implementation does not support modifiers.