[hal] Use MrcLib to talk to DS (#8858)

Using MrcLib on the robot is going to be the plan for the future, to
make things easier.

MrcLib is how sim is supported going forward. The desktop version of
mrclib can act as a robot server.

This is set up where the mrclib interface is in shared code. On robot,
that is the only backend used. On desktop, a default sim backend is
used. However, the sim plugin can switch that to the real robot backend,
so the robot code will exactly look like a real robot.
This commit is contained in:
Thad House
2026-06-06 12:15:17 -07:00
committed by GitHub
parent ddf9306264
commit 6e5171cd8f
47 changed files with 1754 additions and 1721 deletions

View File

@@ -217,6 +217,7 @@ define_native_wrapper(
PKG_CONFIG_DEPS = [
"//datalog:native/datalog/robotpy-native-datalog.pc",
"//datalog:robotpy-wpilog.generated_pkgcfg_files",
"//hal:native/wpihal/robotpy-native-mrclib.pc",
"//hal:native/wpihal/robotpy-native-wpihal.pc",
"//hal:robotpy-hal.generated_pkgcfg_files",
"//ntcore:native/ntcore/robotpy-native-ntcore.pc",

View File

@@ -183,8 +183,9 @@ void DriverStationSim::SetSendError(bool shouldSend) {
HALSIM_SetSendError(nullptr);
} else {
HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
HAL_Bool isLVCode, const char* details,
const char* location, const char* callStack,
const struct WPI_String* details,
const struct WPI_String* location,
const struct WPI_String* callStack,
HAL_Bool printMsg) { return 0; });
}
}
@@ -193,7 +194,7 @@ void DriverStationSim::SetSendConsoleLine(bool shouldSend) {
if (shouldSend) {
HALSIM_SetSendConsoleLine(nullptr);
} else {
HALSIM_SetSendConsoleLine([](const char* line) { return 0; });
HALSIM_SetSendConsoleLine([](const struct WPI_String* line) { return 0; });
}
}

View File

@@ -7,7 +7,7 @@
#include <string>
#include <utility>
#include "wpi/hal/DriverStation.h"
#include "wpi/hal/DriverStation.hpp"
#include "wpi/hal/HAL.h"
#include "wpi/util/StackTrace.hpp"
#include "wpi/util/fs.hpp"
@@ -32,8 +32,8 @@ RuntimeError::RuntimeError(int32_t code, const char* fileName, int lineNumber,
std::move(stack), std::move(message)} {}
void RuntimeError::Report() const {
HAL_SendError(m_data->code < 0, m_data->code, 0, what(), m_data->loc.c_str(),
m_data->stack.c_str(), 1);
wpi::hal::SendError(m_data->code < 0, m_data->code, what(),
m_data->loc.c_str(), m_data->stack.c_str(), 1);
}
const char* wpi::GetErrorMessage(int32_t* code) {
@@ -63,8 +63,8 @@ void wpi::ReportErrorV(int32_t status, const char* fileName, int lineNumber,
fmt::format_to(fmt::appender{out}, "{}: ", GetErrorMessage(&status));
fmt::vformat_to(fmt::appender{out}, format, args);
out.push_back('\0');
HAL_SendError(status < 0, status, 0, out.data(), funcName,
wpi::util::GetStackTrace(2).c_str(), 1);
wpi::hal::SendError(status < 0, status, out.data(), funcName,
wpi::util::GetStackTrace(2).c_str(), 1);
}
RuntimeError wpi::MakeErrorV(int32_t status, const char* fileName,

View File

@@ -6,7 +6,7 @@
#include <utility>
#include "wpi/hal/DriverStation.h"
#include "wpi/hal/DriverStation.hpp"
#include "wpi/hal/Notifier.hpp"
#include "wpi/hal/Threads.h"
#include "wpi/system/Errors.hpp"
@@ -57,7 +57,7 @@ Notifier::Notifier(int priority, std::function<void()> callback) {
" See https://wpilib.org/stacktrace for more information.\n");
throw;
} catch (const std::exception& e) {
HAL_SendError(1, err::Error, 0, e.what(), "", "", 1);
wpi::hal::SendError(1, err::Error, e.what(), "", "", 1);
throw;
}
}

View File

@@ -8,7 +8,7 @@
#include <string>
#include <thread>
#include "wpi/hal/DriverStation.h"
#include "wpi/hal/DriverStation.hpp"
#include "wpi/hal/HAL.h"
#include "wpi/hal/Main.h"
#include "wpi/nt/NetworkTable.hpp"
@@ -47,7 +47,7 @@ void RunRobot(wpi::util::mutex& m, Robot** robot) {
" See https://wpilib.org/stacktrace for more information.\n");
throw;
} catch (const std::exception& e) {
HAL_SendError(1, err::Error, 0, e.what(), "", "", 1);
wpi::hal::SendError(1, err::Error, e.what(), "", "", 1);
throw;
}
}

View File

@@ -61,7 +61,6 @@ def reportErrorInternal(
hal.sendError(
not isWarning,
code,
False,
error,
locString,
traceString,