[wpilib] Deprecate getInstance() in favor of static functions (#3440)

Co-authored-by: Noam Zaks <imnoamzaks@gmail.com>
This commit is contained in:
Peter Johnson
2021-06-15 23:06:03 -07:00
committed by GitHub
parent 26ff9371d9
commit 362066a9b7
105 changed files with 1500 additions and 1539 deletions

View File

@@ -19,15 +19,15 @@ class Robot : public frc::TimedRobot {
static void VisionThread() {
// Get the Axis camera from CameraServer
cs::AxisCamera camera =
frc::CameraServer::GetInstance()->AddAxisCamera("axis-camera.local");
frc::CameraServer::AddAxisCamera("axis-camera.local");
// Set the resolution
camera.SetResolution(640, 480);
// Get a CvSink. This will capture Mats from the Camera
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
cs::CvSink cvSink = frc::CameraServer::GetVideo();
// Setup a CvSource. This will send images back to the Dashboard
cs::CvSource outputStream =
frc::CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
frc::CameraServer::PutVideo("Rectangle", 640, 480);
// Mats are very memory expensive. Lets reuse this Mat.
cv::Mat mat;

View File

@@ -6,7 +6,6 @@
#include <frc/TimedRobot.h>
#include <frc/Timer.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc/livewindow/LiveWindow.h>
#include <frc/motorcontrol/PWMSparkMax.h>
class Robot : public frc::TimedRobot {
@@ -50,7 +49,6 @@ class Robot : public frc::TimedRobot {
frc::DifferentialDrive m_robotDrive{m_left, m_right};
frc::Joystick m_stick{0};
frc::LiveWindow& m_lw = *frc::LiveWindow::GetInstance();
frc::Timer m_timer;
};

View File

@@ -23,16 +23,15 @@ class Robot : public frc::TimedRobot {
private:
static void VisionThread() {
// Get the USB camera from CameraServer
cs::UsbCamera camera =
frc::CameraServer::GetInstance()->StartAutomaticCapture();
cs::UsbCamera camera = frc::CameraServer::StartAutomaticCapture();
// Set the resolution
camera.SetResolution(640, 480);
// Get a CvSink. This will capture Mats from the Camera
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
cs::CvSink cvSink = frc::CameraServer::GetVideo();
// Setup a CvSource. This will send images back to the Dashboard
cs::CvSource outputStream =
frc::CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
frc::CameraServer::PutVideo("Rectangle", 640, 480);
// Mats are very memory expensive. Lets reuse this Mat.
cv::Mat mat;

View File

@@ -17,7 +17,7 @@ class Robot : public frc::TimedRobot {
public:
void RobotInit() override {
#if defined(__linux__) || defined(_WIN32)
frc::CameraServer::GetInstance()->StartAutomaticCapture();
frc::CameraServer::StartAutomaticCapture();
#else
std::fputs("Vision only available on Linux or Windows.\n", stderr);
std::fflush(stderr);