diff --git a/cameraserver/.styleguide b/cameraserver/.styleguide index 899d9c2de3..e503ae31e3 100644 --- a/cameraserver/.styleguide +++ b/cameraserver/.styleguide @@ -16,7 +16,7 @@ repoRootNameOverride { } includeOtherLibs { - ^HAL/ + ^hal/ ^networktables/ ^opencv2/ ^support/ diff --git a/wpilibNewCommands/.styleguide b/wpilibNewCommands/.styleguide index e75c28ca6c..a71befd590 100644 --- a/wpilibNewCommands/.styleguide +++ b/wpilibNewCommands/.styleguide @@ -1,8 +1,42 @@ -includeOtherLibs { - ^HAL/ - ^networktables/ - ^frc/ - ^units/ - ^wpi/ - ^frc2/Timer +cppHeaderFileInclude { + \.h$ + \.hpp$ + \.inc$ +} + +cppSrcFileInclude { + \.cpp$ +} + +generatedFileExclude { + gtest/ + ni-libraries/include/ + ni-libraries/lib/ + FRCNetComm\.java$ + simulation/frc_gazebo_plugins/frcgazebo/ + simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$ +} + +modifiableFileExclude { + \.so$ +} + +repoRootNameOverride { + wpilib +} + +includeOtherLibs { + ^cameraserver/ + ^cscore + ^frc/ + ^hal/ + ^imgui + ^mockdata/ + ^networktables/ + ^ntcore + ^opencv2/ + ^support/ + ^units/ + ^vision/ + ^wpi/ } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp index 8d92367a8f..83c97216ba 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp @@ -48,21 +48,23 @@ ParallelRaceGroup Command::WithInterrupt(std::function condition) && { return ParallelRaceGroup(std::move(temp)); } -SequentialCommandGroup Command::BeforeStarting(std::function toRun, - std::initializer_list requirements) && { +SequentialCommandGroup Command::BeforeStarting( + std::function toRun, + std::initializer_list requirements) && { std::vector> temp; - temp.emplace_back(std::make_unique( - std::move(toRun), requirements)); + temp.emplace_back( + std::make_unique(std::move(toRun), requirements)); temp.emplace_back(std::move(*this).TransferOwnership()); return SequentialCommandGroup(std::move(temp)); } -SequentialCommandGroup Command::AndThen(std::function toRun, - std::initializer_list requirements) && { +SequentialCommandGroup Command::AndThen( + std::function toRun, + std::initializer_list requirements) && { std::vector> temp; temp.emplace_back(std::move(*this).TransferOwnership()); - temp.emplace_back(std::make_unique( - std::move(toRun), requirements)); + temp.emplace_back( + std::make_unique(std::move(toRun), requirements)); return SequentialCommandGroup(std::move(temp)); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp index 9ac69b8704..84d0820552 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp @@ -7,11 +7,11 @@ #include "frc2/command/CommandScheduler.h" -#include #include #include #include #include +#include #include #include diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/FunctionalCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/FunctionalCommand.cpp index f0e178f888..ef7c40a22c 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/FunctionalCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/FunctionalCommand.cpp @@ -9,11 +9,10 @@ using namespace frc2; -FunctionalCommand::FunctionalCommand(std::function onInit, - std::function onExecute, - std::function onEnd, - std::function isFinished, - std::initializer_list requirements) +FunctionalCommand::FunctionalCommand( + std::function onInit, std::function onExecute, + std::function onEnd, std::function isFinished, + std::initializer_list requirements) : m_onInit{std::move(onInit)}, m_onExecute{std::move(onExecute)}, m_onEnd{std::move(onEnd)}, diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp index 54a4cc33b1..261896f274 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp @@ -70,18 +70,18 @@ void RamseteCommand::Execute() { m_controller.Calculate(m_pose(), m_trajectory.Sample(curTime))); if (m_usePID) { - auto leftFeedforward = - m_feedforward.Calculate(targetWheelSpeeds.left, - (targetWheelSpeeds.left - m_prevSpeeds.left) / dt); + auto leftFeedforward = m_feedforward.Calculate( + targetWheelSpeeds.left, + (targetWheelSpeeds.left - m_prevSpeeds.left) / dt); - auto rightFeedforward = - m_feedforward.Calculate(targetWheelSpeeds.right, - (targetWheelSpeeds.right - m_prevSpeeds.right) / dt); + auto rightFeedforward = m_feedforward.Calculate( + targetWheelSpeeds.right, + (targetWheelSpeeds.right - m_prevSpeeds.right) / dt); - auto leftOutput = - volt_t(m_leftController->Calculate( - m_speeds().left.to(), targetWheelSpeeds.left.to())) + - leftFeedforward; + auto leftOutput = volt_t(m_leftController->Calculate( + m_speeds().left.to(), + targetWheelSpeeds.left.to())) + + leftFeedforward; auto rightOutput = volt_t(m_rightController->Calculate( m_speeds().right.to(), diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp index 8479581351..739a049865 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp @@ -7,7 +7,7 @@ #include "frc2/command/WaitUntilCommand.h" -#include +#include "frc2/Timer.h" using namespace frc2; diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp index aec118324f..caf188ee0b 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp @@ -7,7 +7,7 @@ #include "frc2/command/button/Trigger.h" -#include +#include "frc2/command/InstantCommand.h" using namespace frc2; @@ -49,8 +49,9 @@ Trigger Trigger::WhileActiveContinous(Command* command, bool interruptible) { return *this; } -Trigger Trigger::WhileActiveContinous(std::function toRun, - std::initializer_list requirements) { +Trigger Trigger::WhileActiveContinous( + std::function toRun, + std::initializer_list requirements) { return WhileActiveContinous(InstantCommand(std::move(toRun), requirements)); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index b0a57a9a8b..4695c2655e 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -130,8 +130,9 @@ class Command : public frc::ErrorBase { * @param requirements the required subsystems * @return the decorated command */ - SequentialCommandGroup BeforeStarting(std::function toRun, - std::initializer_list requirements = {}) &&; + SequentialCommandGroup BeforeStarting( + std::function toRun, + std::initializer_list requirements = {}) &&; /** * Decorates this command with a runnable to run after the command finishes. @@ -140,8 +141,9 @@ class Command : public frc::ErrorBase { * @param requirements the required subsystems * @return the decorated command */ - SequentialCommandGroup AndThen(std::function toRun, - std::initializer_list requirements = {}) &&; + SequentialCommandGroup AndThen( + std::function toRun, + std::initializer_list requirements = {}) &&; /** * Decorates this command to run perpetually, ignoring its ordinary end diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h index 3955ba9c6c..86cfe0d59e 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDCommand.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -50,10 +51,10 @@ class ProfiledPIDCommand std::function goalSource, std::function useOutput, std::initializer_list requirements = {}) - : m_controller{controller}, - m_measurement{std::move(measurementSource)}, - m_goal{std::move(goalSource)}, - m_useOutput{std::move(useOutput)} { + : m_controller{controller}, + m_measurement{std::move(measurementSource)}, + m_goal{std::move(goalSource)}, + m_useOutput{std::move(useOutput)} { AddRequirements(requirements); } @@ -72,11 +73,11 @@ class ProfiledPIDCommand std::function> goalSource, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, - [&goalSource]() { - return State{goalSource(), 0_mps}; - }, - useOutput, requirements) {} + : ProfiledPIDCommand(controller, measurementSource, + [&goalSource]() { + return State{goalSource(), 0_mps}; + }, + useOutput, requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -92,8 +93,8 @@ class ProfiledPIDCommand std::function> measurementSource, State goal, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, [goal] { return goal; }, - useOutput, requirements) {} + : ProfiledPIDCommand(controller, measurementSource, + [goal] { return goal; }, useOutput, requirements) {} /** * Creates a new PIDCommand, which controls the given output with a @@ -110,8 +111,8 @@ class ProfiledPIDCommand units::meter_t goal, std::function useOutput, std::initializer_list requirements) - : ProfiledPIDCommand(controller, measurementSource, [goal] { return goal; }, - useOutput, requirements) {} + : ProfiledPIDCommand(controller, measurementSource, + [goal] { return goal; }, useOutput, requirements) {} ProfiledPIDCommand(ProfiledPIDCommand&& other) = default; @@ -133,9 +134,7 @@ class ProfiledPIDCommand * * @return The ProfiledPIDController */ - frc::ProfiledPIDController& GetController() { - return m_controller; - } + frc::ProfiledPIDController& GetController() { return m_controller; } protected: frc::ProfiledPIDController m_controller; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h index 757668bedf..55c9f90af9 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/ProfiledPIDSubsystem.h @@ -34,7 +34,7 @@ class ProfiledPIDSubsystem : public SubsystemBase { * @param controller the ProfiledPIDController to use */ explicit ProfiledPIDSubsystem(frc::ProfiledPIDController controller) - : m_controller{controller} {} + : m_controller{controller} {} void Periodic() override { if (m_enabled) { @@ -79,18 +79,16 @@ class ProfiledPIDSubsystem : public SubsystemBase { * Disables the PID control. Sets output to zero. */ virtual void Disable() { - UseOutput(0, State{Distance_t(0), Velocity_t(0)}); - m_enabled = false; - } + UseOutput(0, State{Distance_t(0), Velocity_t(0)}); + m_enabled = false; + } /** * Returns the ProfiledPIDController. * * @return The controller. */ - frc::ProfiledPIDController& GetController() { - return m_controller; - } + frc::ProfiledPIDController& GetController() { return m_controller; } protected: frc::ProfiledPIDController m_controller; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h index e38c14ad1c..c412bb4c17 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/RamseteCommand.h @@ -17,9 +17,9 @@ #include #include #include -#include #include +#include "frc2/Timer.h" #include "frc2/command/CommandBase.h" #include "frc2/command/CommandHelper.h" @@ -42,7 +42,6 @@ namespace frc2 { * @see Trajectory */ class RamseteCommand : public CommandHelper { - public: /** * Constructs a new RamseteCommand that, when executed, will follow the @@ -58,7 +57,8 @@ class RamseteCommand : public CommandHelper { * the odometry classes to provide this. * @param controller The RAMSETE controller used to follow the * trajectory. - * @param feedforward A component for calculating the feedforward for the drive. + * @param feedforward A component for calculating the feedforward for the + * drive. * @param kinematics The kinematics for the robot drivetrain. * @param wheelSpeeds A function that supplies the speeds of the left * and right sides of the robot drive. diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h index a5d3b56ef8..e1074f44d4 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h @@ -13,9 +13,9 @@ #endif #include +#include #include #include -#include #include #include "frc2/command/CommandBase.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h index 38b904d88e..8d71c7ef73 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h @@ -11,8 +11,8 @@ #include #include -#include +#include "frc2/Timer.h" #include "frc2/command/CommandBase.h" #include "frc2/command/CommandHelper.h" @@ -31,6 +31,7 @@ class TrapezoidProfileCommand units::compound_unit>; using Velocity_t = units::unit_t; using State = typename frc::TrapezoidProfile::State; + public: /** * Creates a new TrapezoidProfileCommand that will execute the given @@ -39,10 +40,9 @@ class TrapezoidProfileCommand * @param profile The motion profile to execute. * @param output The consumer for the profile output. */ - TrapezoidProfileCommand( - frc::TrapezoidProfile profile, - std::function output, - std::initializer_list requirements) + TrapezoidProfileCommand(frc::TrapezoidProfile profile, + std::function output, + std::initializer_list requirements) : m_profile(profile), m_output(output) { AddRequirements(requirements); } @@ -52,9 +52,7 @@ class TrapezoidProfileCommand m_timer.Start(); } - void Execute() override { - m_output(m_profile.Calculate(m_timer.Get())); - } + void Execute() override { m_output(m_profile.Calculate(m_timer.Get())); } void End(bool interrupted) override { m_timer.Stop(); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h index 92837b6fa7..cd04fd74e3 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileSubsystem.h @@ -7,15 +7,16 @@ #pragma once -#include "frc2/command/SubsystemBase.h" -#include "frc/trajectory/TrapezoidProfile.h" - +#include #include +#include "frc2/command/SubsystemBase.h" + namespace frc2 { /** - * A subsystem that generates and runs trapezoidal motion profiles automatically. The user - * specifies how to use the current state of the motion profile by overriding the `UseState` method. + * A subsystem that generates and runs trapezoidal motion profiles + * automatically. The user specifies how to use the current state of the motion + * profile by overriding the `UseState` method. */ template class TrapezoidProfileSubsystem : public SubsystemBase { @@ -25,39 +26,42 @@ class TrapezoidProfileSubsystem : public SubsystemBase { using Velocity_t = units::unit_t; using State = typename frc::TrapezoidProfile::State; using Constraints = typename frc::TrapezoidProfile::Constraints; + public: /** * Creates a new TrapezoidProfileSubsystem. * - * @param constraints The constraints (maximum velocity and acceleration) for the profiles. - * @param initialPosition The initial position of the controller mechanism when the subsystem - * is constructed. + * @param constraints The constraints (maximum velocity and acceleration) + * for the profiles. + * @param initialPosition The initial position of the controller mechanism + * when the subsystem is constructed. * @param period The period of the main robot loop, in seconds. */ - TrapezoidProfileSubsystem(Constraints constraints, - Distance_t position, + TrapezoidProfileSubsystem(Constraints constraints, Distance_t position, units::second_t period = 20_ms) - : m_constraints(constraints), - m_state{position, Velocity_t(0)}, - m_period(period) {} + : m_constraints(constraints), + m_state{position, Velocity_t(0)}, + m_period(period) {} void Periodic() override { - auto profile = frc::TrapezoidProfile(m_constraints, GetGoal(), m_state); + auto profile = + frc::TrapezoidProfile(m_constraints, GetGoal(), m_state); m_state = profile.Calculate(m_period); UseState(m_state); } /** - * Users should override this to return the goal state for the subsystem's motion profile. + * Users should override this to return the goal state for the subsystem's + * motion profile. * * @return The goal state for the subsystem's motion profile. */ virtual State GetGoal() = 0; protected: - /** - * Users should override this to consume the current state of the motion profile. + * Users should override this to consume the current state of the motion + * profile. * * @param state The current state of the motion profile. */ @@ -68,4 +72,4 @@ class TrapezoidProfileSubsystem : public SubsystemBase { State m_state; units::second_t m_period; }; -} +} // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h index 412647659b..ab97958acc 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/WaitCommand.h @@ -7,9 +7,9 @@ #pragma once -#include #include +#include "frc2/Timer.h" #include "frc2/command/CommandBase.h" #include "frc2/command/CommandHelper.h" diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h index 7e32d0dd9a..efc4bc0263 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h @@ -7,13 +7,13 @@ #pragma once -#include -#include - #include #include #include +#include "frc2/command/Command.h" +#include "frc2/command/CommandScheduler.h" + namespace frc2 { class Command; /** @@ -149,8 +149,9 @@ class Trigger { * @param toRun the runnable to execute. * @param requirements the required subsystems. */ - Trigger WhileActiveContinous(std::function toRun, - std::initializer_list requirements = {}); + Trigger WhileActiveContinous( + std::function toRun, + std::initializer_list requirements = {}); /** * Binds a command to be started when the trigger becomes active, and diff --git a/wpilibcExamples/.styleguide b/wpilibcExamples/.styleguide index a6925d1a9f..38c02ccb5c 100644 --- a/wpilibcExamples/.styleguide +++ b/wpilibcExamples/.styleguide @@ -9,11 +9,11 @@ cppSrcFileInclude { } includeOtherLibs { - ^HAL/ ^cameraserver/ ^cscore ^frc/ ^frc2/ + ^hal/ ^networktables/ ^ntcore ^opencv2/ diff --git a/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c b/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c index dedb0f2b98..ae5833ec79 100644 --- a/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c +++ b/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -18,7 +18,7 @@ that want even more control over what code runs on their robot. #include -#include "hal/HAL.h" +#include enum DriverStationMode { DisabledMode, diff --git a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp index 1a856c1e78..de8fc3e071 100644 --- a/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/robotbaseskeleton/cpp/Robot.cpp @@ -7,11 +7,10 @@ #include "Robot.h" -#include - #include #include #include +#include #include void Robot::RobotInit() {}