Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed May 20, 2024
1 parent 230d511 commit 367756d
Show file tree
Hide file tree
Showing 151 changed files with 212 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* }
*
* {@literal @}Override
* public void robotInit() {
* public Robot() {
* usbCamera = CameraServer.startAutomaticCapture(0);
* findTotePipeline = new MyFindTotePipeline();
* findToteThread = new VisionThread(usbCamera, findTotePipeline, this);
Expand Down
3 changes: 1 addition & 2 deletions myRobot/src/main/java/frc/robot/MyRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public class MyRobot extends TimedRobot {
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {}
public MyRobot() {}

/** This function is run once each time the robot enters autonomous mode. */
@Override
Expand Down
3 changes: 2 additions & 1 deletion myRobot/src/main/native/cpp/MyRobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#include <frc/TimedRobot.h>

class MyRobot : public frc::TimedRobot {
public:
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
void RobotInit() override {}
MyRobot() {}

/**
* This function is run once each time the robot enters autonomous mode
Expand Down
4 changes: 1 addition & 3 deletions wpilibc/src/test/native/cpp/TimedRobotTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class MockRobot : public TimedRobot {
std::atomic<uint32_t> m_teleopPeriodicCount{0};
std::atomic<uint32_t> m_testPeriodicCount{0};

MockRobot() : TimedRobot{kPeriod} {}

void RobotInit() override { m_robotInitCount++; }
MockRobot() : TimedRobot{kPeriod} { m_robotInitCount++; }

void SimulationInit() override { m_simulationInitCount++; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Robot : public frc::TimedRobot {
public:
void Rainbow();
void RobotInit() override;
Robot();
void RobotPeriodic() override;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Robot : public frc::TimedRobot {
}
#endif

void RobotInit() override {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Robot : public frc::TimedRobot {
public:
void RobotInit() override {}
Robot() {}
void SimulationPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/CANPDP/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/DMA/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Robot : public frc::TimedRobot {
frc::DutyCycleEncoder m_dutyCycleEncoder{0};

public:
void RobotInit() override {
Robot() {
// Set to 0.5 units per rotation
m_dutyCycleEncoder.SetDistancePerRotation(0.5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Robot : public frc::TimedRobot {
public:
void RobotInit() override {}
Robot() {}
void RobotPeriodic() override;
void SimulationPeriodic() override;
void TeleopInit() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Robot : public frc::TimedRobot {
public:
void RobotInit() override {}
Robot() {}
void RobotPeriodic() override;
void SimulationPeriodic() override;
void TeleopPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Robot : public frc::TimedRobot {
wpi::SendableRegistry::AddChild(&m_drive, &m_right);
}

void RobotInit() override {
Robot() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Robot : public frc::TimedRobot {
}
}

void RobotInit() override {
Robot() {
// We need to run our vision program in a separate thread. If not, our robot
// program will not run.
std::thread visionThread(VisionThread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Robot : public frc::TimedRobot {
}
#endif

void RobotInit() override {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
Robot();
void RobotPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 367756d

Please sign in to comment.