mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpimath] Java: add static instantiations of common rotations (#6563)
C++ doesn't need this because it supports value types, which are much cheaper to construct. constexpr is also available to make construction zero-cost.
This commit is contained in:
@@ -181,7 +181,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
|
||||
* positive.
|
||||
*/
|
||||
public void driveCartesian(double xSpeed, double ySpeed, double zRotation) {
|
||||
driveCartesian(xSpeed, ySpeed, zRotation, new Rotation2d());
|
||||
driveCartesian(xSpeed, ySpeed, zRotation, Rotation2d.kZero);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +240,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
|
||||
}
|
||||
|
||||
driveCartesian(
|
||||
magnitude * angle.getCos(), magnitude * angle.getSin(), zRotation, new Rotation2d());
|
||||
magnitude * angle.getCos(), magnitude * angle.getSin(), zRotation, Rotation2d.kZero);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
|
||||
* @return Wheel speeds [-1.0..1.0].
|
||||
*/
|
||||
public static WheelSpeeds driveCartesianIK(double xSpeed, double ySpeed, double zRotation) {
|
||||
return driveCartesianIK(xSpeed, ySpeed, zRotation, new Rotation2d());
|
||||
return driveCartesianIK(xSpeed, ySpeed, zRotation, Rotation2d.kZero);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Field2d implements NTSendable, AutoCloseable {
|
||||
@SuppressWarnings("this-escape")
|
||||
public Field2d() {
|
||||
FieldObject2d obj = new FieldObject2d("Robot");
|
||||
obj.setPose(new Pose2d());
|
||||
obj.setPose(Pose2d.kZero);
|
||||
m_objects.add(obj);
|
||||
SendableRegistry.add(this, "Field");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class FieldObject2d implements AutoCloseable {
|
||||
public synchronized Pose2d getPose() {
|
||||
updateFromEntry();
|
||||
if (m_poses.isEmpty()) {
|
||||
return new Pose2d();
|
||||
return Pose2d.kZero;
|
||||
}
|
||||
return m_poses.get(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user