mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
New 2018 and later build setup (#1001)
This commit is contained in:
committed by
Peter Johnson
parent
cb2c9eb6d5
commit
7f88cf768d
@@ -57,7 +57,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void RobotInit() {
|
||||
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);
|
||||
|
||||
@@ -32,14 +32,14 @@ public:
|
||||
* Use the potentiometer as the PID sensor. This method is automatically
|
||||
* called by the subsystem.
|
||||
*/
|
||||
double ReturnPIDInput();
|
||||
double ReturnPIDInput() override;
|
||||
|
||||
/**
|
||||
* Use the motor as the PID output. This method is automatically called
|
||||
* by
|
||||
* the subsystem.
|
||||
*/
|
||||
void UsePIDOutput(double d);
|
||||
void UsePIDOutput(double d) override;
|
||||
|
||||
private:
|
||||
frc::Spark m_motor{5};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <CameraServer.h>
|
||||
#include <IterativeRobot.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/core/types.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
@@ -21,6 +22,7 @@
|
||||
* processing.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
#if defined(__linux__)
|
||||
private:
|
||||
static void VisionThread() {
|
||||
// Get the USB camera from CameraServer
|
||||
@@ -58,12 +60,18 @@ private:
|
||||
outputStream.PutFrame(mat);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void RobotInit() {
|
||||
// We need to run our vision program in a separate Thread.
|
||||
// If not, our robot program will not run
|
||||
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__)
|
||||
std::thread visionThread(VisionThread);
|
||||
visionThread.detach();
|
||||
#else
|
||||
llvm::errs() << "Vision only available on Linux.\n";
|
||||
llvm::errs().flush();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
public:
|
||||
void RobotInit() {
|
||||
void RobotInit() override {
|
||||
// Invert the left side motors
|
||||
// You may need to change or remove this to match your robot
|
||||
m_frontLeft.SetInverted(true);
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
static constexpr int kJoystickChannel = 0;
|
||||
|
||||
// Bottom, middle, and top elevator setpoints
|
||||
static constexpr std::array<double, 3> kSetPoints = {1.0, 2.6, 4.3};
|
||||
static constexpr std::array<double, 3> kSetPoints = {{1.0, 2.6, 4.3}};
|
||||
|
||||
/* proportional, integral, and derivative speed constants; motor
|
||||
* inverted
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <CameraServer.h>
|
||||
#include <IterativeRobot.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
|
||||
/**
|
||||
* Uses the CameraServer class to automatically capture video from a USB webcam
|
||||
@@ -17,8 +18,13 @@
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
public:
|
||||
void RobotInit() {
|
||||
void RobotInit() override {
|
||||
#if defined(__linux__)
|
||||
CameraServer::GetInstance()->StartAutomaticCapture();
|
||||
#else
|
||||
llvm::errs() << "Vision only available on Linux.\n";
|
||||
llvm::errs().flush();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user