mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Use stricter C++ type conversions (#4357)
Now, implicit narrowing conversions are only used with wpi::Now(). This
also fixes clang-tidy warnings about C-style casts. For example:
```
== clang-tidy /__w/allwpilib/allwpilib/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc ==
/__w/allwpilib/allwpilib/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc:95:18: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [google-readability-casting]
auto curTime = units::second_t(m_timer.Get());
^
```
In that case at least, the cast was removed entirely since Get() already
returns a units::second_t.
This commit is contained in:
@@ -9,12 +9,13 @@
|
||||
#include "Robot.h"
|
||||
|
||||
DriveStraight::DriveStraight(double distance, Drivetrain& drivetrain)
|
||||
: frc2::CommandHelper<frc2::PIDCommand, DriveStraight>(
|
||||
frc2::PIDController(4, 0, 0),
|
||||
[&drivetrain] { return drivetrain.GetDistance(); }, distance,
|
||||
: frc2::CommandHelper<frc2::PIDCommand, DriveStraight>{
|
||||
frc2::PIDController{4, 0, 0},
|
||||
[&drivetrain] { return drivetrain.GetDistance(); },
|
||||
distance,
|
||||
[&drivetrain](double output) { drivetrain.Drive(output, output); },
|
||||
{&drivetrain}),
|
||||
m_drivetrain(&drivetrain) {
|
||||
{&drivetrain}},
|
||||
m_drivetrain{&drivetrain} {
|
||||
m_controller.SetTolerance(0.01);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#include "Robot.h"
|
||||
|
||||
SetDistanceToBox::SetDistanceToBox(double distance, Drivetrain& drivetrain)
|
||||
: frc2::CommandHelper<frc2::PIDCommand, SetDistanceToBox>(
|
||||
frc2::PIDController(-2, 0, 0),
|
||||
: frc2::CommandHelper<frc2::PIDCommand, SetDistanceToBox>{
|
||||
frc2::PIDController{-2, 0, 0},
|
||||
[&drivetrain] { return drivetrain.GetDistanceToObstacle(); },
|
||||
distance,
|
||||
[&drivetrain](double output) { drivetrain.Drive(output, output); },
|
||||
{&drivetrain}),
|
||||
m_drivetrain(&drivetrain) {
|
||||
{&drivetrain}},
|
||||
m_drivetrain{&drivetrain} {
|
||||
m_controller.SetTolerance(0.01);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
|
||||
Elevator::Elevator()
|
||||
: frc2::PIDSubsystem(frc2::PIDController(kP_real, kI_real, 0)) {
|
||||
: frc2::PIDSubsystem{frc2::PIDController{kP_real, kI_real, 0}} {
|
||||
#ifdef SIMULATION // Check for simulation and update PID values
|
||||
GetPIDController()->SetPID(kP_simulation, kI_simulation, 0, 0);
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/controller/PIDController.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
|
||||
Wrist::Wrist() : frc2::PIDSubsystem(frc2::PIDController(kP, 0, 0)) {
|
||||
Wrist::Wrist() : frc2::PIDSubsystem{frc2::PIDController{kP, 0, 0}} {
|
||||
m_controller.SetTolerance(2.5);
|
||||
|
||||
SetName("Wrist");
|
||||
|
||||
Reference in New Issue
Block a user