mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Prepare for RobotInit deprecation by updating examples (#6623)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Default to a length of 60, start empty output
|
||||
// Length is expensive to set, so only set it once, then just update data
|
||||
m_led.SetLength(kLength);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,6 +32,19 @@
|
||||
* solution!
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
|
||||
private:
|
||||
@@ -147,18 +160,6 @@ class Robot : public frc::TimedRobot {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void RobotInit() override {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
|
||||
@@ -23,9 +23,7 @@ class Robot : public frc::TimedRobot {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor);
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
|
||||
@@ -23,9 +23,7 @@ class Robot : public frc::TimedRobot {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor);
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {}
|
||||
Robot() {}
|
||||
void SimulationPeriodic() override;
|
||||
void TeleopInit() override;
|
||||
void TeleopPeriodic() override;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// Put the PDP itself to the dashboard
|
||||
frc::SmartDashboard::PutData("PDP", &m_pdp);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::Encoder m_encoder{0, 1};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// Trigger on falling edge of dma trigger output
|
||||
m_dma.SetExternalTrigger(&m_dmaTrigger, false, true);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -20,7 +20,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::DutyCycleEncoder m_dutyCycleEncoder{0, fullRange, expectedZero};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// If you know the frequency of your sensor, uncomment the following
|
||||
// method, and set the method to the frequency of your sensor.
|
||||
// This will result in more stable readings from the sensor.
|
||||
|
||||
@@ -12,7 +12,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::DutyCycle m_dutyCycle{m_input}; // Duty cycle input
|
||||
|
||||
public:
|
||||
void RobotInit() override {}
|
||||
Robot() {}
|
||||
|
||||
void RobotPeriodic() override {
|
||||
// Duty Cycle Frequency in Hz
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {}
|
||||
Robot() {}
|
||||
void RobotPeriodic() override;
|
||||
void SimulationPeriodic() override;
|
||||
void TeleopInit() override;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {}
|
||||
Robot() {}
|
||||
void RobotPeriodic() override;
|
||||
void SimulationPeriodic() override;
|
||||
void TeleopPeriodic() override;
|
||||
|
||||
@@ -22,7 +22,7 @@ static const auto KICKER_THRESHOLD = 15_mm;
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
m_controller.SetTolerance(TOLERANCE.value());
|
||||
|
||||
frc::BooleanEvent isBallAtKicker{&m_loop, [&kickerSensor = m_kickerSensor] {
|
||||
|
||||
@@ -40,7 +40,7 @@ class Robot : public frc::TimedRobot {
|
||||
0.9 * m_feedforward.Calculate(setpoint));
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// Add bang-bang controler to SmartDashboard and networktables.
|
||||
frc::SmartDashboard::PutData("BangBangControler", &m_bangBangControler);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -18,16 +18,14 @@
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_drive, &m_left);
|
||||
wpi::SendableRegistry::AddChild(&m_drive, &m_right);
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
m_gyro.SetSensitivity(kVoltsPerDegreePerSecond);
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_right.SetInverted(true);
|
||||
|
||||
wpi::SendableRegistry::AddChild(&m_drive, &m_left);
|
||||
wpi::SendableRegistry::AddChild(&m_drive, &m_right);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontLeft);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rearLeft);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontRight);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Start recording to data log
|
||||
frc::DataLogManager::Start();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Start recording to data log
|
||||
frc::DataLogManager::Start();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
* processing.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
}
|
||||
|
||||
private:
|
||||
static void VisionThread() {
|
||||
// Create an HTTP camera. The address will need to be modified to have the
|
||||
@@ -50,13 +58,6 @@ class Robot : public frc::TimedRobot {
|
||||
outputStream.PutFrame(mat);
|
||||
}
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
|
||||
@@ -18,6 +18,19 @@
|
||||
* processing.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
|
||||
private:
|
||||
@@ -55,18 +68,6 @@ class Robot : public frc::TimedRobot {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void RobotInit() override {
|
||||
// We need to run our vision program in a separate thread. If not, our robot
|
||||
// program will not run.
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
std::fputs("Vision only available on Linux or Windows.\n", stderr);
|
||||
std::fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontLeft);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rearLeft);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_frontRight);
|
||||
|
||||
@@ -30,7 +30,7 @@ class Robot : public frc::TimedRobot {
|
||||
static constexpr double kElevatorMinimumLength = 0.5;
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
m_elevatorEncoder.SetDistancePerPulse(kMetersPerPulse);
|
||||
|
||||
// publish to dashboard
|
||||
|
||||
@@ -33,7 +33,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::SmartDashboard::PutNumber("Encoder", m_encoder.GetDistance());
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// Use SetDistancePerPulse to set the multiplier for GetDistance
|
||||
// This is set up assuming a 6 inch wheel with a 360 CPR encoder.
|
||||
m_encoder.SetDistancePerPulse((std::numbers::pi * 6) / 360.0);
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
* Uses the CameraServer class to automatically capture video from a USB webcam
|
||||
* and send it to the FRC dashboard without doing any vision processing. This is
|
||||
* the easiest way to get camera images to the dashboard. Just add this to the
|
||||
* RobotInit() method in your program.
|
||||
* robot class constructor.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
frc::CameraServer::StartAutomaticCapture();
|
||||
#else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Configure default commands and condition bindings on robot startup
|
||||
m_robot.ConfigureBindings();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class RapidReactCommandBot {
|
||||
* Use this method to define bindings between conditions and commands. These
|
||||
* are useful for automating robot behaviors based on button and sensor input.
|
||||
*
|
||||
* <p>Should be called during Robot::RobotInit().
|
||||
* <p>Should be called in the robot class constructor.
|
||||
*
|
||||
* <p>Event binding methods are available on the frc2::Trigger class.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_left);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_right);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
m_trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
|
||||
frc::Pose2d{2_m, 2_m, 0_rad}, {}, frc::Pose2d{6_m, 4_m, 0_rad},
|
||||
frc::TrajectoryConfig(2_mps, 2_mps_sq));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/shuffleboard/Shuffleboard.h>
|
||||
#include <units/pressure.h>
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Publish elements to shuffleboard.
|
||||
frc::ShuffleboardTab& tab = frc::Shuffleboard::GetTab("Pneumatics");
|
||||
tab.Add("Single Solenoid", m_solenoid);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void TeleopPeriodic() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -93,7 +93,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::TrapezoidProfile<units::radians>::State m_lastProfiledReference;
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::TrapezoidProfile<units::meters>::State m_lastProfiledReference;
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// Circumference = pi * d, so distance per click = pi * d / counts
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi * kDrumRadius.value() /
|
||||
4096.0);
|
||||
|
||||
@@ -80,7 +80,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::XboxController m_joystick{kJoystickPort};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::XboxController m_joystick{kJoystickPort};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -21,7 +21,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::Joystick m_rightStick{1};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Robot : public frc::TimedRobot {
|
||||
frc::XboxController m_driverController{0};
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
Robot() {
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <units/length.h>
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
// Add the ultrasonic on the "Sensors" tab of the dashboard
|
||||
// Data will update automatically
|
||||
frc::Shuffleboard::GetTab("Sensors").Add(m_rangeFinder);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void TeleopPeriodic() override;
|
||||
void TestInit() override;
|
||||
void TestPeriodic() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <hal/DriverStation.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
|
||||
void Robot::Disabled() {}
|
||||
|
||||
@@ -22,8 +22,6 @@ void Robot::Teleop() {}
|
||||
void Robot::Test() {}
|
||||
|
||||
void Robot::StartCompetition() {
|
||||
RobotInit();
|
||||
|
||||
frc::internal::DriverStationModeThread modeThread;
|
||||
|
||||
wpi::Event event{false, false};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
class Robot : public frc::RobotBase {
|
||||
public:
|
||||
void RobotInit();
|
||||
Robot();
|
||||
void Disabled();
|
||||
void Autonomous();
|
||||
void Teleop();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <wpi/print.h>
|
||||
|
||||
void Robot::RobotInit() {
|
||||
Robot::Robot() {
|
||||
m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault);
|
||||
m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom);
|
||||
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
void AutonomousInit() override;
|
||||
void AutonomousPeriodic() override;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
Robot::Robot() {}
|
||||
void Robot::RobotPeriodic() {}
|
||||
|
||||
void Robot::AutonomousInit() {}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
|
||||
void AutonomousInit() override;
|
||||
|
||||
@@ -23,9 +23,7 @@ Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} {
|
||||
// Total usage:
|
||||
// 5 ms (robot) + 2 ms (controller 1) + 2 ms (controller 2) = 9 ms
|
||||
// 9 ms / 10 ms -> 90% allocated
|
||||
}
|
||||
|
||||
void Robot::RobotInit() {
|
||||
m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault);
|
||||
m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom);
|
||||
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
class Robot : public frc::TimesliceRobot {
|
||||
public:
|
||||
Robot();
|
||||
|
||||
void RobotInit() override;
|
||||
void RobotPeriodic() override;
|
||||
void AutonomousInit() override;
|
||||
void AutonomousPeriodic() override;
|
||||
|
||||
@@ -23,7 +23,6 @@ Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} {
|
||||
// 9 ms / 10 ms -> 90% allocated
|
||||
}
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
void Robot::RobotPeriodic() {}
|
||||
|
||||
void Robot::AutonomousInit() {}
|
||||
|
||||
@@ -10,7 +10,6 @@ class Robot : public frc::TimesliceRobot {
|
||||
public:
|
||||
Robot();
|
||||
|
||||
void RobotInit() override;
|
||||
void RobotPeriodic() override;
|
||||
|
||||
void AutonomousInit() override;
|
||||
|
||||
Reference in New Issue
Block a user