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:
@@ -10,18 +10,18 @@ using namespace DriveConstants;
|
||||
|
||||
DriveDistanceProfiled::DriveDistanceProfiled(units::meter_t distance,
|
||||
DriveSubsystem* drive)
|
||||
: CommandHelper(
|
||||
frc::TrapezoidProfile<units::meters>(
|
||||
: CommandHelper{
|
||||
frc::TrapezoidProfile<units::meters>{
|
||||
// Limit the max acceleration and velocity
|
||||
{kMaxSpeed, kMaxAcceleration},
|
||||
// End at desired position in meters; implicitly starts at 0
|
||||
{distance, 0_mps}),
|
||||
{distance, 0_mps}},
|
||||
// Pipe the profile state to the drive
|
||||
[drive](auto setpointState) {
|
||||
drive->SetDriveStates(setpointState, setpointState);
|
||||
},
|
||||
// Require the drive
|
||||
{drive}) {
|
||||
{drive}} {
|
||||
// Reset drive encoders since we're starting at 0
|
||||
drive->ResetEncoders();
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ void DriveSubsystem::ResetEncoders() {
|
||||
}
|
||||
|
||||
units::meter_t DriveSubsystem::GetLeftEncoderDistance() {
|
||||
return units::meter_t(m_leftLeader.GetEncoderDistance());
|
||||
return units::meter_t{m_leftLeader.GetEncoderDistance()};
|
||||
}
|
||||
|
||||
units::meter_t DriveSubsystem::GetRightEncoderDistance() {
|
||||
return units::meter_t(m_rightLeader.GetEncoderDistance());
|
||||
return units::meter_t{m_rightLeader.GetEncoderDistance()};
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
|
||||
Reference in New Issue
Block a user