mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] ChassisSpeeds: add equals method (#6414)
This commit is contained in:
@@ -21,6 +21,7 @@ import edu.wpi.first.units.Time;
|
||||
import edu.wpi.first.units.Velocity;
|
||||
import edu.wpi.first.util.protobuf.ProtobufSerializable;
|
||||
import edu.wpi.first.util.struct.StructSerializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents the speed of a robot chassis. Although this class contains similar members compared to
|
||||
@@ -383,6 +384,28 @@ public class ChassisSpeeds implements ProtobufSerializable, StructSerializable {
|
||||
vxMetersPerSecond / scalar, vyMetersPerSecond / scalar, omegaRadiansPerSecond / scalar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return Objects.hash(vxMetersPerSecond, vyMetersPerSecond, omegaRadiansPerSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof ChassisSpeeds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ChassisSpeeds c = (ChassisSpeeds) o;
|
||||
|
||||
return vxMetersPerSecond == c.vxMetersPerSecond
|
||||
&& vyMetersPerSecond == c.vyMetersPerSecond
|
||||
&& omegaRadiansPerSecond == c.omegaRadiansPerSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
Reference in New Issue
Block a user