Use MrcLib to talk to DS#8858
Open
ThadHouse wants to merge 29 commits into
Open
Conversation
Member
Author
|
Even if this passed, don't merge this yet. Haven't done the console line stuff, nor have I actually tested it on systemcore. |
This was referenced May 6, 2026
There was a problem hiding this comment.
Pull request overview
This PR migrates Driver Station communications toward an MrcLib-backed implementation (robot + sim), while also extending the error/crash reporting surface so failures can be reported to the DS consistently across runtimes.
Changes:
- Added a DS “program crash” reporting path and hooked it into
RobotBaseexception handling. - Refactored HAL DriverStation error/console APIs to use
WPI_Stringand routed DS operations through anMrcLibDsbackend (systemcore + sim). - Reworked the
halsim_ds_socketextension to use mrclib instead of the legacy DS socket packet parsing implementation, and added mrclib build definitions for Gradle/Bazel.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| wpilibj/src/main/java/org/wpilib/framework/RobotBase.java | Emits DS crash reports on robot instantiation/runtime exceptions. |
| wpilibj/src/main/java/org/wpilib/driverstation/internal/DriverStationBackend.java | Adds reportCrash() and updates DS error JNI call signature usage. |
| wpilibj/src/main/java/org/wpilib/driverstation/DriverStationErrors.java | Exposes reportCrash() to user code. |
| wpilibc/src/main/native/include/wpi/framework/RobotBase.hpp | Switches to C++ DriverStation wrapper header and new SendError() API. |
| wpilibc/src/main/native/cpp/system/Notifier.cpp | Updates error sending to new C++ SendError() wrapper. |
| wpilibc/src/main/native/cpp/system/Errors.cpp | Updates error sending to new C++ SendError() wrapper. |
| wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp | Updates HALSim DS callback signatures to WPI_String. |
| simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp | Removes tests for legacy DS socket packet parser (parser removed). |
| simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DsSocket.h | Adds placeholder header for packaging. |
| simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommPacket.hpp | Removes legacy DS packet parser API. |
| simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommJoystickPacket.hpp | Removes legacy joystick packet struct. |
| simulation/halsim_ds_socket/src/main/native/cpp/main.cpp | Reimplements DS socket extension around mrclib + forced DS backend. |
| simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp | Removes legacy DS packet parser implementation. |
| simulation/CMakeLists.txt | Disables building ds_socket via CMake. |
| shared/libmrclib.gradle | Adds mrclib as a Gradle native dependency. |
| shared/bazel/thirdparty/mrclib/mrclib.MODULE.bazel | Adds Bazel http_archives for mrclib artifacts. |
| shared/bazel/thirdparty/mrclib/BUILD.bazel | Adds Bazel cc_import for mrclib shared library. |
| MODULE.bazel | Includes mrclib module definition. |
| hal/src/main/python/semiwrap/DriverStation.yml | Exposes new DS-related HAL functions to python semiwrap. |
| hal/src/main/python/semiwrap/DriverStation_c.yml | Exposes HAL_SendProgramCrash to C semiwrap. |
| hal/src/main/python/hal/src/hal.cpp | Updates to new DriverStation.hpp + WPI_String print callback signature. |
| hal/src/main/native/systemcore/HALInitializer.hpp | Removes legacy FIRST DS init symbol. |
| hal/src/main/native/systemcore/HAL.cpp | Stops calling removed FIRST DS initializer. |
| hal/src/main/native/systemcore/FIRSTDriverStation.cpp | Removes legacy systemcore DS implementation. |
| hal/src/main/native/systemcore/DriverStation.cpp | Provides systemcore default DS backend (mrclib). |
| hal/src/main/native/sim/HALInitializer.hpp | Removes legacy sim DS init symbol. |
| hal/src/main/native/sim/HAL.cpp | Drops redundant HAL_GetSystemTimeValid impl and relies on DS backend. |
| hal/src/main/native/sim/DriverStation.cpp | Reworks sim DS to an MrcLibDs implementation + updated callback signatures. |
| hal/src/main/native/include/wpi/hal/simulation/MockHooks.h | Updates mock hook callback typedefs to WPI_String. |
| hal/src/main/native/include/wpi/hal/DriverStationTypes.h | Adjusts HAL_MatchInfo::eventName sizing. |
| hal/src/main/native/include/wpi/hal/DriverStation.hpp | Adds C++ wrappers for SendError/SendConsoleLine/SendProgramCrash. |
| hal/src/main/native/include/wpi/hal/DriverStation.h | Changes C API signatures to use WPI_String + adds HAL_SendProgramCrash. |
| hal/src/main/native/include/wpi/hal/cpp/MrcLibDs.hpp | Introduces the backend interface for DS implementations. |
| hal/src/main/native/cpp/mrclib/MrcLibDs.cpp | Adds mrclib-backed DS implementation. |
| hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp | Updates lambdas for new HALSim DS callback signatures. |
| hal/src/main/native/cpp/jni/HALUtil.cpp | Updates HAL error reporting call to new HAL_SendError signature. |
| hal/src/main/native/cpp/jni/DriverStationJNI.cpp | Updates JNI signatures and adds sendProgramCrash. |
| hal/src/main/native/cpp/FIRSTDriverStation.cpp | Adds the HAL entrypoint layer routing calls to the selected DS backend. |
| hal/src/main/java/org/wpilib/hardware/hal/DriverStationJNI.java | Updates sendError signature and adds sendProgramCrash. |
| hal/build.gradle | Wires mrclib into native build dependencies. |
| hal/BUILD.bazel | Adds mrclib dependency for Bazel builds of hal. |
| glass/src/lib/native/cpp/other/FMS.cpp | Updates robot mode string from “Test” to “Utility”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+8
| #include <algorithm> | ||
| #include <exception> |
| // the WPILib BSD license file in the root directory of this project. | ||
|
|
||
| #include <atomic> | ||
| #include <cstdio> |
Comment on lines
+58
to
59
| static std::atomic<bool> gDSConnected = true; | ||
|
|
Comment on lines
+60
to
+66
| static void WriteSimBackend() { | ||
| MRC_Joysticks joysticks; | ||
| MRC_ControlData controlData; | ||
|
|
||
| client->data.connect([t](Buffer& buf, size_t len) { | ||
| HandleTcpDataStream(buf, len, *t->GetData<DataStore>()); | ||
| }); | ||
| client->StartRead(); | ||
| client->end.connect([c = client.get()] { | ||
| c->Close(); | ||
| gDSConnected = false; | ||
| }); | ||
| }); | ||
| } | ||
| int32_t status = | ||
| MRC_DsComms_GetControlDataWithJoysticks(&controlData, &joysticks); | ||
| if (status != 0) { |
Comment on lines
+70
to
+71
| printf("Control data status: 0x%x\n", controlData.controlFlags); | ||
| fflush(stdout); |
| artifactId = "mrclib-cpp" | ||
| headerClassifier = "headers" | ||
| ext = "zip" | ||
| version = '+' |
PeterJohnson
pushed a commit
that referenced
this pull request
May 15, 2026
The initial build file generation for robotpy projects was relatively naive and purpose built to get `allwpilib` compiling, without supporting all the available features. This modifies the generation scripts to be able to support multiple embedded libraries, which will be necessary for #8858, since `mrclib.so` will need to be bundled along with the hal libraries. In addition some cleanup was done to get the wheels looking more like what is in pypi.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.