27#ifndef __FRC_ROBORIO__
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_ROBORIO__
238#ifdef __FRC_ROBORIO__
251#ifdef __FRC_ROBORIO__
int32_t WPI_IsRuntimeValid(uint32_t *FoundMajor, uint32_t *FoundMinor, uint32_t *ExpectedMajor, uint32_t *ExpectedMinor, WPI_String *RuntimePath)
Implement a Robot Program framework.
Definition RobotBase.h:145
RobotBase()
Constructor for a generic robot program.
bool IsTestEnabled() const
Determine if the robot is current in Test mode and enabled.
static constexpr bool IsReal()
Get if the robot is real.
Definition RobotBase.h:237
static constexpr bool IsSimulation()
Get if the robot is a simulation.
Definition RobotBase.h:250
bool IsTest() const
Determine if the robot is currently in Test mode.
bool m_dashboardDetected
Definition RobotBase.h:279
static std::thread::id GetThreadId()
Returns the main thread ID.
static std::thread::id m_threadId
Definition RobotBase.h:277
RobotBase & operator=(RobotBase &&)=default
bool IsAutonomousEnabled() const
Determine if the robot is currently in Autonomous mode and enabled.
bool IsEnabled() const
Determine if the Robot is currently enabled.
virtual void StartCompetition()=0
Start the main robot code.
bool IsTeleop() const
Determine if the robot is currently in Operator Control mode.
static RuntimeType GetRuntimeType()
Get the current runtime type.
NT_Listener connListenerHandle
Definition RobotBase.h:278
bool IsDisabled() const
Determine if the Robot is currently disabled.
virtual void EndCompetition()=0
Ends the main loop in StartCompetition().
bool IsAutonomous() const
Determine if the robot is currently in Autonomous mode.
bool IsTeleopEnabled() const
Determine if the robot is current in Operator Control mode and enabled.
virtual ~RobotBase()=default
RobotBase(RobotBase &&)=default
Runtime error exception.
Definition Errors.h: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.h:7
void RunRobot(wpi::mutex &m, Robot **robot)
Definition RobotBase.h:32
int StartRobot()
Definition RobotBase.h:58
int RunHALInitialization()
RuntimeType
Runtime type.
Definition RuntimeType.h:11
::std::condition_variable condition_variable
Definition condition_variable.h:16
::std::mutex mutex
Definition mutex.h:17
A const UTF8 string.
Definition string.h:14
#define FRC_ReportError(status, format,...)
Reports an error to the driver station (using HAL_SendError).
Definition Errors.h:137