Class DriveData

    • Field Detail

      • position

        @NotNull
        public final @NotNull OptionalDouble position
        The desired position in position-units, or an empty optional if velocity should not be controlled.
      • velocity

        @NotNull
        public final @NotNull OptionalDouble velocity
        The desired velocity in position-units per second, or an empty optional if velocity should not be controlled.
      • acceleration

        @NotNull
        public final @NotNull OptionalDouble acceleration
        The desired acceleration in position-units per second squared, or an empty optional if acceleration should not be controlled.
      • additionalFeedForward

        @NotNull
        public final @NotNull OptionalDouble additionalFeedForward
        An additional raw amount (from -1 to 1 inclusive) that should be added to motor throttle after any closed-loop logic, or an empty optional if no feed-forward should be added.
    • Constructor Detail

      • DriveData

        public DriveData()
        Create a new DriveData with all fields empty.
      • DriveData

        public DriveData​(@NotNull
                         @NotNull OptionalDouble velocity)
        Create a new DriveData with all fields empty except for the provided velocity.
        Parameters:
        velocity - The desired velocity in position-units per second, or an empty optional if velocity should not be controlled.
      • DriveData

        public DriveData​(@NotNull
                         @NotNull OptionalDouble position,
                         @NotNull
                         @NotNull OptionalDouble velocity,
                         @NotNull
                         @NotNull OptionalDouble acceleration,
                         @NotNull
                         @NotNull OptionalDouble additionalFeedForward)
        Create a new DriveData with the supplied values.
        Parameters:
        position - The desired position in position-units, or an empty optional if velocity should not be controlled.
        velocity - The desired velocity in position-units per second, or an empty optional if velocity should not be controlled.
        acceleration - The desired acceleration in position-units per second squared, or an empty optional if acceleration should not be controlled.
        additionalFeedForward - An additional raw amount (from -1 to 1 inclusive) that should be added to motor throttle after any closed-loop logic, or an empty optional if no feed-forward should be added.
    • Method Detail

      • withPosition

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData withPosition​(double position)
        Creates a copy of this DriveData with a different position value (all other fields remain the same).
        Parameters:
        position - The new value for position.
        Returns:
        A new DriveData as described above.
      • withVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData withVelocity​(double velocity)
        Creates a copy of this DriveData with a different velocity value (all other fields remain the same).
        Parameters:
        velocity - The new value for velocity.
        Returns:
        A new DriveData as described above.
      • withAcceleration

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData withAcceleration​(double acceleration)
        Creates a copy of this DriveData with a different acceleration value (all other fields remain the same).
        Parameters:
        acceleration - The new value for acceleration.
        Returns:
        A new DriveData as described above.
      • withAdditionalFeedForward

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData withAdditionalFeedForward​(double additionalFeedForward)
        Creates a copy of this DriveData with a different additionalFeedForward value (all other fields remain the same).
        Parameters:
        additionalFeedForward - The new value for additionalFeedForward.
        Returns:
        A new DriveData as described above.
      • modifyPosition

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

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

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData plusPosition​(double position)
        Adds the provided value to this DriveData's position. If there is already a value present in position, the returned DriveData's position will be equal to the sum of that value plus the parameter; otherwise, the position will be equal to the value of the provided position parameter.
        Parameters:
        position - The position value to add.
        Returns:
        A new DriveData as described above.
      • plusVelocity

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData plusVelocity​(double velocity)
        Adds the provided value to this DriveData's velocity. If there is already a value present in velocity, the returned DriveData's velocity will be equal to the sum of that value plus the parameter; otherwise, the velocity will be equal to the value of the provided velocity parameter.
        Parameters:
        velocity - The velocity value to add.
        Returns:
        A new DriveData as described above.
      • plusAcceleration

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData plusAcceleration​(double acceleration)
        Adds the provided value to this DriveData's acceleration. If there is already a value present in acceleration, the returned DriveData's acceleration will be equal to the sum of that value plus the parameter; otherwise, the acceleration will be equal to the value of the provided acceleration parameter.
        Parameters:
        acceleration - The acceleration value to add.
        Returns:
        A new DriveData as described above.
      • plusAdditionalFeedForward

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public @NotNull DriveData plusAdditionalFeedForward​(double additionalFeedForward)
        Adds the provided value to this DriveData's additionalFeedForward. If there is already a value present in additionalFeedForward, the returned DriveData's additionalFeedForward will be equal to the sum of that value plus the parameter; otherwise, the additionalFeedForward will be equal to the value of the provided additionalFeedForward parameter.
        Parameters:
        additionalFeedForward - The additionalFeedForward value to add.
        Returns:
        A new DriveData as described above.
      • 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