[examples] Replace M_PI with wpi::math::pi (#2938)

This commit is contained in:
Tyler Veness
2020-12-17 00:15:02 -08:00
committed by GitHub
parent b27d33675d
commit 4afb13f98b
4 changed files with 18 additions and 16 deletions

View File

@@ -9,6 +9,8 @@
#include <frc/Joystick.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <units/length.h>
#include <wpi/math>
DriveTrain::DriveTrain() {
// Encoders may measure differently in the real world and in
@@ -20,11 +22,11 @@ DriveTrain::DriveTrain() {
m_leftEncoder.SetDistancePerPulse(0.042);
m_rightEncoder.SetDistancePerPulse(0.042);
#else
// Circumference in ft = 4in/12(in/ft)*PI
m_leftEncoder.SetDistancePerPulse(static_cast<double>(4.0 / 12.0 * M_PI) /
360.0);
m_rightEncoder.SetDistancePerPulse(static_cast<double>(4.0 / 12.0 * M_PI) /
360.0);
// Circumference = diameter * pi. 360 tick simulated encoders.
m_leftEncoder.SetDistancePerPulse(units::foot_t{4_in}.to<double>() *
wpi::math::pi / 360.0);
m_rightEncoder.SetDistancePerPulse(units::foot_t{4_in}.to<double>() *
wpi::math::pi / 360.0);
#endif
SetName("DriveTrain");
// Let's show everything on the LiveWindow