gitattributes: Mark C++ source files as text (#6210)

Some C++ files had been checked in with CRLF line endings.
This fixes those and also fixes future commits.
This commit is contained in:
Tyler Veness
2024-01-12 10:53:56 -08:00
committed by GitHub
parent 1981b8debd
commit 67e8306819
14 changed files with 6229 additions and 6226 deletions

3
.gitattributes vendored
View File

@@ -1,4 +1,7 @@
*.cpp text
*.gradle text eol=lf
*.h text
*.inc text
*.java text eol=lf
*.json text eol=lf
*.md text eol=lf

View File

@@ -1,25 +1,25 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <string_view>
void Application(std::string_view saveDir);
#ifdef _WIN32
int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* pCmdLine,
int nCmdShow) {
int argc = __argc;
char** argv = __argv;
#else
int main(int argc, char** argv) {
#endif
std::string_view saveDir;
if (argc == 2) {
saveDir = argv[1];
}
Application(saveDir);
return 0;
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <string_view>
void Application(std::string_view saveDir);
#ifdef _WIN32
int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* pCmdLine,
int nCmdShow) {
int argc = __argc;
char** argv = __argv;
#else
int main(int argc, char** argv) {
#endif
std::string_view saveDir;
if (argc == 2) {
saveDir = argv[1];
}
Application(saveDir);
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +1,25 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <string_view>
void Application(std::string_view saveDir);
#ifdef _WIN32
int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* pCmdLine,
int nCmdShow) {
int argc = __argc;
char** argv = __argv;
#else
int main(int argc, char** argv) {
#endif
std::string_view saveDir;
if (argc == 2) {
saveDir = argv[1];
}
Application(saveDir);
return 0;
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <string_view>
void Application(std::string_view saveDir);
#ifdef _WIN32
int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* pCmdLine,
int nCmdShow) {
int argc = __argc;
char** argv = __argv;
#else
int main(int argc, char** argv) {
#endif
std::string_view saveDir;
if (argc == 2) {
saveDir = argv[1];
}
Application(saveDir);
return 0;
}

View File

@@ -1,10 +1,10 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -1,64 +1,64 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc2/command/sysid/SysIdRoutine.h"
using namespace frc2::sysid;
frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
std::unordered_map<Direction, frc::sysid::State> stateOptions{
{Direction::kForward, frc::sysid::State::kQuasistaticForward},
{Direction::kReverse, frc::sysid::State::kQuasistaticReverse},
};
frc::sysid::State state = stateOptions[direction];
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
return m_mechanism.m_subsystem
->RunOnce([this] {
timer.Reset();
timer.Start();
})
.AndThen(
m_mechanism.m_subsystem
->Run([this, state, outputSign] {
m_outputVolts = outputSign * timer.Get() * m_config.m_rampRate;
m_mechanism.m_drive(m_outputVolts);
m_mechanism.m_log(this);
m_recordState(state);
})
.FinallyDo([this] {
m_mechanism.m_drive(0_V);
m_recordState(frc::sysid::State::kNone);
timer.Stop();
})
.WithName("sysid-" +
frc::sysid::SysIdRoutineLog::StateEnumToString(state) +
"-" + m_mechanism.m_name)
.WithTimeout(m_config.m_timeout));
}
frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
std::unordered_map<Direction, frc::sysid::State> stateOptions{
{Direction::kForward, frc::sysid::State::kDynamicForward},
{Direction::kReverse, frc::sysid::State::kDynamicReverse},
};
frc::sysid::State state = stateOptions[direction];
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
return m_mechanism.m_subsystem
->RunOnce([this] { m_outputVolts = m_config.m_stepVoltage; })
.AndThen(m_mechanism.m_subsystem->Run([this, state, outputSign] {
m_mechanism.m_drive(m_outputVolts * outputSign);
m_mechanism.m_log(this);
m_recordState(state);
}))
.FinallyDo([this] {
m_mechanism.m_drive(0_V);
m_recordState(frc::sysid::State::kNone);
})
.WithName("sysid-" +
frc::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
m_mechanism.m_name)
.WithTimeout(m_config.m_timeout);
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc2/command/sysid/SysIdRoutine.h"
using namespace frc2::sysid;
frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
std::unordered_map<Direction, frc::sysid::State> stateOptions{
{Direction::kForward, frc::sysid::State::kQuasistaticForward},
{Direction::kReverse, frc::sysid::State::kQuasistaticReverse},
};
frc::sysid::State state = stateOptions[direction];
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
return m_mechanism.m_subsystem
->RunOnce([this] {
timer.Reset();
timer.Start();
})
.AndThen(
m_mechanism.m_subsystem
->Run([this, state, outputSign] {
m_outputVolts = outputSign * timer.Get() * m_config.m_rampRate;
m_mechanism.m_drive(m_outputVolts);
m_mechanism.m_log(this);
m_recordState(state);
})
.FinallyDo([this] {
m_mechanism.m_drive(0_V);
m_recordState(frc::sysid::State::kNone);
timer.Stop();
})
.WithName("sysid-" +
frc::sysid::SysIdRoutineLog::StateEnumToString(state) +
"-" + m_mechanism.m_name)
.WithTimeout(m_config.m_timeout));
}
frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
std::unordered_map<Direction, frc::sysid::State> stateOptions{
{Direction::kForward, frc::sysid::State::kDynamicForward},
{Direction::kReverse, frc::sysid::State::kDynamicReverse},
};
frc::sysid::State state = stateOptions[direction];
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
return m_mechanism.m_subsystem
->RunOnce([this] { m_outputVolts = m_config.m_stepVoltage; })
.AndThen(m_mechanism.m_subsystem->Run([this, state, outputSign] {
m_mechanism.m_drive(m_outputVolts * outputSign);
m_mechanism.m_log(this);
m_recordState(state);
}))
.FinallyDo([this] {
m_mechanism.m_drive(0_V);
m_recordState(frc::sysid::State::kNone);
})
.WithName("sysid-" +
frc::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
m_mechanism.m_name)
.WithTimeout(m_config.m_timeout);
}

View File

@@ -1,24 +1,24 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "frc/Errors.h"
#include "frc/event/EventLoop.h"
using namespace frc;
TEST(EventLoopTest, ConcurrentModification) {
EventLoop loop;
loop.Bind([&loop] { ASSERT_THROW(loop.Bind([] {}), frc::RuntimeError); });
loop.Poll();
loop.Clear();
loop.Bind([&loop] { ASSERT_THROW(loop.Clear(), frc::RuntimeError); });
loop.Poll();
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "frc/Errors.h"
#include "frc/event/EventLoop.h"
using namespace frc;
TEST(EventLoopTest, ConcurrentModification) {
EventLoop loop;
loop.Bind([&loop] { ASSERT_THROW(loop.Bind([] {}), frc::RuntimeError); });
loop.Poll();
loop.Clear();
loop.Bind([&loop] { ASSERT_THROW(loop.Clear(), frc::RuntimeError); });
loop.Poll();
}

View File

@@ -1,55 +1,55 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "Robot.h"
#include <frc2/command/CommandScheduler.h>
void Robot::RobotInit() {}
void Robot::RobotPeriodic() {
frc2::CommandScheduler::GetInstance().Run();
}
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::DisabledExit() {}
void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();
if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
}
}
void Robot::AutonomousPeriodic() {}
void Robot::AutonomousExit() {}
void Robot::TeleopInit() {
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
}
}
void Robot::TeleopPeriodic() {}
void Robot::TeleopExit() {}
void Robot::TestInit() {
frc2::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
void Robot::TestExit() {}
#ifndef RUNNING_FRC_TESTS
int main() {
return frc::StartRobot<Robot>();
}
#endif
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "Robot.h"
#include <frc2/command/CommandScheduler.h>
void Robot::RobotInit() {}
void Robot::RobotPeriodic() {
frc2::CommandScheduler::GetInstance().Run();
}
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::DisabledExit() {}
void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();
if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
}
}
void Robot::AutonomousPeriodic() {}
void Robot::AutonomousExit() {}
void Robot::TeleopInit() {
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
}
}
void Robot::TeleopPeriodic() {}
void Robot::TeleopExit() {}
void Robot::TestInit() {
frc2::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
void Robot::TestExit() {}
#ifndef RUNNING_FRC_TESTS
int main() {
return frc::StartRobot<Robot>();
}
#endif

View File

@@ -1,30 +1,30 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "SysIdRoutineBot.h"
#include <frc2/command/Commands.h>
SysIdRoutineBot::SysIdRoutineBot() {
ConfigureBindings();
}
void SysIdRoutineBot::ConfigureBindings() {
m_drive.SetDefaultCommand(m_drive.ArcadeDriveCommand(
[this] { return -m_driverController.GetLeftY(); },
[this] { return -m_driverController.GetRightX(); }));
m_driverController.A().WhileTrue(
m_drive.SysIdQuasistatic(frc2::sysid::Direction::kForward));
m_driverController.B().WhileTrue(
m_drive.SysIdQuasistatic(frc2::sysid::Direction::kReverse));
m_driverController.X().WhileTrue(
m_drive.SysIdDynamic(frc2::sysid::Direction::kForward));
m_driverController.Y().WhileTrue(
m_drive.SysIdDynamic(frc2::sysid::Direction::kReverse));
}
frc2::CommandPtr SysIdRoutineBot::GetAutonomousCommand() {
return m_drive.Run([] {});
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "SysIdRoutineBot.h"
#include <frc2/command/Commands.h>
SysIdRoutineBot::SysIdRoutineBot() {
ConfigureBindings();
}
void SysIdRoutineBot::ConfigureBindings() {
m_drive.SetDefaultCommand(m_drive.ArcadeDriveCommand(
[this] { return -m_driverController.GetLeftY(); },
[this] { return -m_driverController.GetRightX(); }));
m_driverController.A().WhileTrue(
m_drive.SysIdQuasistatic(frc2::sysid::Direction::kForward));
m_driverController.B().WhileTrue(
m_drive.SysIdQuasistatic(frc2::sysid::Direction::kReverse));
m_driverController.X().WhileTrue(
m_drive.SysIdDynamic(frc2::sysid::Direction::kForward));
m_driverController.Y().WhileTrue(
m_drive.SysIdDynamic(frc2::sysid::Direction::kReverse));
}
frc2::CommandPtr SysIdRoutineBot::GetAutonomousCommand() {
return m_drive.Run([] {});
}

View File

@@ -1,37 +1,37 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "subsystems/Drive.h"
#include <frc2/command/Commands.h>
Drive::Drive() {
m_leftMotor.AddFollower(frc::PWMSparkMax{constants::drive::kLeftMotor2Port});
m_rightMotor.AddFollower(
frc::PWMSparkMax{constants::drive::kRightMotor2Port});
m_rightMotor.SetInverted(true);
m_leftEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
m_rightEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
m_drive.SetSafetyEnabled(false);
}
frc2::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
std::function<double()> rot) {
return frc2::cmd::Run([this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); },
{this})
.WithName("Arcade Drive");
}
frc2::CommandPtr Drive::SysIdQuasistatic(frc2::sysid::Direction direction) {
return m_sysIdRoutine.Quasistatic(direction);
}
frc2::CommandPtr Drive::SysIdDynamic(frc2::sysid::Direction direction) {
return m_sysIdRoutine.Dynamic(direction);
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "subsystems/Drive.h"
#include <frc2/command/Commands.h>
Drive::Drive() {
m_leftMotor.AddFollower(frc::PWMSparkMax{constants::drive::kLeftMotor2Port});
m_rightMotor.AddFollower(
frc::PWMSparkMax{constants::drive::kRightMotor2Port});
m_rightMotor.SetInverted(true);
m_leftEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
m_rightEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
m_drive.SetSafetyEnabled(false);
}
frc2::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
std::function<double()> rot) {
return frc2::cmd::Run([this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); },
{this})
.WithName("Arcade Drive");
}
frc2::CommandPtr Drive::SysIdQuasistatic(frc2::sysid::Direction direction) {
return m_sysIdRoutine.Quasistatic(direction);
}
frc2::CommandPtr Drive::SysIdDynamic(frc2::sysid::Direction direction) {
return m_sysIdRoutine.Dynamic(direction);
}

View File

@@ -1,35 +1,35 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <optional>
#include <frc/TimedRobot.h>
#include <frc2/command/CommandPtr.h>
#include "SysIdRoutineBot.h"
class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void DisabledExit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void AutonomousExit() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TeleopExit() override;
void TestInit() override;
void TestPeriodic() override;
void TestExit() override;
private:
std::optional<frc2::CommandPtr> m_autonomousCommand;
SysIdRoutineBot m_container;
};
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <optional>
#include <frc/TimedRobot.h>
#include <frc2/command/CommandPtr.h>
#include "SysIdRoutineBot.h"
class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void DisabledExit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void AutonomousExit() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TeleopExit() override;
void TestInit() override;
void TestPeriodic() override;
void TestExit() override;
private:
std::optional<frc2::CommandPtr> m_autonomousCommand;
SysIdRoutineBot m_container;
};

View File

@@ -1,24 +1,24 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <frc2/command/CommandPtr.h>
#include <frc2/command/button/CommandXboxController.h>
#include "Constants.h"
#include "subsystems/Drive.h"
class SysIdRoutineBot {
public:
SysIdRoutineBot();
frc2::CommandPtr GetAutonomousCommand();
private:
void ConfigureBindings();
frc2::CommandXboxController m_driverController{
constants::oi::kDriverControllerPort};
Drive m_drive{};
};
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <frc2/command/CommandPtr.h>
#include <frc2/command/button/CommandXboxController.h>
#include "Constants.h"
#include "subsystems/Drive.h"
class SysIdRoutineBot {
public:
SysIdRoutineBot();
frc2::CommandPtr GetAutonomousCommand();
private:
void ConfigureBindings();
frc2::CommandXboxController m_driverController{
constants::oi::kDriverControllerPort};
Drive m_drive{};
};

View File

@@ -1,10 +1,10 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}