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.DriveDatainstances are typically passed around as members ofTankDriveDatainstances in drive pipelines. EachDriveDatainstance contains values (or emptyOptionalDoubles) for position, velocity, acceleration, and feed-forward.- See Also:
TankDriveData
-
-
Field Summary
Fields Modifier and Type Field Description @NotNull OptionalDoubleaccelerationThe desired acceleration in position-units per second squared, or an empty optional if acceleration should not be controlled.@NotNull OptionalDoubleadditionalFeedForwardAn 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 OptionalDoublepositionThe desired position in position-units, or an empty optional if velocity should not be controlled.@NotNull OptionalDoublevelocityThe 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 newDriveDatawith all fields empty.DriveData(@NotNull OptionalDouble velocity)Create a newDriveDatawith all fields empty except for the provided velocity.DriveData(@NotNull OptionalDouble position, @NotNull OptionalDouble velocity, @NotNull OptionalDouble acceleration, @NotNull OptionalDouble additionalFeedForward)Create a newDriveDatawith the supplied values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)inthashCode()@NotNull DriveDatamodifyAcceleration(@NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedacceleration.@NotNull DriveDatamodifyAdditionalFeedForward(@NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedadditionalFeedForward.@NotNull DriveDatamodifyPosition(@NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedposition.@NotNull DriveDatamodifyVelocity(@NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedvelocity.@NotNull DriveDataplusAcceleration(double acceleration)Adds the provided value to thisDriveData'sacceleration.@NotNull DriveDataplusAdditionalFeedForward(double additionalFeedForward)Adds the provided value to thisDriveData'sadditionalFeedForward.@NotNull DriveDataplusPosition(double position)Adds the provided value to thisDriveData'sposition.@NotNull DriveDataplusVelocity(double velocity)Adds the provided value to thisDriveData'svelocity.StringtoString()@NotNull DriveDatawithAcceleration(double acceleration)Creates a copy of thisDriveDatawith a differentaccelerationvalue (all other fields remain the same).@NotNull DriveDatawithAdditionalFeedForward(double additionalFeedForward)Creates a copy of thisDriveDatawith a differentadditionalFeedForwardvalue (all other fields remain the same).@NotNull DriveDatawithPosition(double position)Creates a copy of thisDriveDatawith a differentpositionvalue (all other fields remain the same).@NotNull DriveDatawithVelocity(double velocity)Creates a copy of thisDriveDatawith a differentvelocityvalue (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 newDriveDatawith all fields empty.
-
DriveData
public DriveData(@NotNull @NotNull OptionalDouble velocity)Create a newDriveDatawith 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 newDriveDatawith 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 thisDriveDatawith a differentpositionvalue (all other fields remain the same).- Parameters:
position- The new value forposition.- Returns:
- A new
DriveDataas described above.
-
withVelocity
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withVelocity(double velocity)Creates a copy of thisDriveDatawith a differentvelocityvalue (all other fields remain the same).- Parameters:
velocity- The new value forvelocity.- Returns:
- A new
DriveDataas described above.
-
withAcceleration
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withAcceleration(double acceleration)Creates a copy of thisDriveDatawith a differentaccelerationvalue (all other fields remain the same).- Parameters:
acceleration- The new value foracceleration.- Returns:
- A new
DriveDataas described above.
-
withAdditionalFeedForward
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData withAdditionalFeedForward(double additionalFeedForward)Creates a copy of thisDriveDatawith a differentadditionalFeedForwardvalue (all other fields remain the same).- Parameters:
additionalFeedForward- The new value foradditionalFeedForward.- Returns:
- A new
DriveDataas described above.
-
modifyPosition
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyPosition(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedposition.
-
modifyVelocity
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyVelocity(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedvelocity.
-
modifyAcceleration
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyAcceleration(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedacceleration.- Parameters:
function- AFunctionthat takes thisDriveData's currentaccelerationand returns a newacceleration.- Returns:
- A copy of this
DriveDatawith all fields identical except for theaccelerationfield.
-
modifyAdditionalFeedForward
@NotNull @Contract(value="_ -> new", pure=true) public @NotNull DriveData modifyAdditionalFeedForward(@NotNull @NotNull Function<OptionalDouble,OptionalDouble> function)Creates a copy of thisDriveDatawith a modifiedadditionalFeedForward.- Parameters:
function- AFunctionthat takes thisDriveData's currentadditionalFeedForwardand returns a newadditionalFeedForward.- Returns:
- A copy of this
DriveDatawith all fields identical except for theadditionalFeedForwardfield.
-
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'spositionwill be equal to the sum of that value plus the parameter; otherwise, thepositionwill be equal to the value of the provided position parameter.- Parameters:
position- The position value to add.- Returns:
- A new
DriveDataas 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'svelocitywill be equal to the sum of that value plus the parameter; otherwise, thevelocitywill be equal to the value of the provided velocity parameter.- Parameters:
velocity- The velocity value to add.- Returns:
- A new
DriveDataas 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'saccelerationwill be equal to the sum of that value plus the parameter; otherwise, theaccelerationwill be equal to the value of the provided acceleration parameter.- Parameters:
acceleration- The acceleration value to add.- Returns:
- A new
DriveDataas 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'sadditionalFeedForwardwill be equal to the sum of that value plus the parameter; otherwise, theadditionalFeedForwardwill be equal to the value of the provided additionalFeedForward parameter.- Parameters:
additionalFeedForward- The additionalFeedForward value to add.- Returns:
- A new
DriveDataas described above.
-
equals
@Contract(value="null -> false", pure=true) public boolean equals(Object o)
-
-