Class DriveData
- java.lang.Object
-
- org.team1540.rooster.drive.pipeline.DriveData
-
public class DriveData extends Object
Encapsulates data for one side of a tank drivetrain.DriveData
instances are typically passed around as members ofTankDriveData
instances in drive pipelines. EachDriveData
instance contains values (or emptyOptionalDoubles
) for position, velocity, acceleration, and feed-forward.- See Also:
TankDriveData
-
-
Field Summary
Fields Modifier and Type Field Description @NotNull OptionalDouble
acceleration
The desired acceleration in position-units per second squared, or an empty optional if acceleration should not be controlled.@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.@NotNull OptionalDouble
position
The desired position in position-units, or an empty optional if velocity should not be controlled.@NotNull OptionalDouble
velocity
The desired velocity in position-units per second, or an empty optional if velocity should not be controlled.
-
Constructor Summary
Constructors Constructor Description DriveData()
Create a newDriveData
with all fields empty.DriveData(@NotNull OptionalDouble velocity)
Create a newDriveData
with all fields empty except for the provided velocity.DriveData(@NotNull OptionalDouble position, @NotNull OptionalDouble velocity, @NotNull OptionalDouble acceleration, @NotNull OptionalDouble additionalFeedForward)
Create a newDriveData
with the supplied values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int
hashCode()
@NotNull DriveData
modifyAcceleration(@NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedacceleration
.@NotNull DriveData
modifyAdditionalFeedForward(@NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedadditionalFeedForward
.@NotNull DriveData
modifyPosition(@NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedposition
.@NotNull DriveData
modifyVelocity(@NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedvelocity
.@NotNull DriveData
plusAcceleration(double acceleration)
Adds the provided value to thisDriveData
'sacceleration
.@NotNull DriveData
plusAdditionalFeedForward(double additionalFeedForward)
Adds the provided value to thisDriveData
'sadditionalFeedForward
.@NotNull DriveData
plusPosition(double position)
Adds the provided value to thisDriveData
'sposition
.@NotNull DriveData
plusVelocity(double velocity)
Adds the provided value to thisDriveData
'svelocity
.String
toString()
@NotNull DriveData
withAcceleration(double acceleration)
Creates a copy of thisDriveData
with a differentacceleration
value (all other fields remain the same).@NotNull DriveData
withAdditionalFeedForward(double additionalFeedForward)
Creates a copy of thisDriveData
with a differentadditionalFeedForward
value (all other fields remain the same).@NotNull DriveData
withPosition(double position)
Creates a copy of thisDriveData
with a differentposition
value (all other fields remain the same).@NotNull DriveData
withVelocity(double velocity)
Creates a copy of thisDriveData
with a differentvelocity
value (all other fields remain the same).
-
-
-
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 newDriveData
with all fields empty.
-
DriveData
public DriveData(@NotNull @NotNull OptionalDouble velocity)
Create a newDriveData
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 newDriveData
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 thisDriveData
with a differentposition
value (all other fields remain the same).- Parameters:
position
- The new value forposition
.- Returns:
- A new
DriveData
as described above.
-
withVelocity
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withVelocity(double velocity)
Creates a copy of thisDriveData
with a differentvelocity
value (all other fields remain the same).- Parameters:
velocity
- The new value forvelocity
.- Returns:
- A new
DriveData
as described above.
-
withAcceleration
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withAcceleration(double acceleration)
Creates a copy of thisDriveData
with a differentacceleration
value (all other fields remain the same).- Parameters:
acceleration
- The new value foracceleration
.- Returns:
- A new
DriveData
as described above.
-
withAdditionalFeedForward
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withAdditionalFeedForward(double additionalFeedForward)
Creates a copy of thisDriveData
with a differentadditionalFeedForward
value (all other fields remain the same).- Parameters:
additionalFeedForward
- The new value foradditionalFeedForward
.- 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 thisDriveData
with a modifiedposition
.
-
modifyVelocity
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyVelocity(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedvelocity
.
-
modifyAcceleration
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyAcceleration(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedacceleration
.- Parameters:
function
- AFunction
that takes thisDriveData
's currentacceleration
and returns a newacceleration
.- Returns:
- A copy of this
DriveData
with all fields identical except for theacceleration
field.
-
modifyAdditionalFeedForward
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyAdditionalFeedForward(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)
Creates a copy of thisDriveData
with a modifiedadditionalFeedForward
.- Parameters:
function
- AFunction
that takes thisDriveData
's currentadditionalFeedForward
and returns a newadditionalFeedForward
.- Returns:
- A copy of this
DriveData
with all fields identical except for theadditionalFeedForward
field.
-
plusPosition
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData plusPosition(double position)
Adds the provided value to thisDriveData
'sposition
. If there is already a value present inposition
, the returnedDriveData
'sposition
will be equal to the sum of that value plus the parameter; otherwise, theposition
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 thisDriveData
'svelocity
. If there is already a value present invelocity
, the returnedDriveData
'svelocity
will be equal to the sum of that value plus the parameter; otherwise, thevelocity
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 thisDriveData
'sacceleration
. If there is already a value present inacceleration
, the returnedDriveData
'sacceleration
will be equal to the sum of that value plus the parameter; otherwise, theacceleration
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 thisDriveData
'sadditionalFeedForward
. If there is already a value present inadditionalFeedForward
, the returnedDriveData
'sadditionalFeedForward
will be equal to the sum of that value plus the parameter; otherwise, theadditionalFeedForward
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)
-
-