27#ifndef __FRC_SYSTEMCORE__
34 static Robot theRobot;
36 std::scoped_lock lock{m};
39 theRobot.StartCompetition();
44 "The robot program quit unexpectedly."
45 " This is usually due to a code error.\n"
46 " The above stacktrace can help determine where the error occurred.\n"
47 " See https://wpilib.org/stacktrace for more information.\n");
49 }
catch (
const std::exception& e) {
61 uint32_t expectedMajor;
62 uint32_t expectedMinor;
65 &expectedMinor, &runtimePath)) {
70 "Your copy of Visual Studio is out of date. Please update it.\n");
81 static Robot* robot =
nullptr;
82 static bool exited =
false;
91 std::scoped_lock lock{m};
101 std::scoped_lock lock{m};
112 robot->EndCompetition();
116 using namespace std::chrono_literals;
117 std::unique_lock lock{m};
118 if (
cv.wait_for(lock, 1s, [] { return exited; })) {
127#ifndef __FRC_SYSTEMCORE__
257#ifdef __FRC_SYSTEMCORE__
270#ifdef __FRC_SYSTEMCORE__
#define WPILIB_ReportError(status, format,...)
Reports an error to the driver station (using HAL_SendError).
Definition Errors.hpp:137
int32_t WPI_IsRuntimeValid(uint32_t *FoundMajor, uint32_t *FoundMinor, uint32_t *ExpectedMajor, uint32_t *ExpectedMinor, WPI_String *RuntimePath)
NT_Listener connListenerHandle
Definition RobotBase.hpp:297
static int64_t GetOpModeId()
Gets the currently selected operating mode of the driver station.
virtual void EndCompetition()=0
Ends the main loop in StartCompetition().
static constexpr bool IsSimulation()
Get if the robot is a simulation.
Definition RobotBase.hpp:269
RobotBase(RobotBase &&)=default
static bool IsDisabled()
Determine if the Robot is currently disabled.
static std::thread::id GetThreadId()
Returns the main thread ID.
static std::thread::id m_threadId
Definition RobotBase.hpp:296
static RuntimeType GetRuntimeType()
Get the current runtime type.
static std::string GetOpMode()
Gets the currently selected operating mode of the driver station.
static bool IsEnabled()
Determine if the Robot is currently enabled.
virtual ~RobotBase()=default
RobotBase()
Constructor for a generic robot program.
static bool IsTeleop()
Determine if the robot is currently in Operator Control mode.
static bool IsTest()
Determine if the robot is currently in Test mode.
static constexpr bool IsReal()
Get if the robot is real.
Definition RobotBase.hpp:256
static bool IsAutonomous()
Determine if the robot is currently in Autonomous mode.
static bool IsTestEnabled()
Determine if the robot is current in Test mode and enabled.
virtual void StartCompetition()=0
Start the main robot code.
static bool IsTeleopEnabled()
Determine if the robot is current in Operator Control mode and enabled.
static bool IsAutonomousEnabled()
Determine if the robot is currently in Autonomous mode and enabled.
RobotBase & operator=(RobotBase &&)=default
Runtime error exception.
Definition Errors.hpp:20
void Report() const
Reports error to Driver Station (using HAL_SendError).
void HAL_Shutdown(void)
Call this to shut down HAL.
int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode, const char *details, const char *location, const char *callStack, HAL_Bool printMsg)
Sends an error to the driver station.
void HAL_RunMain(void)
Runs the main function provided to HAL_SetMain().
HAL_Bool HAL_HasMain(void)
Returns true if HAL_SetMain() has been called.
void HAL_ExitMain(void)
Causes HAL_RunMain() to exit.
NT_Handle NT_Listener
Definition ntcore_c.h:39
Definition VisionPipeline.hpp:7
Definition RobotBase.hpp:26
void RunRobot(wpi::util::mutex &m, Robot **robot)
Definition RobotBase.hpp:32
::std::condition_variable condition_variable
Definition condition_variable.hpp:16
::std::mutex mutex
Definition mutex.hpp:17
Definition CvSource.hpp:15
RuntimeType
Runtime type.
Definition RuntimeType.hpp:11
int RunHALInitialization()
int StartRobot()
Definition RobotBase.hpp:58
A const UTF8 string.
Definition string.h:12