mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilib] Add X and Y component getters to Pose2d and Transform2d (#2563)
pose.Translation().X() and pose.Translation.Y() are common operations, so shortening them to pose.X() and pose.Y() would be convenient. Java uses the getX() convention so that is used instead of X() for Java.
This commit is contained in:
@@ -54,8 +54,8 @@ ChassisSpeeds RamseteController::Calculate(
|
||||
m_poseError = poseRef.RelativeTo(currentPose);
|
||||
|
||||
// Aliases for equation readability
|
||||
double eX = m_poseError.Translation().X().to<double>();
|
||||
double eY = m_poseError.Translation().Y().to<double>();
|
||||
double eX = m_poseError.X().to<double>();
|
||||
double eY = m_poseError.Y().to<double>();
|
||||
double eTheta = m_poseError.Rotation().Radians().to<double>();
|
||||
double vRef = linearVelocityRef.to<double>();
|
||||
double omegaRef = angularVelocityRef.to<double>();
|
||||
|
||||
@@ -48,9 +48,9 @@ bool EllipticalRegionConstraint::IsPoseInRegion(const Pose2d& pose) const {
|
||||
// If the inequality is satisfied, then it is inside the ellipse; otherwise
|
||||
// it is outside the ellipse.
|
||||
// Both sides have been multiplied by Rx^2 * Ry^2 for efficiency reasons.
|
||||
return units::math::pow<2>(pose.Translation().X() - m_center.X()) *
|
||||
return units::math::pow<2>(pose.X() - m_center.X()) *
|
||||
units::math::pow<2>(m_radii.Y()) +
|
||||
units::math::pow<2>(pose.Translation().Y() - m_center.Y()) *
|
||||
units::math::pow<2>(pose.Y() - m_center.Y()) *
|
||||
units::math::pow<2>(m_radii.X()) <=
|
||||
units::math::pow<2>(m_radii.X()) * units::math::pow<2>(m_radii.Y());
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ TrajectoryConstraint::MinMax RectangularRegionConstraint::MinMaxAcceleration(
|
||||
}
|
||||
|
||||
bool RectangularRegionConstraint::IsPoseInRegion(const Pose2d& pose) const {
|
||||
return pose.Translation().X() >= m_bottomLeftPoint.X() &&
|
||||
pose.Translation().X() <= m_topRightPoint.X() &&
|
||||
pose.Translation().Y() >= m_bottomLeftPoint.Y() &&
|
||||
pose.Translation().Y() <= m_topRightPoint.Y();
|
||||
return pose.X() >= m_bottomLeftPoint.X() && pose.X() <= m_topRightPoint.X() &&
|
||||
pose.Y() >= m_bottomLeftPoint.Y() && pose.Y() <= m_topRightPoint.Y();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user