[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

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -7,9 +7,9 @@
#include "subsystems/DriveTrain.h"
#include <cmath>
#include <frc/Joystick.h>
#include <units/length.h>
#include <wpi/math>
#include "commands/DriveWithJoystick.h"
@@ -36,11 +36,11 @@ DriveTrain::DriveTrain() : frc::Subsystem("DriveTrain") {
m_rightEncoder.SetDistancePerPulse(0.0785398);
m_leftEncoder.SetDistancePerPulse(0.0785398);
#else
// Convert to feet 4in diameter wheels with 360 tick simulated encoders
m_rightEncoder.SetDistancePerPulse((4.0 /*in*/ * M_PI) /
(360.0 * 12.0 /*in/ft*/));
m_leftEncoder.SetDistancePerPulse((4.0 /*in*/ * M_PI) /
(360.0 * 12.0 /*in/ft*/));
// Circumference = diameter * pi. 360 tick simulated encoders.
m_rightEncoder.SetDistancePerPulse(units::foot_t{4_in}.to<double>() *
wpi::math::pi / 360.0);
m_leftEncoder.SetDistancePerPulse(units::foot_t{4_in}.to<double>() *
wpi::math::pi / 360.0);
#endif
AddChild("Right Encoder", m_rightEncoder);