mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Transition C++ classes to units::second_t (#3396)
A lot of these are breaking changes. frc::Timer was replaced with the contents of frc2::Timer. The others were in-place argument changes or removing deprecated non-unit overloads.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "ReplaceMeTimedCommand.h"
|
||||
|
||||
ReplaceMeTimedCommand::ReplaceMeTimedCommand(double timeout)
|
||||
ReplaceMeTimedCommand::ReplaceMeTimedCommand(units::second_t timeout)
|
||||
: TimedCommand(timeout) {
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(Robot::chassis.get());
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <frc/commands/TimedCommand.h>
|
||||
#include <units/time.h>
|
||||
|
||||
class ReplaceMeTimedCommand : public frc::TimedCommand {
|
||||
public:
|
||||
explicit ReplaceMeTimedCommand(double timeout);
|
||||
explicit ReplaceMeTimedCommand(units::second_t timeout);
|
||||
void Initialize() override;
|
||||
void Execute() override;
|
||||
void End() override;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Drivetrain.h"
|
||||
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
|
||||
#include "ExampleGlobalMeasurementSensor.h"
|
||||
|
||||
@@ -38,5 +38,5 @@ void Drivetrain::UpdateOdometry() {
|
||||
m_poseEstimator.AddVisionMeasurement(
|
||||
ExampleGlobalMeasurementSensor::GetEstimatedGlobalPose(
|
||||
m_poseEstimator.GetEstimatedPosition()),
|
||||
frc2::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
frc::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
m_robotDrive.SetExpiration(0.1);
|
||||
m_robotDrive.SetExpiration(100_ms);
|
||||
m_timer.Start();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Robot : public frc::TimedRobot {
|
||||
|
||||
void AutonomousPeriodic() override {
|
||||
// Drive for 2 seconds
|
||||
if (m_timer.Get() < 2.0) {
|
||||
if (m_timer.Get() < 2_s) {
|
||||
// Drive forwards half speed
|
||||
m_robotDrive.ArcadeDrive(0.5, 0.0);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Drivetrain.h"
|
||||
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
|
||||
#include "ExampleGlobalMeasurementSensor.h"
|
||||
|
||||
@@ -58,5 +58,5 @@ void Drivetrain::UpdateOdometry() {
|
||||
m_poseEstimator.AddVisionMeasurement(
|
||||
ExampleGlobalMeasurementSensor::GetEstimatedGlobalPose(
|
||||
m_poseEstimator.GetEstimatedPosition()),
|
||||
frc2::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
frc::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
CheckForHotGoal::CheckForHotGoal(double time) {
|
||||
CheckForHotGoal::CheckForHotGoal(units::second_t time) {
|
||||
SetTimeout(time);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
DriveAndShootAutonomous::DriveAndShootAutonomous() {
|
||||
AddSequential(new CloseClaw());
|
||||
AddSequential(new WaitForPressure(), 2);
|
||||
AddSequential(new WaitForPressure(), 2_s);
|
||||
#ifndef SIMULATION
|
||||
// NOTE: Simulation doesn't currently have the concept of hot.
|
||||
AddSequential(new CheckForHotGoal(2));
|
||||
AddSequential(new CheckForHotGoal(2_s));
|
||||
#endif
|
||||
AddSequential(new SetPivotSetpoint(45));
|
||||
AddSequential(new DriveForward(8, 0.3));
|
||||
|
||||
@@ -29,7 +29,7 @@ DriveForward::DriveForward(double dist, double maxSpeed) {
|
||||
// Called just before this Command runs the first time
|
||||
void DriveForward::Initialize() {
|
||||
Robot::drivetrain.GetRightEncoder().Reset();
|
||||
SetTimeout(2);
|
||||
SetTimeout(2_s);
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
ExtendShooter::ExtendShooter() : frc::TimedCommand(1.0) {
|
||||
ExtendShooter::ExtendShooter() : frc::TimedCommand(1_s) {
|
||||
Requires(&Robot::shooter);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ DriveTrain::DriveTrain() : frc::Subsystem("DriveTrain") {
|
||||
// Configure the DifferentialDrive to reflect the fact that all our
|
||||
// motors are wired backwards and our drivers sensitivity preferences.
|
||||
m_robotDrive.SetSafetyEnabled(false);
|
||||
m_robotDrive.SetExpiration(0.1);
|
||||
m_robotDrive.SetExpiration(100_ms);
|
||||
m_robotDrive.SetMaxOutput(1.0);
|
||||
m_leftCIMs.SetInverted(true);
|
||||
m_rightCIMs.SetInverted(true);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <frc/commands/Command.h>
|
||||
#include <units/time.h>
|
||||
|
||||
/**
|
||||
* This command looks for the hot goal and waits until it's detected or timed
|
||||
@@ -14,6 +15,6 @@
|
||||
*/
|
||||
class CheckForHotGoal : public frc::Command {
|
||||
public:
|
||||
explicit CheckForHotGoal(double time);
|
||||
explicit CheckForHotGoal(units::second_t time);
|
||||
bool IsFinished() override;
|
||||
};
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
#include <frc/SlewRateLimiter.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/Timer.h>
|
||||
#include <frc/XboxController.h>
|
||||
#include <frc/controller/RamseteController.h>
|
||||
#include <frc/smartdashboard/Field2d.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc/trajectory/TrajectoryGenerator.h>
|
||||
#include <frc2/Timer.h>
|
||||
|
||||
#include "Drivetrain.h"
|
||||
|
||||
@@ -89,7 +89,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::RamseteController m_ramseteController;
|
||||
|
||||
// The timer to use during the autonomous period.
|
||||
frc2::Timer m_timer;
|
||||
frc::Timer m_timer;
|
||||
|
||||
// Create Field2d for robot and trajectory visualizations.
|
||||
frc::Field2d m_field;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/DigitalInput.h>
|
||||
#include <frc/DigitalOutput.h>
|
||||
#include <frc/Errors.h>
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
|
||||
OnBoardIO::OnBoardIO(OnBoardIO::ChannelMode dio1, OnBoardIO::ChannelMode dio2) {
|
||||
if (dio1 == ChannelMode::INPUT) {
|
||||
@@ -30,7 +30,7 @@ bool OnBoardIO::GetButtonBPressed() {
|
||||
return m_buttonB->Get();
|
||||
}
|
||||
|
||||
auto currentTime = frc2::Timer::GetFPGATimestamp();
|
||||
auto currentTime = frc::Timer::GetFPGATimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "Button {} was not configured", "B");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
@@ -43,7 +43,7 @@ bool OnBoardIO::GetButtonCPressed() {
|
||||
return m_buttonC->Get();
|
||||
}
|
||||
|
||||
auto currentTime = frc2::Timer::GetFPGATimestamp();
|
||||
auto currentTime = frc::Timer::GetFPGATimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "Button {} was not configured", "C");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
@@ -55,7 +55,7 @@ void OnBoardIO::SetGreenLed(bool value) {
|
||||
if (m_greenLed) {
|
||||
m_greenLed->Set(value);
|
||||
} else {
|
||||
auto currentTime = frc2::Timer::GetFPGATimestamp();
|
||||
auto currentTime = frc::Timer::GetFPGATimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{} LED was not configured", "Green");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
@@ -67,7 +67,7 @@ void OnBoardIO::SetRedLed(bool value) {
|
||||
if (m_redLed) {
|
||||
m_redLed->Set(value);
|
||||
} else {
|
||||
auto currentTime = frc2::Timer::GetFPGATimestamp();
|
||||
auto currentTime = frc::Timer::GetFPGATimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{} LED was not configured", "Red");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <units/time.h>
|
||||
@@ -27,5 +27,5 @@ class DriveTime : public frc2::CommandHelper<frc2::CommandBase, DriveTime> {
|
||||
double m_speed;
|
||||
units::second_t m_duration;
|
||||
Drivetrain* m_drive;
|
||||
frc2::Timer m_timer;
|
||||
frc::Timer m_timer;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <units/time.h>
|
||||
@@ -27,5 +27,5 @@ class TurnTime : public frc2::CommandHelper<frc2::CommandBase, TurnTime> {
|
||||
double m_speed;
|
||||
units::second_t m_duration;
|
||||
Drivetrain* m_drive;
|
||||
frc2::Timer m_timer;
|
||||
frc::Timer m_timer;
|
||||
};
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
#include <frc/SlewRateLimiter.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/Timer.h>
|
||||
#include <frc/XboxController.h>
|
||||
#include <frc/controller/RamseteController.h>
|
||||
#include <frc/trajectory/TrajectoryGenerator.h>
|
||||
#include <frc2/Timer.h>
|
||||
|
||||
#include "Drivetrain.h"
|
||||
|
||||
@@ -69,7 +69,7 @@ class Robot : public frc::TimedRobot {
|
||||
Drivetrain m_drive;
|
||||
frc::Trajectory m_trajectory;
|
||||
frc::RamseteController m_ramsete;
|
||||
frc2::Timer m_timer;
|
||||
frc::Timer m_timer;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Drivetrain.h"
|
||||
|
||||
#include <frc2/Timer.h>
|
||||
#include <frc/Timer.h>
|
||||
|
||||
#include "ExampleGlobalMeasurementSensor.h"
|
||||
|
||||
@@ -37,5 +37,5 @@ void Drivetrain::UpdateOdometry() {
|
||||
m_poseEstimator.AddVisionMeasurement(
|
||||
ExampleGlobalMeasurementSensor::GetEstimatedGlobalPose(
|
||||
m_poseEstimator.GetEstimatedPosition()),
|
||||
frc2::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
frc::Timer::GetFPGATimestamp() - 0.3_s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user