Class TankDriveData


  • public class TankDriveData
    extends Object
    Encapsulates drive commands for a tank drive. TankDriveData instances are usually passed around in drive pipelines. Each TankDriveData instance contains DriveData instances for the left and right side, as well as commands for heading and turning rate.
    See Also:
    DriveData
    • Field Detail

      • left

        @NotNull
        public final @NotNull DriveData left
        The drive data for the left side.
      • right

        @NotNull
        public final @NotNull DriveData right
        The drive data for the right side.
      • heading

        @NotNull
        public final @NotNull OptionalDouble heading
        The desired heading in radians from 0 (straight forward) to 2π, increasing clockwise, or an empty optional if heading should not be controlled.
      • turningRate

        @NotNull
        public final @NotNull OptionalDouble turningRate
        The desired turning rate in radians/sec, or an empty optional if turning rate should not be controlled.
    • Constructor Detail

      • TankDriveData

        public TankDriveData()
        Creates a new TankDriveData with all fields empty.
      • TankDriveData

        public TankDriveData​(@NotNull
                             @NotNull DriveData left,
                             @NotNull
                             @NotNull DriveData right,
                             @NotNull
                             @NotNull OptionalDouble heading,
                             @NotNull
                             @NotNull OptionalDouble turningRate)
        Creates a new TankDriveData with the supplied values.
        Parameters:
        left - The DriveData for the left side.
        right - The DriveData for the right side.
        heading - The desired heading in radians from 0 (straight forward) to 2π, increasing clockwise, or an empty optional if heading should not be controlled.
        turningRate - The desired turning rate in radians/sec, or an empty optional if turning rate should not be controlled.
    • Method Detail

      • modifyHeading

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData modifyHeading​(@NotNull
                                                    @NotNull Function<OptionalDouble,​OptionalDouble> function)
        Creates a copy of this TankDriveData with a modified heading.
        Parameters:
        function - A Function that takes this DriveData's current heading and returns a new heading.
        Returns:
        A copy of this TankDriveData with all fields identical except for the heading field.
      • modifyLeftPosition

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData modifyLeftPosition​(@NotNull
                                                         @NotNull Function<OptionalDouble,​OptionalDouble> function)
        Creates a copy of this TankDriveData with a modified left position.
        Parameters:
        function - A Function that takes this DriveData's current left position and returns a new position.
        Returns:
        A copy of this TankDriveData with all fields identical except for the left position field.
      • modifyLeftVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData modifyLeftVelocity​(@NotNull
                                                         @NotNull Function<OptionalDouble,​OptionalDouble> function)
        Creates a copy of this TankDriveData with a modified left velocity.
        Parameters:
        function - A Function that takes this DriveData's current left velocity and returns a new velocity.
        Returns:
        A copy of this TankDriveData with all fields identical except for the left velocity field.
      • modifyRightPosition

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData modifyRightPosition​(@NotNull
                                                          @NotNull Function<OptionalDouble,​OptionalDouble> function)
        Creates a copy of this TankDriveData with a modified right position.
        Parameters:
        function - A Function that takes this DriveData's current right position and returns a new position.
        Returns:
        A copy of this TankDriveData with all fields identical except for the right position field.
      • modifyRightVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData modifyRightVelocity​(@NotNull
                                                          @NotNull Function<OptionalDouble,​OptionalDouble> function)
        Creates a copy of this TankDriveData with a modified right velocity.
        Parameters:
        function - A Function that takes this DriveData's current right velocity and returns a new velocity.
        Returns:
        A copy of this TankDriveData with all fields identical except for the right velocity field.
      • plusHeading

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusHeading​(double heading)
        Adds the provided value to this TankDriveData's heading. If there is already a value present in heading, the returned TankDriveData's heading will be equal to the sum of that value plus the parameter; otherwise, the left heading will be equal to the value of the provided heading parameter.
        Parameters:
        heading - The heading to add.
        Returns:
        A new TankDriveData with all fields identical except for the left heading field.
      • plusTurningRate

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusTurningRate​(double turningRate)
        Adds the provided value to this TankDriveData's turningRate. If there is already a value present in turningRate, the returned TankDriveData's turningRate will be equal to the sum of that value plus the parameter; otherwise, the left turningRate will be equal to the value of the provided turningRate parameter.
        Parameters:
        turningRate - The turningRate to add.
        Returns:
        A new TankDriveData with all fields identical except for the left turningRate field.
      • plusLeftPosition

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusLeftPosition​(double position)
        Adds the provided value to this TankDriveData's left position. If there is already a value present in left.position, the returned TankDriveData's left position will be equal to the sum of that value plus the parameter; otherwise, the left position will be equal to the value of the provided position parameter.
        Parameters:
        position - The position to add.
        Returns:
        A new TankDriveData with all fields identical except for the left position field.
      • plusLeftVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusLeftVelocity​(double velocity)
        Adds the provided value to this TankDriveData's left velocity. If there is already a value present in left.velocity, the returned TankDriveData's left velocity will be equal to the sum of that value plus the parameter; otherwise, the left velocity will be equal to the value of the provided velocity parameter.
        Parameters:
        velocity - The velocity to add.
        Returns:
        A new TankDriveData with all fields identical except for the left velocity field.
      • plusLeftAcceleration

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusLeftAcceleration​(double acceleration)
        Adds the provided value to this TankDriveData's left acceleration. If there is already a value present in left.acceleration, the returned TankDriveData's left acceleration will be equal to the sum of that value plus the parameter; otherwise, the left acceleration will be equal to the value of the provided acceleration parameter.
        Parameters:
        acceleration - The acceleration to add.
        Returns:
        A new TankDriveData with all fields identical except for the left acceleration field.
      • plusLeftAdditionalFeedForward

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusLeftAdditionalFeedForward​(double additionalFeedForward)
        Adds the provided value to this TankDriveData's left additionalFeedForward. If there is already a value present in left.additionalFeedForward, the returned TankDriveData's left additionalFeedForward will be equal to the sum of that value plus the parameter; otherwise, the left additionalFeedForward will be equal to the value of the provided additionalFeedForward parameter.
        Parameters:
        additionalFeedForward - The additionalFeedForward to add.
        Returns:
        A new TankDriveData with all fields identical except for the left additionalFeedForward field.
      • plusRightPosition

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusRightPosition​(double position)
        Adds the provided value to this TankDriveData's right position. If there is already a value present in right.position, the returned TankDriveData's right position will be equal to the sum of that value plus the parameter; otherwise, the right position will be equal to the value of the provided position parameter.
        Parameters:
        position - The position to add.
        Returns:
        A new TankDriveData with all fields identical except for the right position field.
      • plusRightVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusRightVelocity​(double velocity)
        Adds the provided value to this TankDriveData's right velocity. If there is already a value present in right.velocity, the returned TankDriveData's right velocity will be equal to the sum of that value plus the parameter; otherwise, the right velocity will be equal to the value of the provided velocity parameter.
        Parameters:
        velocity - The velocity to add.
        Returns:
        A new TankDriveData with all fields identical except for the right velocity field.
      • plusRightAcceleration

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusRightAcceleration​(double acceleration)
        Adds the provided value to this TankDriveData's right acceleration. If there is already a value present in right.acceleration, the returned TankDriveData's right acceleration will be equal to the sum of that value plus the parameter; otherwise, the right acceleration will be equal to the value of the provided acceleration parameter.
        Parameters:
        acceleration - The acceleration to add.
        Returns:
        A new TankDriveData with all fields identical except for the right acceleration field.
      • plusRightAdditionalFeedForward

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData plusRightAdditionalFeedForward​(double additionalFeedForward)
        Adds the provided value to this TankDriveData's right additionalFeedForward. If there is already a value present in right.additionalFeedForward, the returned TankDriveData's right additionalFeedForward will be equal to the sum of that value plus the parameter; otherwise, the right additionalFeedForward will be equal to the value of the provided additionalFeedForward parameter.
        Parameters:
        additionalFeedForward - The additionalFeedForward to add.
        Returns:
        A new TankDriveData with all fields identical except for the right additionalFeedForward field.
      • plusPositions

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData plusPositions​(double leftPosition,
                                                    double rightPosition)
        Adds the provided values to this TankDriveData's left and right position. If there is already a value present in either position, the returned TankDriveData's positions will be equal to the sum of that value plus the parameter; otherwise, the position will be equal to the value of the provided parameter for each side.
        Parameters:
        leftPosition - The position to add to the left side.
        rightPosition - The position to add to the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right position fields.
      • plusVelocities

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData plusVelocities​(double leftVelocity,
                                                     double rightVelocity)
        Adds the provided values to this TankDriveData's left and right velocity. If there is already a value present in either velocity, the returned TankDriveData's velocities will be equal to the sum of that value plus the parameter; otherwise, the velocity will be equal to the value of the provided parameter for each side.
        Parameters:
        leftVelocity - The velocity to add to the left side.
        rightVelocity - The velocity to add to the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right velocity fields.
      • plusAccelerations

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData plusAccelerations​(double leftAcceleration,
                                                        double rightAcceleration)
        Adds the provided values to this TankDriveData's left and right acceleration. If there is already a value present in either acceleration, the returned TankDriveData's accelerations will be equal to the sum of that value plus the parameter; otherwise, the acceleration will be equal to the value of the provided parameter for each side.
        Parameters:
        leftAcceleration - The acceleration to add to the left side.
        rightAcceleration - The acceleration to add to the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right acceleration fields.
      • plusAdditionalFeedForwards

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData plusAdditionalFeedForwards​(double leftAdditionalFeedForward,
                                                                 double rightAdditionalFeedForward)
        Adds the provided values to this TankDriveData's left and right additionalFeedForward. If there is already a value present in either additionalFeedForward, the returned TankDriveData's additionalFeedForwards will be equal to the sum of that value plus the parameter; otherwise, the additionalFeedForward will be equal to the value of the provided parameter for each side.
        Parameters:
        leftAdditionalFeedForward - The additionalFeedForward to add to the left side.
        rightAdditionalFeedForward - The additionalFeedForward to add to the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right additionalFeedForward fields.
      • withHeading

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData withHeading​(double heading)
        Creates a copy of this TankDriveData and sets its heading. If there is already a value present in heading, it will be overwritten.
        Parameters:
        heading - The new heading.
        Returns:
        A TankDriveData with all fields identical except for heading.
      • withTurningRate

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull TankDriveData withTurningRate​(double turningRate)
        Creates a copy of this TankDriveData and sets its turningRate. If there is already a value present in turningRate, it will be overwritten.
        Parameters:
        turningRate - The new turningRate.
        Returns:
        A TankDriveData with all fields identical except for turningRate.
      • withPositions

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData withPositions​(double leftPosition,
                                                    double rightPosition)
        Creates a copy of this TankDriveData and sets its left and right positions. If there is already a value present in either position, it will be overwritten during copying.
        Parameters:
        leftPosition - The position to set on the left side.
        rightPosition - The position to set on the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right position fields.
      • withVelocities

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData withVelocities​(double leftVelocity,
                                                     double rightVelocity)
        Creates a copy of this TankDriveData and sets its left and right velocities. If there is already a value present in either velocity, it will be overwritten during copying.
        Parameters:
        leftVelocity - The velocity to set on the left side.
        rightVelocity - The velocity to set on the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right velocity fields.
      • withAccelerations

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData withAccelerations​(double leftAcceleration,
                                                        double rightAcceleration)
        Creates a copy of this TankDriveData and sets its left and right accelerations. If there is already a value present in either acceleration, it will be overwritten during copying.
        Parameters:
        leftAcceleration - The acceleration to set on the left side.
        rightAcceleration - The acceleration to set on the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right acceleration fields.
      • withAdditionalFeedForwards

        @NotNull
        @Contract(value="_, _ -> new",
                  pure=true)
        public @NotNull TankDriveData withAdditionalFeedForwards​(double leftAdditionalFeedForward,
                                                                 double rightAdditionalFeedForward)
        Creates a copy of this TankDriveData and sets its left and right additionalFeedForwards. If there is already a value present in either additionalFeedForward, it will be overwritten during copying.
        Parameters:
        leftAdditionalFeedForward - The additionalFeedForward to set on the left side.
        rightAdditionalFeedForward - The additionalFeedForward to set on the right side.
        Returns:
        A new TankDriveData with all fields identical except for the left and right additionalFeedForward fields.
      • equals

        @Contract(value="null -> false",
                  pure=true)
        public boolean equals​(Object o)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object