diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt index 61ad9a75e0..7dbe1c91da 100644 --- a/ThirdPartyNotices.txt +++ b/ThirdPartyNotices.txt @@ -36,7 +36,7 @@ CoreUI wpiutil/src/main/native/resources/coreui-* Feather Icons wpiutil/src/main/native/resources/feather-* jQuery wpiutil/src/main/native/resources/jquery-* popper.js wpiutil/src/main/native/resources/popper-* -units wpiutil/src/main/native/include/units/units.h +units wpiutil/src/main/native/include/units/ Eigen wpiutil/src/main/native/eigeninclude/ StackWalker wpiutil/src/main/native/windows/StackWalker.* Team 254 Library wpilibj/src/main/java/edu/wpi/first/wpilibj/spline/SplineParameterizer.java diff --git a/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp b/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp index 4f4cf31821..c5089b4b0e 100644 --- a/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp @@ -16,7 +16,8 @@ #define IMGUI_DEFINE_MATH_OPERATORS #include #include -#include +#include +#include #include #include #include diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index e50f09e054..060832c1e5 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index e489e5a0c0..471169566c 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/MecanumControllerCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/MecanumControllerCommand.h index f667e5fa57..baae261411 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/MecanumControllerCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/MecanumControllerCommand.h @@ -18,7 +18,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #include "CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/NotifierCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/NotifierCommand.h index 59af028ff0..1c6d7767d4 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/NotifierCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/NotifierCommand.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "frc2/command/CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h index fbc4f6d2a3..5bc497838a 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "frc2/command/CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h index 919ed18dcf..2bbe14932f 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include "frc2/command/SubsystemBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h index 580bc574af..21d5cfdfa8 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h @@ -17,7 +17,8 @@ #include #include #include -#include +#include +#include #include #include "frc2/Timer.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.h index 38ca60cd3e..30a8d337d5 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.h @@ -17,7 +17,9 @@ #include #include #include -#include +#include +#include +#include #include #include "CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h index c5d7e359b2..08336f17d4 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include "frc2/command/SubsystemBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h index ab97958acc..568db65ec9 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include #include "frc2/Timer.h" #include "frc2/command/CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h index 50b4855f6f..741d3eb83b 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,7 +9,7 @@ #include -#include +#include #include "frc2/command/CommandBase.h" #include "frc2/command/CommandHelper.h" diff --git a/wpilibc/src/main/native/cpp/controller/RamseteController.cpp b/wpilibc/src/main/native/cpp/controller/RamseteController.cpp index 0302d187d2..466429e86a 100644 --- a/wpilibc/src/main/native/cpp/controller/RamseteController.cpp +++ b/wpilibc/src/main/native/cpp/controller/RamseteController.cpp @@ -9,6 +9,8 @@ #include +#include + using namespace frc; /** diff --git a/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp b/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp index a3c4bea932..29dfe624f2 100644 --- a/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp +++ b/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,6 +9,7 @@ #include +#include #include using namespace frc; diff --git a/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp b/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp index c3db7e3a69..cc59a3fce0 100644 --- a/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp +++ b/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,6 +7,7 @@ #include "frc/geometry/Translation2d.h" +#include #include using namespace frc; diff --git a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp b/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp index 5b13f0ecad..60b8e7a22d 100644 --- a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp +++ b/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,6 +7,8 @@ #include "frc/kinematics/DifferentialDriveWheelSpeeds.h" +#include + using namespace frc; void DifferentialDriveWheelSpeeds::Normalize( diff --git a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp b/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp index 1641ba87ef..776f4efa78 100644 --- a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp +++ b/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,6 +11,8 @@ #include #include +#include + using namespace frc; void MecanumDriveWheelSpeeds::Normalize( diff --git a/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp b/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp index d1f45eb9b8..060996ece9 100644 --- a/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp @@ -7,6 +7,7 @@ #include "frc/trajectory/Trajectory.h" +#include #include using namespace frc; diff --git a/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp b/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp index 976b4e26e6..26d1146f6e 100644 --- a/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp @@ -33,6 +33,8 @@ #include +#include + using namespace frc; Trajectory TrajectoryParameterizer::TimeParameterizeTrajectory( diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp index b43a54779d..eb42cc19e7 100644 --- a/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp @@ -7,6 +7,8 @@ #include "frc/trajectory/constraint/CentripetalAccelerationConstraint.h" +#include + using namespace frc; CentripetalAccelerationConstraint::CentripetalAccelerationConstraint( diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp index 652577d4bf..17b3b31ac3 100644 --- a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp @@ -10,6 +10,7 @@ #include #include +#include #include using namespace frc; diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/EllipticalRegionConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/EllipticalRegionConstraint.cpp index 52d0074a02..3d71073137 100644 --- a/wpilibc/src/main/native/cpp/trajectory/constraint/EllipticalRegionConstraint.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/constraint/EllipticalRegionConstraint.cpp @@ -9,6 +9,8 @@ #include +#include + using namespace frc; EllipticalRegionConstraint::EllipticalRegionConstraint( diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp index 5b8a3a13bb..07eed8cc0f 100644 --- a/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp +++ b/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp @@ -7,6 +7,8 @@ #include "frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h" +#include + using namespace frc; MecanumDriveKinematicsConstraint::MecanumDriveKinematicsConstraint( diff --git a/wpilibc/src/main/native/include/frc/AddressableLED.h b/wpilibc/src/main/native/include/frc/AddressableLED.h index 1d95ec5920..3154f9ef49 100644 --- a/wpilibc/src/main/native/include/frc/AddressableLED.h +++ b/wpilibc/src/main/native/include/frc/AddressableLED.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "frc/ErrorBase.h" diff --git a/wpilibc/src/main/native/include/frc/AnalogEncoder.h b/wpilibc/src/main/native/include/frc/AnalogEncoder.h index 872db87f8a..efe28c554e 100644 --- a/wpilibc/src/main/native/include/frc/AnalogEncoder.h +++ b/wpilibc/src/main/native/include/frc/AnalogEncoder.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,7 @@ #include #include -#include +#include #include "frc/AnalogTrigger.h" #include "frc/Counter.h" diff --git a/wpilibc/src/main/native/include/frc/DMASample.h b/wpilibc/src/main/native/include/frc/DMASample.h index 4592930ed7..c286c8d8be 100644 --- a/wpilibc/src/main/native/include/frc/DMASample.h +++ b/wpilibc/src/main/native/include/frc/DMASample.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,7 @@ #include #include -#include +#include #include "frc/AnalogInput.h" #include "frc/Counter.h" diff --git a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h index 847cd8568d..73db9bb99d 100644 --- a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h +++ b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "frc/AnalogTrigger.h" #include "frc/Counter.h" diff --git a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h index 8601cd3bf9..66897aaaac 100644 --- a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h +++ b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include "frc/RobotBase.h" diff --git a/wpilibc/src/main/native/include/frc/LinearFilter.h b/wpilibc/src/main/native/include/frc/LinearFilter.h index 2b83a32d4e..4c9c859d53 100644 --- a/wpilibc/src/main/native/include/frc/LinearFilter.h +++ b/wpilibc/src/main/native/include/frc/LinearFilter.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-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. */ @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/wpilibc/src/main/native/include/frc/Notifier.h b/wpilibc/src/main/native/include/frc/Notifier.h index bdd440a388..94df7252e9 100644 --- a/wpilibc/src/main/native/include/frc/Notifier.h +++ b/wpilibc/src/main/native/include/frc/Notifier.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include diff --git a/wpilibc/src/main/native/include/frc/SPI.h b/wpilibc/src/main/native/include/frc/SPI.h index 1308bbf04c..e9cbe627fe 100644 --- a/wpilibc/src/main/native/include/frc/SPI.h +++ b/wpilibc/src/main/native/include/frc/SPI.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/wpilibc/src/main/native/include/frc/SlewRateLimiter.h b/wpilibc/src/main/native/include/frc/SlewRateLimiter.h index 3d24ae5cc4..fe3a458973 100644 --- a/wpilibc/src/main/native/include/frc/SlewRateLimiter.h +++ b/wpilibc/src/main/native/include/frc/SlewRateLimiter.h @@ -11,7 +11,7 @@ #include -#include +#include namespace frc { /** diff --git a/wpilibc/src/main/native/include/frc/SpeedController.h b/wpilibc/src/main/native/include/frc/SpeedController.h index 2b11aee1f7..3053c3b097 100644 --- a/wpilibc/src/main/native/include/frc/SpeedController.h +++ b/wpilibc/src/main/native/include/frc/SpeedController.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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,7 +7,7 @@ #pragma once -#include +#include #include "frc/PIDOutput.h" diff --git a/wpilibc/src/main/native/include/frc/TimedRobot.h b/wpilibc/src/main/native/include/frc/TimedRobot.h index 81d9008466..66f960b473 100644 --- a/wpilibc/src/main/native/include/frc/TimedRobot.h +++ b/wpilibc/src/main/native/include/frc/TimedRobot.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include "frc/ErrorBase.h" diff --git a/wpilibc/src/main/native/include/frc/Timer.h b/wpilibc/src/main/native/include/frc/Timer.h index 990e8789ec..c766afaa26 100644 --- a/wpilibc/src/main/native/include/frc/Timer.h +++ b/wpilibc/src/main/native/include/frc/Timer.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include diff --git a/wpilibc/src/main/native/include/frc/Tracer.h b/wpilibc/src/main/native/include/frc/Tracer.h index 924783369c..627b07b936 100644 --- a/wpilibc/src/main/native/include/frc/Tracer.h +++ b/wpilibc/src/main/native/include/frc/Tracer.h @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/wpilibc/src/main/native/include/frc/Watchdog.h b/wpilibc/src/main/native/include/frc/Watchdog.h index 127fe7373c..4323b9a7a9 100644 --- a/wpilibc/src/main/native/include/frc/Watchdog.h +++ b/wpilibc/src/main/native/include/frc/Watchdog.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include diff --git a/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h b/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h index 6d0784a676..6629de1253 100644 --- a/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h +++ b/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h @@ -7,7 +7,10 @@ #pragma once -#include +#include +#include +#include +#include #include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h b/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h index d237d6441c..32dced6fb9 100644 --- a/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h +++ b/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h @@ -10,7 +10,7 @@ #include #include -#include +#include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h b/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h index 26d1e7cbf6..faf8ad786f 100644 --- a/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h +++ b/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/controller/PIDController.h b/wpilibc/src/main/native/include/frc/controller/PIDController.h index 6b41af3dae..5f97c1e80e 100644 --- a/wpilibc/src/main/native/include/frc/controller/PIDController.h +++ b/wpilibc/src/main/native/include/frc/controller/PIDController.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "frc/smartdashboard/Sendable.h" #include "frc/smartdashboard/SendableHelper.h" diff --git a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h index eaf2d6ffd7..3f97d18bd6 100644 --- a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h +++ b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "frc/controller/ControllerUtil.h" #include "frc/controller/PIDController.h" diff --git a/wpilibc/src/main/native/include/frc/controller/RamseteController.h b/wpilibc/src/main/native/include/frc/controller/RamseteController.h index e099b5be12..02159838ff 100644 --- a/wpilibc/src/main/native/include/frc/controller/RamseteController.h +++ b/wpilibc/src/main/native/include/frc/controller/RamseteController.h @@ -7,7 +7,8 @@ #pragma once -#include +#include +#include #include "frc/geometry/Pose2d.h" #include "frc/kinematics/ChassisSpeeds.h" diff --git a/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h b/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h index 6f1ef66536..1d31a25c15 100644 --- a/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h +++ b/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h @@ -7,7 +7,8 @@ #pragma once -#include +#include +#include #include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h b/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h index b63651343d..1007a52e08 100644 --- a/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h +++ b/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include namespace wpi { class json; diff --git a/wpilibc/src/main/native/include/frc/geometry/Translation2d.h b/wpilibc/src/main/native/include/frc/geometry/Translation2d.h index 90c61e26fe..5623bd704a 100644 --- a/wpilibc/src/main/native/include/frc/geometry/Translation2d.h +++ b/wpilibc/src/main/native/include/frc/geometry/Translation2d.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include #include "Rotation2d.h" diff --git a/wpilibc/src/main/native/include/frc/geometry/Twist2d.h b/wpilibc/src/main/native/include/frc/geometry/Twist2d.h index ab246a0898..68b2632153 100644 --- a/wpilibc/src/main/native/include/frc/geometry/Twist2d.h +++ b/wpilibc/src/main/native/include/frc/geometry/Twist2d.h @@ -1,12 +1,15 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ /*----------------------------------------------------------------------------*/ #pragma once -#include + +#include +#include +#include namespace frc { /** diff --git a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h index 3fe9b83d54..6154d6d8b3 100644 --- a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h +++ b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h index 8c772c0bb9..a87a11909b 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h +++ b/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,8 @@ #pragma once -#include +#include +#include #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h index e986029994..5de3ec6a55 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h +++ b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,7 +8,8 @@ #pragma once #include -#include +#include +#include #include "frc/kinematics/ChassisSpeeds.h" #include "frc/kinematics/DifferentialDriveWheelSpeeds.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h index 379839df6b..b1023be2dd 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h +++ b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include #include "DifferentialDriveKinematics.h" #include "frc/geometry/Pose2d.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h index 66bd84e235..8eec16b9ef 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h +++ b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include namespace frc { /** diff --git a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h index 697a6b0a26..3008d99053 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h +++ b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include #include "frc/geometry/Pose2d.h" #include "frc/kinematics/MecanumDriveKinematics.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h index 159f7f0a64..7e45e1554d 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h +++ b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include namespace frc { /** diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h index 9717c7a058..53b1330d65 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h +++ b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "frc/geometry/Rotation2d.h" #include "frc/geometry/Translation2d.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc index 26cf4a9151..d40b668fc1 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc +++ b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc @@ -9,6 +9,8 @@ #include +#include + namespace frc { template diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h index 8093ca5360..c2f6460a35 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h +++ b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,7 @@ #include #include -#include +#include #include "SwerveDriveKinematics.h" #include "SwerveModuleState.h" diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h index fbfe0d1da9..f7aa4d9ac7 100644 --- a/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h +++ b/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,7 @@ #pragma once -#include +#include #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/main/native/include/frc/simulation/Field2d.h b/wpilibc/src/main/native/include/frc/simulation/Field2d.h index 5f00606c20..de308474de 100644 --- a/wpilibc/src/main/native/include/frc/simulation/Field2d.h +++ b/wpilibc/src/main/native/include/frc/simulation/Field2d.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/main/native/include/frc/spline/Spline.h b/wpilibc/src/main/native/include/frc/spline/Spline.h index 1fec449f72..cf16bf5195 100644 --- a/wpilibc/src/main/native/include/frc/spline/Spline.h +++ b/wpilibc/src/main/native/include/frc/spline/Spline.h @@ -12,7 +12,8 @@ #include #include -#include +#include +#include #include "frc/geometry/Pose2d.h" diff --git a/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h b/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h index 8cf8ee994b..97334ab17c 100644 --- a/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h +++ b/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h @@ -38,7 +38,10 @@ #include #include -#include +#include +#include +#include +#include #include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h b/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h index 24e13d7f1d..2ca386272f 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h +++ b/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h @@ -9,7 +9,10 @@ #include -#include +#include +#include +#include +#include #include "frc/geometry/Pose2d.h" #include "frc/geometry/Transform2d.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h index 36118a0dbb..291bd98177 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h +++ b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,8 @@ #include #include -#include +#include +#include #include "frc/kinematics/DifferentialDriveKinematics.h" #include "frc/kinematics/MecanumDriveKinematics.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h index 3d57682773..00be35c7db 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h +++ b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc index 50f232dca2..51d1c17548 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc +++ b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,6 +9,8 @@ #include +#include + namespace frc { template TrapezoidProfile::TrapezoidProfile(Constraints constraints, diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h index e46404ef4e..8dc865dc33 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h @@ -7,7 +7,9 @@ #pragma once -#include +#include +#include +#include #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h index 901bd779a4..268805c866 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "frc/kinematics/DifferentialDriveKinematics.h" #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h index ae8d9adb44..bb2336731f 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h @@ -7,7 +7,8 @@ #pragma once -#include +#include +#include #include "frc/controller/SimpleMotorFeedforward.h" #include "frc/kinematics/DifferentialDriveKinematics.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/EllipticalRegionConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/EllipticalRegionConstraint.h index 1e5e673ccb..9441144f99 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/EllipticalRegionConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/EllipticalRegionConstraint.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include "frc/geometry/Rotation2d.h" #include "frc/geometry/Translation2d.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/MaxVelocityConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/MaxVelocityConstraint.h index 042340e0ea..8a4ed557cf 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/MaxVelocityConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/MaxVelocityConstraint.h @@ -7,7 +7,8 @@ #pragma once -#include +#include +#include #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h index 9eb43d2a9c..8f235d5ca5 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h @@ -9,7 +9,7 @@ #include -#include +#include #include "frc/kinematics/MecanumDriveKinematics.h" #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/RectangularRegionConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/RectangularRegionConstraint.h index 134f0555e6..80f2a0994e 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/RectangularRegionConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/RectangularRegionConstraint.h @@ -7,8 +7,6 @@ #pragma once -#include - #include "frc/geometry/Rotation2d.h" #include "frc/geometry/Translation2d.h" #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h index ece368c6a7..d808fc34e2 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h @@ -9,7 +9,7 @@ #include -#include +#include #include "frc/kinematics/SwerveDriveKinematics.h" #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc index c36e3e9b45..84b0ba92b1 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc @@ -7,6 +7,8 @@ #pragma once +#include + namespace frc { template diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h index c9de6761fc..ae9390560f 100644 --- a/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h +++ b/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h @@ -9,7 +9,9 @@ #include -#include +#include +#include +#include #include "frc/geometry/Pose2d.h" #include "frc/spline/Spline.h" diff --git a/wpilibc/src/main/native/include/frc2/Timer.h b/wpilibc/src/main/native/include/frc2/Timer.h index 4994f97485..97b41d9537 100644 --- a/wpilibc/src/main/native/include/frc2/Timer.h +++ b/wpilibc/src/main/native/include/frc2/Timer.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include diff --git a/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp b/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp index 0bb10021c7..637decb9fc 100644 --- a/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp +++ b/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-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. */ @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "gtest/gtest.h" diff --git a/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp b/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp index 8db91b3937..a20437ed24 100644 --- a/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp +++ b/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-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. */ @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "gtest/gtest.h" diff --git a/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp b/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp index ae253a7445..a6c08a4ceb 100644 --- a/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp +++ b/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,6 +7,10 @@ #include +#include +#include +#include + #include "frc/SlewRateLimiter.h" #include "gtest/gtest.h" diff --git a/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp b/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp index 82ca374ac5..9e34af8f6b 100644 --- a/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp +++ b/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include +#include #include "frc/controller/ControllerUtil.h" #include "gtest/gtest.h" diff --git a/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp b/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp index a6000544dd..7cf84fe6fe 100644 --- a/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp +++ b/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp @@ -1,10 +1,11 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ /*----------------------------------------------------------------------------*/ +#include #include #include "frc/controller/RamseteController.h" diff --git a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp index ad0d3c7592..c77b634401 100644 --- a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp +++ b/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp @@ -1,11 +1,13 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ /*----------------------------------------------------------------------------*/ -#include +#include +#include +#include #include #include "frc/kinematics/ChassisSpeeds.h" diff --git a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp index 75f395d72a..af5ba1597d 100644 --- a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp +++ b/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp @@ -1,11 +1,11 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ /*----------------------------------------------------------------------------*/ -#include +#include #include #include "frc/geometry/Translation2d.h" diff --git a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp index 8fd67ea4ac..d52eed70de 100644 --- a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp +++ b/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp @@ -1,11 +1,11 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ /*----------------------------------------------------------------------------*/ -#include +#include #include #include "frc/geometry/Translation2d.h" diff --git a/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp b/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp index f2f0a38f60..5e8cb8de59 100644 --- a/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp +++ b/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp b/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp index 8a87053387..12445e72d9 100644 --- a/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp +++ b/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp @@ -8,7 +8,8 @@ #include #include -#include +#include +#include #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp b/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp index 37f471a1e8..3cc565baf5 100644 --- a/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,7 +8,10 @@ #include #include -#include +#include +#include +#include +#include #include "frc/trajectory/constraint/CentripetalAccelerationConstraint.h" #include "frc/trajectory/constraint/TrajectoryConstraint.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp index df5ddbd665..304de0e8c7 100644 --- a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,7 +8,7 @@ #include #include -#include +#include #include "frc/kinematics/DifferentialDriveKinematics.h" #include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp index 2d5cbdd062..9314e61ac4 100644 --- a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp @@ -9,7 +9,11 @@ #include #include -#include +#include +#include +#include +#include +#include #include "frc/geometry/Pose2d.h" #include "frc/kinematics/DifferentialDriveKinematics.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/EllipticalRegionConstraintTest.cpp b/wpilibc/src/test/native/cpp/trajectory/EllipticalRegionConstraintTest.cpp index c0bfd997ac..a2dc37c10f 100644 --- a/wpilibc/src/test/native/cpp/trajectory/EllipticalRegionConstraintTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/EllipticalRegionConstraintTest.cpp @@ -7,7 +7,10 @@ #include -#include +#include +#include +#include +#include #include "frc/kinematics/DifferentialDriveKinematics.h" #include "frc/trajectory/constraint/EllipticalRegionConstraint.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/RectangularRegionConstraintTest.cpp b/wpilibc/src/test/native/cpp/trajectory/RectangularRegionConstraintTest.cpp index 4b11ecf6f2..7d1144f4a2 100644 --- a/wpilibc/src/test/native/cpp/trajectory/RectangularRegionConstraintTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/RectangularRegionConstraintTest.cpp @@ -7,7 +7,10 @@ #include -#include +#include +#include +#include +#include #include "frc/kinematics/DifferentialDriveKinematics.h" #include "frc/trajectory/constraint/MaxVelocityConstraint.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp index 90046c565f..8101eef130 100644 --- a/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp @@ -7,6 +7,8 @@ #include +#include + #include "frc/trajectory/Trajectory.h" #include "frc/trajectory/TrajectoryGenerator.h" #include "frc/trajectory/constraint/CentripetalAccelerationConstraint.h" diff --git a/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp index bd9ffef9ac..53cae83dfc 100644 --- a/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp +++ b/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -10,6 +10,11 @@ #include #include +#include +#include +#include +#include + #include "gtest/gtest.h" static constexpr auto kDt = 10_ms; diff --git a/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.cpp b/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.cpp index 392e643514..23fc17b16d 100644 --- a/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.cpp +++ b/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,13 +7,16 @@ #include "ReplaceMeProfiledPIDCommand.h" +#include +#include + // NOTE: Consider using this command inline, rather than writing a subclass. // For more information, see: // https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html ReplaceMeProfiledPIDCommand::ReplaceMeProfiledPIDCommand() : CommandHelper( // The ProfiledPIDController that the command will use - frc::ProfiledPIDController( + frc::ProfiledPIDController( // The PID gains 0, 0, 0, // The motion profile constraints @@ -22,11 +25,11 @@ ReplaceMeProfiledPIDCommand::ReplaceMeProfiledPIDCommand() [] { return 0_m; }, // This should return the goal state (can also be a constant) [] { - return frc::TrapezoidProfile::State{0_m, 0_mps}; + return frc::TrapezoidProfile::State{0_m, 0_mps}; }, // This uses the output and current trajectory setpoint [](double output, - frc::TrapezoidProfile::State setpoint) { + frc::TrapezoidProfile::State setpoint) { // Use the output and setpoint here }) {} diff --git a/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.h b/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.h index d3407e8880..dc2c50e3c0 100644 --- a/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.h +++ b/wpilibcExamples/src/main/cpp/commands/profiledpidcommand/ReplaceMeProfiledPIDCommand.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,9 +9,10 @@ #include #include +#include class ReplaceMeProfiledPIDCommand - : public frc2::CommandHelper, + : public frc2::CommandHelper, ReplaceMeProfiledPIDCommand> { public: ReplaceMeProfiledPIDCommand(); diff --git a/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.cpp b/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.cpp index dc27b4357f..4ba8bafbd7 100644 --- a/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.cpp +++ b/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,17 +7,20 @@ #include "ReplaceMeProfiledPIDSubsystem.h" +#include +#include + ReplaceMeProfiledPIDSubsystem::ReplaceMeProfiledPIDSubsystem() : ProfiledPIDSubsystem( // The ProfiledPIDController used by the subsystem - frc::ProfiledPIDController( + frc::ProfiledPIDController( // The PID gains 0, 0, 0, // The constraints for the motion profiles {0_mps, 0_mps_sq})) {} void ReplaceMeProfiledPIDSubsystem::UseOutput( - double output, frc::TrapezoidProfile::State setpoint) { + double output, frc::TrapezoidProfile::State setpoint) { // Use the output and current trajectory setpoint here } diff --git a/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.h b/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.h index b382b1df54..6969c296ac 100644 --- a/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.h +++ b/wpilibcExamples/src/main/cpp/commands/profiledpidsubsystem/ReplaceMeProfiledPIDSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,15 +8,16 @@ #pragma once #include +#include class ReplaceMeProfiledPIDSubsystem - : public frc2::ProfiledPIDSubsystem { + : public frc2::ProfiledPIDSubsystem { public: ReplaceMeProfiledPIDSubsystem(); protected: void UseOutput(double output, - frc::TrapezoidProfile::State setpoint) override; + frc::TrapezoidProfile::State setpoint) override; units::meter_t GetMeasurement() override; }; diff --git a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.cpp b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.cpp index b8cb678657..9bd5f9fdd9 100644 --- a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.cpp +++ b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,19 +7,22 @@ #include "ReplaceMeTrapezoidProfileCommand.h" +#include +#include + // NOTE: Consider using this command inline, rather than writing a subclass. // For more information, see: // https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html ReplaceMeTrapezoidProfileCommand::ReplaceMeTrapezoidProfileCommand() : CommandHelper // The profile to execute - (frc::TrapezoidProfile( + (frc::TrapezoidProfile( // The maximum velocity and acceleration of the profile {5_mps, 5_mps_sq}, // The goal state of the profile {10_m, 0_mps}, // The initial state of the profile {0_m, 0_mps}), - [](frc::TrapezoidProfile::State state) { + [](frc::TrapezoidProfile::State state) { // Use the computed intermediate trajectory state here }) {} diff --git a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.h b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.h index e9043be551..5cf7a200ad 100644 --- a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.h +++ b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilecommand/ReplaceMeTrapezoidProfileCommand.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,9 +9,10 @@ #include #include +#include class ReplaceMeTrapezoidProfileCommand - : public frc2::CommandHelper, + : public frc2::CommandHelper, ReplaceMeTrapezoidProfileCommand> { public: ReplaceMeTrapezoidProfileCommand(); diff --git a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.cpp b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.cpp index 162c02f084..8bc1beede8 100644 --- a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.cpp +++ b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,6 +7,9 @@ #include "ReplaceMeTrapezoidProfileSubsystem.h" +#include +#include + ReplaceMeTrapezoidProfileSubsystem::ReplaceMeTrapezoidProfileSubsystem() : TrapezoidProfileSubsystem( // The motion profile constraints diff --git a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.h b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.h index e93f590300..42a8cb540b 100644 --- a/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.h +++ b/wpilibcExamples/src/main/cpp/commands/trapezoidprofilesubsystem/ReplaceMeTrapezoidProfileSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -8,6 +8,7 @@ #pragma once #include +#include class ReplaceMeTrapezoidProfileSubsystem : frc2::TrapezoidProfileSubsystem { diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/RobotContainer.cpp index aec6b1d7a7..ba7bbf5777 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/RobotContainer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,7 +9,7 @@ #include #include -#include +#include RobotContainer::RobotContainer() { // Initialize all of your commands and subsystems here diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Constants.h index 674633c56d..ac5ffe074b 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/Constants.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,10 @@ #pragma once -#include +#include +#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/subsystems/ArmSubsystem.h b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/subsystems/ArmSubsystem.h index 693f0b4a67..1733efe019 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBot/include/subsystems/ArmSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBot/include/subsystems/ArmSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,7 @@ #include #include #include -#include +#include /** * A robot arm subsystem that moves with a motion profile. diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/RobotContainer.cpp index aec6b1d7a7..ba7bbf5777 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/cpp/RobotContainer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,7 +9,7 @@ #include #include -#include +#include RobotContainer::RobotContainer() { // Initialize all of your commands and subsystems here diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Constants.h index 674633c56d..ac5ffe074b 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/Constants.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,10 @@ #pragma once -#include +#include +#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/subsystems/ArmSubsystem.h b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/subsystems/ArmSubsystem.h index 52f15f1130..8030cb4279 100644 --- a/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/subsystems/ArmSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/ArmBotOffboard/include/subsystems/ArmSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,7 +9,7 @@ #include #include -#include +#include #include "ExampleSmartMotorController.h" diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h index f2106b00f3..d8f3521c6c 100644 --- a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h +++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.h @@ -15,7 +15,10 @@ #include #include #include -#include +#include +#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Constants.h index bcf3356e0a..8ff887e12e 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Constants.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,11 @@ #pragma once -#include +#include +#include +#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.h b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.h index 900995f4db..45fa982f1f 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "Constants.h" #include "ExampleSmartMotorController.h" diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp index d423dd80a7..b1bb1ecbed 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,10 @@ #include #include #include -#include +#include +#include +#include +#include #include class Robot : public frc::TimedRobot { diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp index 5853054054..5addac4140 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -9,7 +9,11 @@ #include #include #include -#include +#include +#include +#include +#include +#include #include #include "ExampleSmartMotorController.h" @@ -33,8 +37,8 @@ class Robot : public frc::TimedRobot { // Create a motion profile with the given maximum velocity and maximum // acceleration constraints for the next setpoint, the desired goal, and the // current setpoint. - frc::TrapezoidProfile profile{m_constraints, m_goal, - m_setpoint}; + frc::TrapezoidProfile profile{m_constraints, m_goal, + m_setpoint}; // Retrieve the profiled setpoint for the next timestep. This setpoint moves // toward the goal while obeying the constraints. diff --git a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h index 1aef3ad0a4..0e2d0e7814 100644 --- a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/Constants.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,9 @@ #pragma once -#include +#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/subsystems/ShooterSubsystem.h b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/subsystems/ShooterSubsystem.h index e8edd28309..7553544825 100644 --- a/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/subsystems/ShooterSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/Frisbeebot/include/subsystems/ShooterSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -11,7 +11,7 @@ #include #include #include -#include +#include class ShooterSubsystem : public frc2::PIDSubsystem { public: diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h index f423640566..cc8b841818 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/Constants.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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,7 +7,8 @@ #pragma once -#include +#include +#include #include /** diff --git a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/subsystems/DriveSubsystem.h b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/subsystems/DriveSubsystem.h index c4cd21c71d..cd3d66780b 100644 --- a/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/subsystems/DriveSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/GyroDriveCommands/include/subsystems/DriveSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "Constants.h" diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/subsystems/DriveSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/subsystems/DriveSubsystem.cpp index 3651cae36a..ef6564fd26 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/subsystems/DriveSubsystem.cpp +++ b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/subsystems/DriveSubsystem.cpp @@ -7,7 +7,9 @@ #include "subsystems/DriveSubsystem.h" -#include +#include +#include +#include #include "Constants.h" diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Constants.h index 8ca9aade7d..c37cb8a8d6 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/include/Constants.h @@ -8,7 +8,13 @@ #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #pragma once diff --git a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h index ad9930d19c..7d3ea8f97d 100644 --- a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h @@ -7,7 +7,11 @@ #include #include -#include +#include +#include +#include +#include +#include #include #pragma once 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 2fb211e546..73c6c21887 100644 --- a/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h +++ b/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "Constants.h" diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.h b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.h index 4c281608db..bf82df4f38 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.h +++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.h @@ -13,6 +13,10 @@ #include #include #include +#include +#include +#include +#include #include class SwerveModule { @@ -43,8 +47,8 @@ class SwerveModule { 0.0, {kModuleMaxAngularVelocity, kModuleMaxAngularAcceleration}}; - frc::SimpleMotorFeedforward m_driveFeedforward{1_V, - 3_V / 1_mps}; + frc::SimpleMotorFeedforward m_driveFeedforward{1_V, + 3_V / 1_mps}; frc::SimpleMotorFeedforward m_turnFeedforward{ 1_V, 0.5_V / 1_rad_per_s}; }; diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp index 44efba52b5..87aac29c09 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-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. */ @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include "Constants.h" #include "subsystems/DriveSubsystem.h" diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/DriveSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/DriveSubsystem.cpp index 06a5b58523..37bb83d6ac 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/DriveSubsystem.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/DriveSubsystem.cpp @@ -8,7 +8,9 @@ #include "subsystems/DriveSubsystem.h" #include -#include +#include +#include +#include #include "Constants.h" diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Constants.h b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Constants.h index 237ad5145c..8911b5fdc2 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Constants.h +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/Constants.h @@ -8,7 +8,13 @@ #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #pragma once diff --git a/wpiutil/.styleguide b/wpiutil/.styleguide index 409ea0688e..b505fbfb6d 100644 --- a/wpiutil/.styleguide +++ b/wpiutil/.styleguide @@ -13,6 +13,7 @@ generatedFileExclude { src/main/native/cpp/llvm/ src/main/native/eigeninclude/ src/main/native/include/llvm/ + src/main/native/include/units/base\.h$ src/main/native/include/units/units\.h$ src/main/native/include/unsupported/ src/main/native/include/wpi/AlignOf\.h$ diff --git a/wpiutil/src/main/native/include/units/acceleration.h b/wpiutil/src/main/native/include/units/acceleration.h new file mode 100644 index 0000000000..5427160029 --- /dev/null +++ b/wpiutil/src/main/native/include/units/acceleration.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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. */ +/*----------------------------------------------------------------------------*/ + +// Copyright (c) 2016 Nic Holthaus +// +// The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "units/base.h" +#include "units/length.h" +#include "units/time.h" + +namespace units { +/** + * @namespace units::acceleration + * @brief namespace for unit types and containers representing acceleration + * values + * @details The SI unit for acceleration is `meters_per_second_squared`, and the + * corresponding `base_unit` category is `acceleration_unit`. + * @anchor accelerationContainers + * @sa See unit_t for more information on unit type containers. + */ +#if !defined(DISABLE_PREDEFINED_UNITS) || \ + defined(ENABLE_PREDEFINED_ACCELERATION_UNITS) +UNIT_ADD(acceleration, meters_per_second_squared, meters_per_second_squared, + mps_sq, unit, units::category::acceleration_unit>) +UNIT_ADD(acceleration, feet_per_second_squared, feet_per_second_squared, fps_sq, + compound_unit>>) +UNIT_ADD(acceleration, standard_gravity, standard_gravity, SG, + unit, meters_per_second_squared>) + +UNIT_ADD_CATEGORY_TRAIT(acceleration) +#endif + +using namespace acceleration; +} // namespace units diff --git a/wpiutil/src/main/native/include/units/angle.h b/wpiutil/src/main/native/include/units/angle.h new file mode 100644 index 0000000000..a0f802f299 --- /dev/null +++ b/wpiutil/src/main/native/include/units/angle.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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. */ +/*----------------------------------------------------------------------------*/ + +// Copyright (c) 2016 Nic Holthaus +// +// The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "units/base.h" + +namespace units { +/** + * @namespace units::angle + * @brief namespace for unit types and containers representing angle values + * @details The SI unit for angle is `radians`, and the corresponding + * `base_unit` category is`angle_unit`. + * @anchor angleContainers + * @sa See unit_t for more information on unit type containers. + */ +#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS) +UNIT_ADD_WITH_METRIC_PREFIXES(angle, radian, radians, rad, + unit, units::category::angle_unit>) +UNIT_ADD(angle, degree, degrees, deg, + unit, radians, std::ratio<1>>) +UNIT_ADD(angle, arcminute, arcminutes, arcmin, unit, degrees>) +UNIT_ADD(angle, arcsecond, arcseconds, arcsec, + unit, arcminutes>) +UNIT_ADD(angle, milliarcsecond, milliarcseconds, mas, milli) +UNIT_ADD(angle, turn, turns, tr, unit, radians, std::ratio<1>>) +UNIT_ADD(angle, gradian, gradians, gon, unit, turns>) + +UNIT_ADD_CATEGORY_TRAIT(angle) +#endif + +using namespace angle; +} // namespace units diff --git a/wpiutil/src/main/native/include/units/angular_velocity.h b/wpiutil/src/main/native/include/units/angular_velocity.h new file mode 100644 index 0000000000..580d021c44 --- /dev/null +++ b/wpiutil/src/main/native/include/units/angular_velocity.h @@ -0,0 +1,61 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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. */ +/*----------------------------------------------------------------------------*/ + +// Copyright (c) 2016 Nic Holthaus +// +// The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "units/angle.h" +#include "units/base.h" +#include "units/time.h" + +namespace units { +/** + * @namespace units::angular_velocity + * @brief namespace for unit types and containers representing angular velocity + * values + * @details The SI unit for angular velocity is `radians_per_second`, and the + * corresponding `base_unit` category is`angular_velocity_unit`. + * @anchor angularVelocityContainers + * @sa See unit_t for more information on unit type containers. + */ +#if !defined(DISABLE_PREDEFINED_UNITS) || \ + defined(ENABLE_PREDEFINED_ANGULAR_VELOCITY_UNITS) +UNIT_ADD(angular_velocity, radians_per_second, radians_per_second, rad_per_s, + unit, units::category::angular_velocity_unit>) +UNIT_ADD(angular_velocity, degrees_per_second, degrees_per_second, deg_per_s, + compound_unit>) +UNIT_ADD(angular_velocity, revolutions_per_minute, revolutions_per_minute, rpm, + unit, radians_per_second, std::ratio<1>>) +UNIT_ADD(angular_velocity, milliarcseconds_per_year, milliarcseconds_per_year, + mas_per_yr, compound_unit>) + +UNIT_ADD_CATEGORY_TRAIT(angular_velocity) +#endif + +using namespace angular_velocity; +} // namespace units diff --git a/wpiutil/src/main/native/include/units/area.h b/wpiutil/src/main/native/include/units/area.h new file mode 100644 index 0000000000..1bdd3e34d4 --- /dev/null +++ b/wpiutil/src/main/native/include/units/area.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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. */ +/*----------------------------------------------------------------------------*/ + +// Copyright (c) 2016 Nic Holthaus +// +// The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "units/base.h" +#include "units/length.h" + +namespace units { +/** + * @namespace units::area + * @brief namespace for unit types and containers representing area values + * @details The SI unit for area is `square_meters`, and the corresponding + * `base_unit` category is `area_unit`. + * @anchor areaContainers + * @sa See unit_t for more information on unit type containers. + */ +#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_AREA_UNITS) +UNIT_ADD(area, square_meter, square_meters, sq_m, + unit, units::category::area_unit>) +UNIT_ADD(area, square_foot, square_feet, sq_ft, squared) +UNIT_ADD(area, square_inch, square_inches, sq_in, squared) +UNIT_ADD(area, square_mile, square_miles, sq_mi, squared) +UNIT_ADD(area, square_kilometer, square_kilometers, sq_km, + squared) +UNIT_ADD(area, hectare, hectares, ha, unit, square_meters>) +UNIT_ADD(area, acre, acres, acre, unit, square_feet>) + +UNIT_ADD_CATEGORY_TRAIT(area) +#endif + +using namespace area; +} // namespace units diff --git a/wpiutil/src/main/native/include/units/base.h b/wpiutil/src/main/native/include/units/base.h new file mode 100644 index 0000000000..b3c1355135 --- /dev/null +++ b/wpiutil/src/main/native/include/units/base.h @@ -0,0 +1,3366 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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. */ +/*----------------------------------------------------------------------------*/ + +// Copyright (c) 2016 Nic Holthaus +// +// The MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// ATTRIBUTION: +// Parts of this work have been adapted from: +// http://stackoverflow.com/questions/35069778/create-comparison-trait-for-template-classes-whose-parameters-are-in-a-different +// http://stackoverflow.com/questions/28253399/check-traits-for-all-variadic-template-arguments/28253503 +// http://stackoverflow.com/questions/36321295/rational-approximation-of-square-root-of-stdratio-at-compile-time?noredirect=1#comment60266601_36321295 +// + +/// @file units.h +/// @brief Complete implementation of `units` - a compile-time, header-only, +/// unit conversion library built on c++14 with no dependencies. + +#pragma once + +#ifdef _MSC_VER +# pragma push_macro("pascal") +# undef pascal +# if _MSC_VER <= 1800 +# define _ALLOW_KEYWORD_MACROS +# pragma warning(push) +# pragma warning(disable : 4520) +# pragma push_macro("constexpr") +# define constexpr /*constexpr*/ +# pragma push_macro("noexcept") +# define noexcept throw() +# endif // _MSC_VER < 1800 +#endif // _MSC_VER + +#if !defined(_MSC_VER) || _MSC_VER > 1800 +# define UNIT_HAS_LITERAL_SUPPORT +# define UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT +#endif + +#ifndef UNIT_LIB_DEFAULT_TYPE +# define UNIT_LIB_DEFAULT_TYPE double +#endif + +//-------------------- +// INCLUDES +//-------------------- + +#include +#include +#include +#include +#include +#include + +#if !defined(UNIT_LIB_DISABLE_IOSTREAM) + #include + #include + #include + + //------------------------------ + // STRING FORMATTER + //------------------------------ + + namespace units + { + namespace detail + { + template std::string to_string(const T& t) + { + std::string str{ std::to_string(t) }; + int offset{ 1 }; + + // remove trailing decimal points for integer value units. Locale aware! + struct lconv * lc; + lc = localeconv(); + char decimalPoint = *lc->decimal_point; + if (str.find_last_not_of('0') == str.find(decimalPoint)) { offset = 0; } + str.erase(str.find_last_not_of('0') + offset, std::string::npos); + return str; + } + } + } +#endif + +namespace units +{ + template inline constexpr const char* name(const T&); + template inline constexpr const char* abbreviation(const T&); +} + +//------------------------------ +// MACROS +//------------------------------ + +/** + * @def UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, definition) + * @brief Helper macro for generating the boiler-plate code generating the tags of a new unit. + * @details The macro generates singular, plural, and abbreviated forms + * of the unit definition (e.g. `meter`, `meters`, and `m`), as aliases for the + * unit tag. + * @param namespaceName namespace in which the new units will be encapsulated. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param namePlural - plural version of the unit name, e.g. 'meters' + * @param abbreviation - abbreviated unit name, e.g. 'm' + * @param definition - the variadic parameter is used for the definition of the unit + * (e.g. `unit, units::category::length_unit>`) + * @note a variadic template is used for the definition to allow templates with + * commas to be easily expanded. All the variadic 'arguments' should together + * comprise the unit definition. + */ +#define UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, /*definition*/...)\ + namespace namespaceName\ + {\ + /** @name Units (full names plural) */ /** @{ */ typedef __VA_ARGS__ namePlural; /** @} */\ + /** @name Units (full names singular) */ /** @{ */ typedef namePlural nameSingular; /** @} */\ + /** @name Units (abbreviated) */ /** @{ */ typedef namePlural abbreviation; /** @} */\ + } + +/** + * @def UNIT_ADD_UNIT_DEFINITION(namespaceName,nameSingular) + * @brief Macro for generating the boiler-plate code for the unit_t type definition. + * @details The macro generates the definition of the unit container types, e.g. `meter_t` + * @param namespaceName namespace in which the new units will be encapsulated. + * @param nameSingular singular version of the unit name, e.g. 'meter' + */ +#define UNIT_ADD_UNIT_DEFINITION(namespaceName,nameSingular)\ + namespace namespaceName\ + {\ + /** @name Unit Containers */ /** @{ */ typedef unit_t nameSingular ## _t; /** @} */\ + } + +/** + * @def UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION(namespaceName,nameSingular,underlyingType) + * @brief Macro for generating the boiler-plate code for a unit_t type definition with a non-default underlying type. + * @details The macro generates the definition of the unit container types, e.g. `meter_t` + * @param namespaceName namespace in which the new units will be encapsulated. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param underlyingType the underlying type + */ +#define UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION(namespaceName,nameSingular, underlyingType)\ + namespace namespaceName\ + {\ + /** @name Unit Containers */ /** @{ */ typedef unit_t nameSingular ## _t; /** @} */\ + } +/** + * @def UNIT_ADD_IO(namespaceName,nameSingular, abbreviation) + * @brief Macro for generating the boiler-plate code needed for I/O for a new unit. + * @details The macro generates the code to insert units into an ostream. It + * prints both the value and abbreviation of the unit when invoked. + * @param namespaceName namespace in which the new units will be encapsulated. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param abbrev - abbreviated unit name, e.g. 'm' + * @note When UNIT_LIB_DISABLE_IOSTREAM is defined, the macro does not generate any code + */ +#if defined(UNIT_LIB_DISABLE_IOSTREAM) + #define UNIT_ADD_IO(namespaceName, nameSingular, abbrev) +#else + #define UNIT_ADD_IO(namespaceName, nameSingular, abbrev)\ + namespace namespaceName\ + {\ + inline std::ostream& operator<<(std::ostream& os, const nameSingular ## _t& obj) \ + {\ + os << obj() << " "#abbrev; return os; \ + }\ + inline std::string to_string(const nameSingular ## _t& obj)\ + {\ + return units::detail::to_string(obj()) + std::string(" "#abbrev);\ + }\ + } +#endif + + /** + * @def UNIT_ADD_NAME(namespaceName,nameSingular,abbreviation) + * @brief Macro for generating constexpr names/abbreviations for units. + * @details The macro generates names for units. E.g. name() of 1_m would be "meter", and + * abbreviation would be "m". + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param abbreviation - abbreviated unit name, e.g. 'm' + */ +#define UNIT_ADD_NAME(namespaceName, nameSingular, abbrev)\ +template<> inline constexpr const char* name(const namespaceName::nameSingular ## _t&)\ +{\ + return #nameSingular;\ +}\ +template<> inline constexpr const char* abbreviation(const namespaceName::nameSingular ## _t&)\ +{\ + return #abbrev;\ +} + +/** + * @def UNIT_ADD_LITERALS(namespaceName,nameSingular,abbreviation) + * @brief Macro for generating user-defined literals for units. + * @details The macro generates user-defined literals for units. A literal suffix is created + * using the abbreviation (e.g. `10.0_m`). + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param abbreviation - abbreviated unit name, e.g. 'm' + * @note When UNIT_HAS_LITERAL_SUPPORT is not defined, the macro does not generate any code + */ +#if defined(UNIT_HAS_LITERAL_SUPPORT) + #define UNIT_ADD_LITERALS(namespaceName, nameSingular, abbreviation)\ + namespace literals\ + {\ + inline constexpr namespaceName::nameSingular ## _t operator""_ ## abbreviation(long double d)\ + {\ + return namespaceName::nameSingular ## _t(static_cast(d));\ + }\ + inline constexpr namespaceName::nameSingular ## _t operator""_ ## abbreviation (unsigned long long d)\ + {\ + return namespaceName::nameSingular ## _t(static_cast(d));\ + }\ + } +#else + #define UNIT_ADD_LITERALS(namespaceName, nameSingular, abbreviation) +#endif + +/** + * @def UNIT_ADD(namespaceName,nameSingular, namePlural, abbreviation, definition) + * @brief Macro for generating the boiler-plate code needed for a new unit. + * @details The macro generates singular, plural, and abbreviated forms + * of the unit definition (e.g. `meter`, `meters`, and `m`), as well as the + * appropriately named unit container (e.g. `meter_t`). A literal suffix is created + * using the abbreviation (e.g. `10.0_m`). It also defines a class-specific + * cout function which prints both the value and abbreviation of the unit when invoked. + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param namePlural - plural version of the unit name, e.g. 'meters' + * @param abbreviation - abbreviated unit name, e.g. 'm' + * @param definition - the variadic parameter is used for the definition of the unit + * (e.g. `unit, units::category::length_unit>`) + * @note a variadic template is used for the definition to allow templates with + * commas to be easily expanded. All the variadic 'arguments' should together + * comprise the unit definition. + */ +#define UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation, /*definition*/...)\ + UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, __VA_ARGS__)\ + UNIT_ADD_UNIT_DEFINITION(namespaceName,nameSingular)\ + UNIT_ADD_NAME(namespaceName,nameSingular, abbreviation)\ + UNIT_ADD_IO(namespaceName,nameSingular, abbreviation)\ + UNIT_ADD_LITERALS(namespaceName,nameSingular, abbreviation) + +/** + * @def UNIT_ADD_WITH_CUSTOM_TYPE(namespaceName,nameSingular, namePlural, abbreviation, underlyingType, definition) + * @brief Macro for generating the boiler-plate code needed for a new unit with a non-default underlying type. + * @details The macro generates singular, plural, and abbreviated forms + * of the unit definition (e.g. `meter`, `meters`, and `m`), as well as the + * appropriately named unit container (e.g. `meter_t`). A literal suffix is created + * using the abbreviation (e.g. `10.0_m`). It also defines a class-specific + * cout function which prints both the value and abbreviation of the unit when invoked. + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param namePlural - plural version of the unit name, e.g. 'meters' + * @param abbreviation - abbreviated unit name, e.g. 'm' + * @param underlyingType - the underlying type, e.g. 'int' or 'float' + * @param definition - the variadic parameter is used for the definition of the unit + * (e.g. `unit, units::category::length_unit>`) + * @note a variadic template is used for the definition to allow templates with + * commas to be easily expanded. All the variadic 'arguments' should together + * comprise the unit definition. + */ +#define UNIT_ADD_WITH_CUSTOM_TYPE(namespaceName, nameSingular, namePlural, abbreviation, underlyingType, /*definition*/...)\ + UNIT_ADD_UNIT_TAGS(namespaceName,nameSingular, namePlural, abbreviation, __VA_ARGS__)\ + UNIT_ADD_CUSTOM_TYPE_UNIT_DEFINITION(namespaceName,nameSingular,underlyingType)\ + UNIT_ADD_IO(namespaceName,nameSingular, abbreviation)\ + UNIT_ADD_LITERALS(namespaceName,nameSingular, abbreviation) + +/** + * @def UNIT_ADD_DECIBEL(namespaceName, nameSingular, abbreviation) + * @brief Macro to create decibel container and literals for an existing unit type. + * @details This macro generates the decibel unit container, cout overload, and literal definitions. + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the base unit name, e.g. 'watt' + * @param abbreviation - abbreviated decibel unit name, e.g. 'dBW' + */ +#define UNIT_ADD_DECIBEL(namespaceName, nameSingular, abbreviation)\ + namespace namespaceName\ + {\ + /** @name Unit Containers */ /** @{ */ typedef unit_t abbreviation ## _t; /** @} */\ + }\ + UNIT_ADD_IO(namespaceName, abbreviation, abbreviation)\ + UNIT_ADD_LITERALS(namespaceName, abbreviation, abbreviation) + +/** + * @def UNIT_ADD_CATEGORY_TRAIT(unitCategory, baseUnit) + * @brief Macro to create the `is_category_unit` type trait. + * @details This trait allows users to test whether a given type matches + * an intended category. This macro comprises all the boiler-plate + * code necessary to do so. + * @param unitCategory The name of the category of unit, e.g. length or mass. + */ + +#define UNIT_ADD_CATEGORY_TRAIT_DETAIL(unitCategory)\ + namespace traits\ + {\ + /** @cond */\ + namespace detail\ + {\ + template struct is_ ## unitCategory ## _unit_impl : std::false_type {};\ + template\ + struct is_ ## unitCategory ## _unit_impl> : std::is_same>::base_unit_type>, units::category::unitCategory ## _unit>::type {};\ + template class N>\ + struct is_ ## unitCategory ## _unit_impl> : std::is_same>::unit_type>, units::category::unitCategory ## _unit>::type {};\ + }\ + /** @endcond */\ + } + +#if defined(UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT) +#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)\ + namespace traits\ + {\ + template struct is_ ## unitCategory ## _unit : std::integral_constant>::value...>::value> {};\ + } +#else +#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)\ + namespace traits\ + {\ + template\ + struct is_ ## unitCategory ## _unit : std::integral_constant::type>::value &&\ + units::traits::detail::is_ ## unitCategory ## _unit_impl::type>::value &&\ + units::traits::detail::is_ ## unitCategory ## _unit_impl::type>::value>{};\ + } +#endif + +#define UNIT_ADD_CATEGORY_TRAIT(unitCategory)\ + UNIT_ADD_CATEGORY_TRAIT_DETAIL(unitCategory)\ + /** @ingroup TypeTraits*/\ + /** @brief Trait which tests whether a type represents a unit of unitCategory*/\ + /** @details Inherits from `std::true_type` or `std::false_type`. Use `is_ ## unitCategory ## _unit::value` to test the unit represents a unitCategory quantity.*/\ + /** @tparam T one or more types to test*/\ + UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory) + +/** + * @def UNIT_ADD_WITH_METRIC_PREFIXES(nameSingular, namePlural, abbreviation, definition) + * @brief Macro for generating the boiler-plate code needed for a new unit, including its metric + * prefixes from femto to peta. + * @details See UNIT_ADD. In addition to generating the unit definition and containers '(e.g. `meters` and 'meter_t', + * it also creates corresponding units with metric suffixes such as `millimeters`, and `millimeter_t`), as well as the + * literal suffixes (e.g. `10.0_mm`). + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'meter' + * @param namePlural - plural version of the unit name, e.g. 'meters' + * @param abbreviation - abbreviated unit name, e.g. 'm' + * @param definition - the variadic parameter is used for the definition of the unit + * (e.g. `unit, units::category::length_unit>`) + * @note a variadic template is used for the definition to allow templates with + * commas to be easily expanded. All the variadic 'arguments' should together + * comprise the unit definition. + */ +#define UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, /*definition*/...)\ + UNIT_ADD(namespaceName, nameSingular, namePlural, abbreviation, __VA_ARGS__)\ + UNIT_ADD(namespaceName, femto ## nameSingular, femto ## namePlural, f ## abbreviation, femto)\ + UNIT_ADD(namespaceName, pico ## nameSingular, pico ## namePlural, p ## abbreviation, pico)\ + UNIT_ADD(namespaceName, nano ## nameSingular, nano ## namePlural, n ## abbreviation, nano)\ + UNIT_ADD(namespaceName, micro ## nameSingular, micro ## namePlural, u ## abbreviation, micro)\ + UNIT_ADD(namespaceName, milli ## nameSingular, milli ## namePlural, m ## abbreviation, milli)\ + UNIT_ADD(namespaceName, centi ## nameSingular, centi ## namePlural, c ## abbreviation, centi)\ + UNIT_ADD(namespaceName, deci ## nameSingular, deci ## namePlural, d ## abbreviation, deci)\ + UNIT_ADD(namespaceName, deca ## nameSingular, deca ## namePlural, da ## abbreviation, deca)\ + UNIT_ADD(namespaceName, hecto ## nameSingular, hecto ## namePlural, h ## abbreviation, hecto)\ + UNIT_ADD(namespaceName, kilo ## nameSingular, kilo ## namePlural, k ## abbreviation, kilo)\ + UNIT_ADD(namespaceName, mega ## nameSingular, mega ## namePlural, M ## abbreviation, mega)\ + UNIT_ADD(namespaceName, giga ## nameSingular, giga ## namePlural, G ## abbreviation, giga)\ + UNIT_ADD(namespaceName, tera ## nameSingular, tera ## namePlural, T ## abbreviation, tera)\ + UNIT_ADD(namespaceName, peta ## nameSingular, peta ## namePlural, P ## abbreviation, peta)\ + + /** + * @def UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(nameSingular, namePlural, abbreviation, definition) + * @brief Macro for generating the boiler-plate code needed for a new unit, including its metric + * prefixes from femto to peta, and binary prefixes from kibi to exbi. + * @details See UNIT_ADD. In addition to generating the unit definition and containers '(e.g. `bytes` and 'byte_t', + * it also creates corresponding units with metric suffixes such as `millimeters`, and `millimeter_t`), as well as the + * literal suffixes (e.g. `10.0_B`). + * @param namespaceName namespace in which the new units will be encapsulated. All literal values + * are placed in the `units::literals` namespace. + * @param nameSingular singular version of the unit name, e.g. 'byte' + * @param namePlural - plural version of the unit name, e.g. 'bytes' + * @param abbreviation - abbreviated unit name, e.g. 'B' + * @param definition - the variadic parameter is used for the definition of the unit + * (e.g. `unit, units::category::data_unit>`) + * @note a variadic template is used for the definition to allow templates with + * commas to be easily expanded. All the variadic 'arguments' should together + * comprise the unit definition. + */ +#define UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, /*definition*/...)\ + UNIT_ADD_WITH_METRIC_PREFIXES(namespaceName, nameSingular, namePlural, abbreviation, __VA_ARGS__)\ + UNIT_ADD(namespaceName, kibi ## nameSingular, kibi ## namePlural, Ki ## abbreviation, kibi)\ + UNIT_ADD(namespaceName, mebi ## nameSingular, mebi ## namePlural, Mi ## abbreviation, mebi)\ + UNIT_ADD(namespaceName, gibi ## nameSingular, gibi ## namePlural, Gi ## abbreviation, gibi)\ + UNIT_ADD(namespaceName, tebi ## nameSingular, tebi ## namePlural, Ti ## abbreviation, tebi)\ + UNIT_ADD(namespaceName, pebi ## nameSingular, pebi ## namePlural, Pi ## abbreviation, pebi)\ + UNIT_ADD(namespaceName, exbi ## nameSingular, exbi ## namePlural, Ei ## abbreviation, exbi) + +//-------------------- +// UNITS NAMESPACE +//-------------------- + +/** + * @namespace units + * @brief Unit Conversion Library namespace + */ +namespace units +{ + //---------------------------------- + // DOXYGEN + //---------------------------------- + + /** + * @defgroup UnitContainers Unit Containers + * @brief Defines a series of classes which contain dimensioned values. Unit containers + * store a value, and support various arithmetic operations. + */ + + /** + * @defgroup UnitTypes Unit Types + * @brief Defines a series of classes which represent units. These types are tags used by + * the conversion function, to create compound units, or to create `unit_t` types. + * By themselves, they are not containers and have no stored value. + */ + + /** + * @defgroup UnitManipulators Unit Manipulators + * @brief Defines a series of classes used to manipulate unit types, such as `inverse<>`, `squared<>`, and metric prefixes. + * Unit manipulators can be chained together, e.g. `inverse>>` to + * represent picoseconds^-2. + */ + + /** + * @defgroup CompileTimeUnitManipulators Compile-time Unit Manipulators + * @brief Defines a series of classes used to manipulate `unit_value_t` types at compile-time, such as `unit_value_add<>`, `unit_value_sqrt<>`, etc. + * Compile-time manipulators can be chained together, e.g. `unit_value_sqrt, unit_value_power>>` to + * represent `c = sqrt(a^2 + b^2). + */ + + /** + * @defgroup UnitMath Unit Math + * @brief Defines a collection of unit-enabled, strongly-typed versions of `` functions. + * @details Includes most c++11 extensions. + */ + + /** + * @defgroup Conversion Explicit Conversion + * @brief Functions used to convert values of one logical type to another. + */ + + /** + * @defgroup TypeTraits Type Traits + * @brief Defines a series of classes to obtain unit type information at compile-time. + */ + + //------------------------------ + // FORWARD DECLARATIONS + //------------------------------ + + /** @cond */ // DOXYGEN IGNORE + namespace constants + { + namespace detail + { + static constexpr const UNIT_LIB_DEFAULT_TYPE PI_VAL = 3.14159265358979323846264338327950288419716939937510; + } + } + /** @endcond */ // END DOXYGEN IGNORE + + //------------------------------ + // RATIO TRAITS + //------------------------------ + + /** + * @ingroup TypeTraits + * @{ + */ + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /// has_num implementation. + template + struct has_num_impl + { + template + static constexpr auto test(U*)->std::is_integral {return std::is_integral{}; } + template + static constexpr std::false_type test(...) { return std::false_type{}; } + + using type = decltype(test(0)); + }; + } + + /** + * @brief Trait which checks for the existence of a static numerator. + * @details Inherits from `std::true_type` or `std::false_type`. Use `has_num::value` to test + * whether `class T` has a numerator static member. + */ + template + struct has_num : units::detail::has_num_impl::type {}; + + namespace detail + { + /// has_den implementation. + template + struct has_den_impl + { + template + static constexpr auto test(U*)->std::is_integral { return std::is_integral{}; } + template + static constexpr std::false_type test(...) { return std::false_type{}; } + + using type = decltype(test(0)); + }; + } + + /** + * @brief Trait which checks for the existence of a static denominator. + * @details Inherits from `std::true_type` or `std::false_type`. Use `has_den::value` to test + * whether `class T` has a denominator static member. + */ + template + struct has_den : units::detail::has_den_impl::type {}; + + /** @endcond */ // END DOXYGEN IGNORE + + namespace traits + { + /** + * @brief Trait that tests whether a type represents a std::ratio. + * @details Inherits from `std::true_type` or `std::false_type`. Use `is_ratio::value` to test + * whether `class T` implements a std::ratio. + */ + template + struct is_ratio : std::integral_constant::value && + has_den::value> + {}; + } + + //------------------------------ + // UNIT TRAITS + //------------------------------ + + /** @cond */ // DOXYGEN IGNORE + /** + * @brief void type. + * @details Helper class for creating type traits. + */ + template + struct void_t { typedef void type; }; + + /** + * @brief parameter pack for boolean arguments. + */ + template struct bool_pack {}; + + /** + * @brief Trait which tests that a set of other traits are all true. + */ + template + struct all_true : std::is_same, units::bool_pack> {}; + /** @endcond */ // DOXYGEN IGNORE + + /** + * @brief namespace representing type traits which can access the properties of types provided by the units library. + */ + namespace traits + { +#ifdef FOR_DOXYGEN_PURPOSES_ONLY + /** + * @ingroup TypeTraits + * @brief Traits class defining the properties of units. + * @details The units library determines certain properties of the units passed to + * them and what they represent by using the members of the corresponding + * unit_traits instantiation. + */ + template + struct unit_traits + { + typedef typename T::base_unit_type base_unit_type; ///< Unit type that the unit was derived from. May be a `base_unit` or another `unit`. Use the `base_unit_of` trait to find the SI base unit type. This will be `void` if type `T` is not a unit. + typedef typename T::conversion_ratio conversion_ratio; ///< `std::ratio` representing the conversion factor to the `base_unit_type`. This will be `void` if type `T` is not a unit. + typedef typename T::pi_exponent_ratio pi_exponent_ratio; ///< `std::ratio` representing the exponent of pi to be used in the conversion. This will be `void` if type `T` is not a unit. + typedef typename T::translation_ratio translation_ratio; ///< `std::ratio` representing a datum translation to the base unit (i.e. degrees C to degrees F conversion). This will be `void` if type `T` is not a unit. + }; +#endif + /** @cond */ // DOXYGEN IGNORE + /** + * @brief unit traits implementation for classes which are not units. + */ + template + struct unit_traits + { + typedef void base_unit_type; + typedef void conversion_ratio; + typedef void pi_exponent_ratio; + typedef void translation_ratio; + }; + + template + struct unit_traits + ::type> + { + typedef typename T::base_unit_type base_unit_type; ///< Unit type that the unit was derived from. May be a `base_unit` or another `unit`. Use the `base_unit_of` trait to find the SI base unit type. This will be `void` if type `T` is not a unit. + typedef typename T::conversion_ratio conversion_ratio; ///< `std::ratio` representing the conversion factor to the `base_unit_type`. This will be `void` if type `T` is not a unit. + typedef typename T::pi_exponent_ratio pi_exponent_ratio; ///< `std::ratio` representing the exponent of pi to be used in the conversion. This will be `void` if type `T` is not a unit. + typedef typename T::translation_ratio translation_ratio; ///< `std::ratio` representing a datum translation to the base unit (i.e. degrees C to degrees F conversion). This will be `void` if type `T` is not a unit. + }; + /** @endcond */ // END DOXYGEN IGNORE + } + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief helper type to identify base units. + * @details A non-templated base class for `base_unit` which enables RTTI testing. + */ + struct _base_unit_t {}; + } + /** @endcond */ // END DOXYGEN IGNORE + + namespace traits + { + /** + * @ingroup TypeTraits + * @brief Trait which tests if a class is a `base_unit` type. + * @details Inherits from `std::true_type` or `std::false_type`. Use `is_base_unit::value` to test + * whether `class T` implements a `base_unit`. + */ + template + struct is_base_unit : std::is_base_of {}; + } + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief helper type to identify units. + * @details A non-templated base class for `unit` which enables RTTI testing. + */ + struct _unit {}; + + template + using meter_ratio = std::ratio; + } + /** @endcond */ // END DOXYGEN IGNORE + + namespace traits + { + /** + * @ingroup TypeTraits + * @brief Traits which tests if a class is a `unit` + * @details Inherits from `std::true_type` or `std::false_type`. Use `is_unit::value` to test + * whether `class T` implements a `unit`. + */ + template + struct is_unit : std::is_base_of::type {}; + } + + /** @} */ // end of TypeTraits + + //------------------------------ + // BASE UNIT CLASS + //------------------------------ + + /** + * @ingroup UnitTypes + * @brief Class representing SI base unit types. + * @details Base units are represented by a combination of `std::ratio` template parameters, each + * describing the exponent of the type of unit they represent. Example: meters per second + * would be described by a +1 exponent for meters, and a -1 exponent for seconds, thus: + * `base_unit, std::ratio<0>, std::ratio<-1>>` + * @tparam Meter `std::ratio` representing the exponent value for meters. + * @tparam Kilogram `std::ratio` representing the exponent value for kilograms. + * @tparam Second `std::ratio` representing the exponent value for seconds. + * @tparam Radian `std::ratio` representing the exponent value for radians. Although radians are not SI base units, they are included because radians are described by the SI as m * m^-1, which would make them indistinguishable from scalars. + * @tparam Ampere `std::ratio` representing the exponent value for amperes. + * @tparam Kelvin `std::ratio` representing the exponent value for Kelvin. + * @tparam Mole `std::ratio` representing the exponent value for moles. + * @tparam Candela `std::ratio` representing the exponent value for candelas. + * @tparam Byte `std::ratio` representing the exponent value for bytes. + * @sa category for type aliases for SI base_unit types. + */ + template, + class Kilogram = std::ratio<0>, + class Second = std::ratio<0>, + class Radian = std::ratio<0>, + class Ampere = std::ratio<0>, + class Kelvin = std::ratio<0>, + class Mole = std::ratio<0>, + class Candela = std::ratio<0>, + class Byte = std::ratio<0>> + struct base_unit : units::detail::_base_unit_t + { + static_assert(traits::is_ratio::value, "Template parameter `Meter` must be a `std::ratio` representing the exponent of meters the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Kilogram` must be a `std::ratio` representing the exponent of kilograms the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Second` must be a `std::ratio` representing the exponent of seconds the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Ampere` must be a `std::ratio` representing the exponent of amperes the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Kelvin` must be a `std::ratio` representing the exponent of kelvin the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Candela` must be a `std::ratio` representing the exponent of candelas the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Mole` must be a `std::ratio` representing the exponent of moles the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Radian` must be a `std::ratio` representing the exponent of radians the unit has"); + static_assert(traits::is_ratio::value, "Template parameter `Byte` must be a `std::ratio` representing the exponent of bytes the unit has"); + + typedef Meter meter_ratio; + typedef Kilogram kilogram_ratio; + typedef Second second_ratio; + typedef Radian radian_ratio; + typedef Ampere ampere_ratio; + typedef Kelvin kelvin_ratio; + typedef Mole mole_ratio; + typedef Candela candela_ratio; + typedef Byte byte_ratio; + }; + + //------------------------------ + // UNIT CATEGORIES + //------------------------------ + + /** + * @brief namespace representing the implemented base and derived unit types. These will not generally be needed by library users. + * @sa base_unit for the definition of the category parameters. + */ + namespace category + { + // SCALAR (DIMENSIONLESS) TYPES + typedef base_unit<> scalar_unit; ///< Represents a quantity with no dimension. + typedef base_unit<> dimensionless_unit; ///< Represents a quantity with no dimension. + + // SI BASE UNIT TYPES + // METERS KILOGRAMS SECONDS RADIANS AMPERES KELVIN MOLE CANDELA BYTE --- CATEGORY + typedef base_unit> length_unit; ///< Represents an SI base unit of length + typedef base_unit, std::ratio<1>> mass_unit; ///< Represents an SI base unit of mass + typedef base_unit, std::ratio<0>, std::ratio<1>> time_unit; ///< Represents an SI base unit of time + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<1>> angle_unit; ///< Represents an SI base unit of angle + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> current_unit; ///< Represents an SI base unit of current + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> temperature_unit; ///< Represents an SI base unit of temperature + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> substance_unit; ///< Represents an SI base unit of amount of substance + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> luminous_intensity_unit; ///< Represents an SI base unit of luminous intensity + + // SI DERIVED UNIT TYPES + // METERS KILOGRAMS SECONDS RADIANS AMPERES KELVIN MOLE CANDELA BYTE --- CATEGORY + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<2>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>> solid_angle_unit; ///< Represents an SI derived unit of solid angle + typedef base_unit, std::ratio<0>, std::ratio<-1>> frequency_unit; ///< Represents an SI derived unit of frequency + typedef base_unit, std::ratio<0>, std::ratio<-1>> velocity_unit; ///< Represents an SI derived unit of velocity + typedef base_unit, std::ratio<0>, std::ratio<-1>, std::ratio<1>> angular_velocity_unit; ///< Represents an SI derived unit of angular velocity + typedef base_unit, std::ratio<0>, std::ratio<-2>> acceleration_unit; ///< Represents an SI derived unit of acceleration + typedef base_unit, std::ratio<1>, std::ratio<-2>> force_unit; ///< Represents an SI derived unit of force + typedef base_unit, std::ratio<1>, std::ratio<-2>> pressure_unit; ///< Represents an SI derived unit of pressure + typedef base_unit, std::ratio<0>, std::ratio<1>, std::ratio<0>, std::ratio<1>> charge_unit; ///< Represents an SI derived unit of charge + typedef base_unit, std::ratio<1>, std::ratio<-2>> energy_unit; ///< Represents an SI derived unit of energy + typedef base_unit, std::ratio<1>, std::ratio<-3>> power_unit; ///< Represents an SI derived unit of power + typedef base_unit, std::ratio<1>, std::ratio<-3>, std::ratio<0>, std::ratio<-1>> voltage_unit; ///< Represents an SI derived unit of voltage + typedef base_unit, std::ratio<-1>, std::ratio<4>, std::ratio<0>, std::ratio<2>> capacitance_unit; ///< Represents an SI derived unit of capacitance + typedef base_unit, std::ratio<1>, std::ratio<-3>, std::ratio<0>, std::ratio<-2>> impedance_unit; ///< Represents an SI derived unit of impedance + typedef base_unit, std::ratio<-1>, std::ratio<3>, std::ratio<0>, std::ratio<2>> conductance_unit; ///< Represents an SI derived unit of conductance + typedef base_unit, std::ratio<1>, std::ratio<-2>, std::ratio<0>, std::ratio<-1>> magnetic_flux_unit; ///< Represents an SI derived unit of magnetic flux + typedef base_unit, std::ratio<1>, std::ratio<-2>, std::ratio<0>, std::ratio<-1>> magnetic_field_strength_unit; ///< Represents an SI derived unit of magnetic field strength + typedef base_unit, std::ratio<1>, std::ratio<-2>, std::ratio<0>, std::ratio<-2>> inductance_unit; ///< Represents an SI derived unit of inductance + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<2>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> luminous_flux_unit; ///< Represents an SI derived unit of luminous flux + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<2>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> illuminance_unit; ///< Represents an SI derived unit of illuminance + typedef base_unit, std::ratio<0>, std::ratio<-1>> radioactivity_unit; ///< Represents an SI derived unit of radioactivity + + // OTHER UNIT TYPES + // METERS KILOGRAMS SECONDS RADIANS AMPERES KELVIN MOLE CANDELA BYTE --- CATEGORY + typedef base_unit, std::ratio<1>, std::ratio<-2>> torque_unit; ///< Represents an SI derived unit of torque + typedef base_unit> area_unit; ///< Represents an SI derived unit of area + typedef base_unit> volume_unit; ///< Represents an SI derived unit of volume + typedef base_unit, std::ratio<1>> density_unit; ///< Represents an SI derived unit of density + typedef base_unit<> concentration_unit; ///< Represents a unit of concentration + typedef base_unit, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> data_unit; ///< Represents a unit of data size + typedef base_unit, std::ratio<0>, std::ratio<-1>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>> data_transfer_rate_unit; ///< Represents a unit of data transfer rate + } + + //------------------------------ + // UNIT CLASSES + //------------------------------ + + /** @cond */ // DOXYGEN IGNORE + /** + * @brief unit type template specialization for units derived from base units. + */ + template struct unit; + template + struct unit, PiExponent, Translation> : units::detail::_unit + { + static_assert(traits::is_ratio::value, "Template parameter `Conversion` must be a `std::ratio` representing the conversion factor to `BaseUnit`."); + static_assert(traits::is_ratio::value, "Template parameter `PiExponent` must be a `std::ratio` representing the exponents of Pi the unit has."); + static_assert(traits::is_ratio::value, "Template parameter `Translation` must be a `std::ratio` representing an additive translation required by the unit conversion."); + + typedef typename units::base_unit base_unit_type; + typedef Conversion conversion_ratio; + typedef Translation translation_ratio; + typedef PiExponent pi_exponent_ratio; + }; + /** @endcond */ // END DOXYGEN IGNORE + + /** + * @brief Type representing an arbitrary unit. + * @ingroup UnitTypes + * @details `unit` types are used as tags for the `conversion` function. They are *not* containers + * (see `unit_t` for a container class). Each unit is defined by: + * + * - A `std::ratio` defining the conversion factor to the base unit type. (e.g. `std::ratio<1,12>` for inches to feet) + * - A base unit that the unit is derived from (or a unit category. Must be of type `unit` or `base_unit`) + * - An exponent representing factors of PI required by the conversion. (e.g. `std::ratio<-1>` for a radians to degrees conversion) + * - a ratio representing a datum translation required for the conversion (e.g. `std::ratio<32>` for a farenheit to celsius conversion) + * + * Typically, a specific unit, like `meters`, would be implemented as a type alias + * of `unit`, i.e. `using meters = unit, units::category::length_unit`, or + * `using inches = unit, feet>`. + * @tparam Conversion std::ratio representing scalar multiplication factor. + * @tparam BaseUnit Unit type which this unit is derived from. May be a `base_unit`, or another `unit`. + * @tparam PiExponent std::ratio representing the exponent of pi required by the conversion. + * @tparam Translation std::ratio representing any datum translation required by the conversion. + */ + template, class Translation = std::ratio<0>> + struct unit : units::detail::_unit + { + static_assert(traits::is_unit::value, "Template parameter `BaseUnit` must be a `unit` type."); + static_assert(traits::is_ratio::value, "Template parameter `Conversion` must be a `std::ratio` representing the conversion factor to `BaseUnit`."); + static_assert(traits::is_ratio::value, "Template parameter `PiExponent` must be a `std::ratio` representing the exponents of Pi the unit has."); + + typedef typename units::traits::unit_traits::base_unit_type base_unit_type; + typedef typename std::ratio_multiply conversion_ratio; + typedef typename std::ratio_add pi_exponent_ratio; + typedef typename std::ratio_add, typename BaseUnit::translation_ratio> translation_ratio; + }; + + //------------------------------ + // BASE UNIT MANIPULATORS + //------------------------------ + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief base_unit_of trait implementation + * @details recursively seeks base_unit type that a unit is derived from. Since units can be + * derived from other units, the `base_unit_type` typedef may not represent this value. + */ + template struct base_unit_of_impl; + template + struct base_unit_of_impl> : base_unit_of_impl {}; + template + struct base_unit_of_impl> + { + typedef base_unit type; + }; + template<> + struct base_unit_of_impl + { + typedef void type; + }; + } + /** @endcond */ // END DOXYGEN IGNORE + + namespace traits + { + /** + * @brief Trait which returns the `base_unit` type that a unit is originally derived from. + * @details Since units can be derived from other `unit` types in addition to `base_unit` types, + * the `base_unit_type` typedef will not always be a `base_unit` (or unit category). + * Since compatible + */ + template + using base_unit_of = typename units::detail::base_unit_of_impl::type; + } + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief implementation of base_unit_multiply + * @details 'multiples' (adds exponent ratios of) two base unit types. Base units can be found + * using `base_unit_of`. + */ + template struct base_unit_multiply_impl; + template + struct base_unit_multiply_impl, base_unit> { + using type = base_unit...>; + }; + + /** + * @brief represents type of two base units multiplied together + */ + template + using base_unit_multiply = typename base_unit_multiply_impl::type; + + /** + * @brief implementation of base_unit_divide + * @details 'dived' (subtracts exponent ratios of) two base unit types. Base units can be found + * using `base_unit_of`. + */ + template struct base_unit_divide_impl; + template + struct base_unit_divide_impl, base_unit> { + using type = base_unit...>; + }; + + /** + * @brief represents the resulting type of `base_unit` U1 divided by U2. + */ + template + using base_unit_divide = typename base_unit_divide_impl::type; + + /** + * @brief implementation of inverse_base + * @details multiplies all `base_unit` exponent ratios by -1. The resulting type represents + * the inverse base unit of the given `base_unit` type. + */ + template struct inverse_base_impl; + + template + struct inverse_base_impl> { + using type = base_unit>...>; + }; + + /** + * @brief represent the inverse type of `class U` + * @details E.g. if `U` is `length_unit`, then `inverse` will represent `length_unit^-1`. + */ + template using inverse_base = typename inverse_base_impl::type; + + /** + * @brief implementation of `squared_base` + * @details multiplies all the exponent ratios of the given class by 2. The resulting type is + * equivalent to the given type squared. + */ + template struct squared_base_impl; + template + struct squared_base_impl> { + using type = base_unit>...>; + }; + + /** + * @brief represents the type of a `base_unit` squared. + * @details E.g. `squared` will represent `length_unit^2`. + */ + template using squared_base = typename squared_base_impl::type; + + /** + * @brief implementation of `cubed_base` + * @details multiplies all the exponent ratios of the given class by 3. The resulting type is + * equivalent to the given type cubed. + */ + template struct cubed_base_impl; + template + struct cubed_base_impl> { + using type = base_unit>...>; + }; + + /** + * @brief represents the type of a `base_unit` cubed. + * @details E.g. `cubed` will represent `length_unit^3`. + */ + template using cubed_base = typename cubed_base_impl::type; + + /** + * @brief implementation of `sqrt_base` + * @details divides all the exponent ratios of the given class by 2. The resulting type is + * equivalent to the square root of the given type. + */ + template struct sqrt_base_impl; + template + struct sqrt_base_impl> { + using type = base_unit>...>; + }; + + /** + * @brief represents the square-root type of a `base_unit`. + * @details E.g. `sqrt` will represent `length_unit^(1/2)`. + */ + template using sqrt_base = typename sqrt_base_impl::type; + + /** + * @brief implementation of `cbrt_base` + * @details divides all the exponent ratios of the given class by 3. The resulting type is + * equivalent to the given type's cube-root. + */ + template struct cbrt_base_impl; + template + struct cbrt_base_impl> { + using type = base_unit>...>; + }; + + /** + * @brief represents the cube-root type of a `base_unit` . + * @details E.g. `cbrt` will represent `length_unit^(1/3)`. + */ + template using cbrt_base = typename cbrt_base_impl::type; + } + /** @endcond */ // END DOXYGEN IGNORE + + //------------------------------ + // UNIT MANIPULATORS + //------------------------------ + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief implementation of `unit_multiply`. + * @details multiplies two units. The base unit becomes the base units of each with their exponents + * added together. The conversion factors of each are multiplied by each other. Pi exponent ratios + * are added, and datum translations are removed. + */ + template + struct unit_multiply_impl + { + using type = unit < std::ratio_multiply, + base_unit_multiply , traits::base_unit_of>, + std::ratio_add, + std::ratio < 0 >> ; + }; + + /** + * @brief represents the type of two units multiplied together. + * @details recalculates conversion and exponent ratios at compile-time. + */ + template + using unit_multiply = typename unit_multiply_impl::type; + + /** + * @brief implementation of `unit_divide`. + * @details divides two units. The base unit becomes the base units of each with their exponents + * subtracted from each other. The conversion factors of each are divided by each other. Pi exponent ratios + * are subtracted, and datum translations are removed. + */ + template + struct unit_divide_impl + { + using type = unit < std::ratio_divide, + base_unit_divide, traits::base_unit_of>, + std::ratio_subtract, + std::ratio < 0 >> ; + }; + + /** + * @brief represents the type of two units divided by each other. + * @details recalculates conversion and exponent ratios at compile-time. + */ + template + using unit_divide = typename unit_divide_impl::type; + + /** + * @brief implementation of `inverse` + * @details inverts a unit (equivalent to 1/unit). The `base_unit` and pi exponents are all multiplied by + * -1. The conversion ratio numerator and denominator are swapped. Datum translation + * ratios are removed. + */ + template + struct inverse_impl + { + using type = unit < std::ratio, + inverse_base::base_unit_type>>, + std::ratio_multiply::pi_exponent_ratio, std::ratio<-1>>, + std::ratio < 0 >> ; // inverses are rates or change, the translation factor goes away. + }; + } + /** @endcond */ // END DOXYGEN IGNORE + + /** + * @brief represents the inverse unit type of `class U`. + * @ingroup UnitManipulators + * @tparam U `unit` type to invert. + * @details E.g. `inverse` will represent meters^-1 (i.e. 1/meters). + */ + template using inverse = typename units::detail::inverse_impl::type; + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief implementation of `squared` + * @details Squares the conversion ratio, `base_unit` exponents, pi exponents, and removes + * datum translation ratios. + */ + template + struct squared_impl + { + static_assert(traits::is_unit::value, "Template parameter `Unit` must be a `unit` type."); + using Conversion = typename Unit::conversion_ratio; + using type = unit < std::ratio_multiply, + squared_base>, + std::ratio_multiply>, + typename Unit::translation_ratio + > ; + }; + } + /** @endcond */ // END DOXYGEN IGNORE + + /** + * @brief represents the unit type of `class U` squared + * @ingroup UnitManipulators + * @tparam U `unit` type to square. + * @details E.g. `square` will represent meters^2. + */ + template + using squared = typename units::detail::squared_impl::type; + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + /** + * @brief implementation of `cubed` + * @details Cubes the conversion ratio, `base_unit` exponents, pi exponents, and removes + * datum translation ratios. + */ + template + struct cubed_impl + { + static_assert(traits::is_unit::value, "Template parameter `Unit` must be a `unit` type."); + using Conversion = typename Unit::conversion_ratio; + using type = unit < std::ratio_multiply>, + cubed_base>, + std::ratio_multiply>, + typename Unit::translation_ratio> ; + }; + } + /** @endcond */ // END DOXYGEN IGNORE + + /** + * @brief represents the type of `class U` cubed. + * @ingroup UnitManipulators + * @tparam U `unit` type to cube. + * @details E.g. `cubed` will represent meters^3. + */ + template + using cubed = typename units::detail::cubed_impl::type; + + /** @cond */ // DOXYGEN IGNORE + namespace detail + { + //---------------------------------- + // RATIO_SQRT IMPLEMENTATION + //---------------------------------- + + using Zero = std::ratio<0>; + using One = std::ratio<1>; + template using Square = std::ratio_multiply; + + // Find the largest std::integer N such that Predicate::value is true. + template