mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Replace M_PI with wpi::math::pi (#2938)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user