diff --git a/wpilibcExamples/.styleguide b/wpilibcExamples/.styleguide index d9369fac39..a6925d1a9f 100644 --- a/wpilibcExamples/.styleguide +++ b/wpilibcExamples/.styleguide @@ -18,6 +18,7 @@ includeOtherLibs { ^ntcore ^opencv2/ ^support/ + ^units/ ^vision/ ^wpi/ } diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h index 748558478e..151404a993 100644 --- a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h +++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h @@ -7,8 +7,6 @@ #pragma once -#include - #include #include #include @@ -16,6 +14,7 @@ #include #include #include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp index 95aac42f9a..8479867381 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp @@ -5,20 +5,22 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include - #include #include #include #include #include #include +#include +#include class Robot : public frc::TimedRobot { public: static constexpr units::second_t kDt = 20_ms; - Robot() { m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); } + Robot() { + m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * wpi::math::pi * 1.5); + } void TeleopPeriodic() override { if (m_joystick.GetRawButtonPressed(2)) { diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp index 9a15f316ce..d88331ab04 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp @@ -11,12 +11,15 @@ #include #include #include +#include class Robot : public frc::TimedRobot { public: static constexpr units::second_t kDt = 20_ms; - Robot() { m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); } + Robot() { + m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * wpi::math::pi * 1.5); + } void TeleopPeriodic() override { if (m_joystick.GetRawButtonPressed(2)) { diff --git a/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp index 1dbbfa5409..3cfffd7442 100644 --- a/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2017-2019 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. */ @@ -8,6 +8,7 @@ #include #include #include +#include /** * Sample program displaying the value of a quadrature encoder on the @@ -42,7 +43,7 @@ class Robot : public frc::TimedRobot { * inch diameter (1.5inch radius) wheel, and that we want to measure * distance in inches. */ - m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); + m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * wpi::math::pi * 1.5); /* Defines the lowest rate at which the encoder will not be considered * stopped, for the purposes of the GetStopped() method. Units are in diff --git a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h index f9f07f4460..90fb772c8f 100644 --- a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h @@ -8,6 +8,7 @@ #pragma once #include +#include /** * The Constants header provides a convenient place for teams to hold robot-wide @@ -33,7 +34,7 @@ constexpr int kEncoderCPR = 1024; constexpr double kWheelDiameterInches = 6; constexpr double kEncoderDistancePerPulse = // Assumes the encoders are directly mounted on the wheel shafts - (kWheelDiameterInches * 3.142) / static_cast(kEncoderCPR); + (kWheelDiameterInches * wpi::math::pi) / static_cast(kEncoderCPR); } // namespace DriveConstants namespace ShooterConstants { diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h index 59daf0ee69..bfce2adee0 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h @@ -7,6 +7,8 @@ #pragma once +#include + /** * The Constants header provides a convenient place for teams to hold robot-wide * numerical or bool constants. This should not be used for any other purpose. @@ -31,7 +33,7 @@ constexpr int kEncoderCPR = 1024; constexpr double kWheelDiameterInches = 6; constexpr double kEncoderDistancePerPulse = // Assumes the encoders are directly mounted on the wheel shafts - (kWheelDiameterInches * 3.142) / static_cast(kEncoderCPR); + (kWheelDiameterInches * wpi::math::pi) / static_cast(kEncoderCPR); constexpr bool kGyroReversed = true; diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Constants.h index a8ec7f3024..29c4413408 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Constants.h @@ -7,6 +7,8 @@ #pragma once +#include + /** * The Constants header provides a convenient place for teams to hold robot-wide * numerical or bool constants. This should not be used for any other purpose. @@ -31,7 +33,7 @@ constexpr int kEncoderCPR = 1024; constexpr double kWheelDiameterInches = 6; constexpr double kEncoderDistancePerPulse = // Assumes the encoders are directly mounted on the wheel shafts - (kWheelDiameterInches * 3.142) / static_cast(kEncoderCPR); + (kWheelDiameterInches * wpi::math::pi) / static_cast(kEncoderCPR); } // namespace DriveConstants namespace HatchConstants { diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Constants.h index a8ec7f3024..29c4413408 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Constants.h @@ -7,6 +7,8 @@ #pragma once +#include + /** * The Constants header provides a convenient place for teams to hold robot-wide * numerical or bool constants. This should not be used for any other purpose. @@ -31,7 +33,7 @@ constexpr int kEncoderCPR = 1024; constexpr double kWheelDiameterInches = 6; constexpr double kEncoderDistancePerPulse = // Assumes the encoders are directly mounted on the wheel shafts - (kWheelDiameterInches * 3.142) / static_cast(kEncoderCPR); + (kWheelDiameterInches * wpi::math::pi) / static_cast(kEncoderCPR); } // namespace DriveConstants namespace HatchConstants { diff --git a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h index f88aea0781..863af2a87c 100644 --- a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h @@ -5,10 +5,10 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include - #include #include +#include +#include #pragma once @@ -39,7 +39,7 @@ constexpr int kEncoderCPR = 1024; constexpr double kWheelDiameterInches = 6; constexpr double kEncoderDistancePerPulse = // Assumes the encoders are directly mounted on the wheel shafts - (kWheelDiameterInches * 3.142) / static_cast(kEncoderCPR); + (kWheelDiameterInches * wpi::math::pi) / static_cast(kEncoderCPR); constexpr bool kGyroReversed = true; diff --git a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h index 86247d40a8..8eb5b8617b 100644 --- a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h @@ -7,8 +7,6 @@ #pragma once -#include - #include #include #include @@ -17,6 +15,7 @@ #include #include #include +#include #include "Constants.h" diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java index a48909f453..8ea1ed1167 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java @@ -30,7 +30,7 @@ public class Robot extends TimedRobot { @Override public void robotInit() { - m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); + m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * Math.PI * 1.5); } @Override diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java index fddd4176ed..15f56b9ef3 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java @@ -29,7 +29,7 @@ public class Robot extends TimedRobot { @Override public void robotInit() { - m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); + m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * Math.PI * 1.5); } @Override diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java index 4bb26ea112..ef34fe594a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/encoder/Robot.java @@ -54,7 +54,7 @@ public class Robot extends TimedRobot { * attached to a 3 inch diameter (1.5inch radius) wheel, * and that we want to measure distance in inches. */ - m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * 3.1415 * 1.5); + m_encoder.setDistancePerPulse(1.0 / 360.0 * 2.0 * Math.PI * 1.5); /* * Defines the lowest rate at which the encoder will