Skip to content

Commit

Permalink
Merge pull request #709 from Autodesk/wpilib-2021
Browse files Browse the repository at this point in the history
Update Emulator for WPILib 2021.2.2 Support
  • Loading branch information
MattMoradi authored Mar 31, 2021
2 parents 80d0b20 + 5401c4f commit 0f88db0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
3 changes: 1 addition & 2 deletions emulation/hel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ OPTION(BUILD_DOC "Enable building of documentation" OFF)

SET(DEFAULT_BUILD_TYPE "Release")
SET(DEFAULT_GRPC_VERSION "v1.21.4")
SET(DEFAULT_WPILIB_VERSION "v2020.3.2")
#SET(DEFAULT_NILIB_VERSION "v2019-12")
SET(DEFAULT_WPILIB_VERSION "v2021.2.2")
SET(DEFAULT_NILIB_VERSION "main")

IF(NOT CMAKE_CONFIGURATION_TYPES)
Expand Down
8 changes: 8 additions & 0 deletions emulation/hel/src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <cstdio>
#include <fstream>

#include <FRC_NetworkCommunication/LoadOut.h>

#define LIBHEL_VERSION "1.1.0" // Major, minor, patch
#define VIRTUAL_MACHINE_INFO_PATH "/home/lvuser/.vminfo"
#define SERVER_CONFIG_PATH "/home/lvuser/.grpc_config"
Expand Down Expand Up @@ -52,3 +54,9 @@ namespace nFPGA {
unsigned int g_currentTargetClass; //Ni FPGA declares this as extern, so define it here
}
}

namespace nLoadOut {
tTargetClass EXPORT_FUNC getTargetClass() {
return (tTargetClass) nFPGA::nRoboRIO_FPGANamespace::g_currentTargetClass;
}
}
8 changes: 5 additions & 3 deletions emulation/hel/src/interrupt_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ namespace nFPGA{
}).detach();
}

uint32_t tInterruptManager::watch(int32_t /*timeoutInMs*/, bool /*ignorePrevious*/, tRioStatusCode* /*status*/){
hel::warnUnsupportedFeature("Function call tInterruptManager::watch");
return 0;
uint32_t tInterruptManager::watch(int32_t timeoutInMs, bool ignorePrevious, tRioStatusCode* /*status*/){
// hel::warnUnsupportedFeature("Function call tInterruptManager::watch");
if(timeoutInMs == 10000 && ignorePrevious == false)
return !0;
return 0;
}

void tInterruptManager::enable(tRioStatusCode* /*status*/){
Expand Down
31 changes: 26 additions & 5 deletions emulation/java_vm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

FROM ubuntu:18.04 AS builder

ENV WPILIB_VERSION v2020.3.2
ENV SYNTHESIS_BRANCH emulator-restore
ENV WPILIB_VERSION v2021.2.2
ENV SYNTHESIS_BRANCH wpilib-2021
ENV TEMPPATH /temp
ENV PATH $TEMPPATH/bin:$PATH

Expand Down Expand Up @@ -69,7 +69,27 @@ RUN ${ENTER_HEL}/../java_vm/wpi_cross && \
patch -p0 < ../AddressableLED.patch && \
patch -p0 < ../FRCDriverStation.patch && \
./gradlew halBaseLinuxx86-64ReleaseSharedLibrary halJNILinuxx86-64ReleaseSharedLibrary :wpilibj:assemble && \
(./gradlew wpilibj:build || true) # This gradle build step will fail, but that's okay
(./gradlew wpilibj:build || true)
RUN ${ENTER_HEL}/../java_vm/wpi_cross/allwpilib && \
cp wpilibc/src/main/native/include/frc wpilibOldCommands/src/main/native/include -r -f && \
cp wpilibc/src/main/native/include/frc2 wpilibOldCommands/src/main/native/include -r -f && \
cp wpiutil/src/main/native/include/wpi wpilibOldCommands/src/main/native/include -r -f && \
cp ntcore/src/main/native/include/* wpilibOldCommands/src/main/native/include -r -f && \
cp hal/src/main/native/include/* wpilibOldCommands/src/main/native/include -r -f && \
cp wpimath/src/main/native/include/* wpilibOldCommands/src/main/native/include -r -f && \
cp hal/build/generated/headers/* wpilibOldCommands/src/main/native/include -r -f && \
./gradlew wpilibOldCommandsBaseLinuxx86-64DebugSharedLibrary
RUN ${ENTER_HEL}/../java_vm/wpi_cross/allwpilib && \
cp wpilibc/src/main/native/include/frc wpilibNewCommands/src/main/native/include -r -f && \
cp wpilibc/src/main/native/include/frc2 wpilibNewCommands/src/main/native/include -r -f && \
cp wpiutil/src/main/native/include/wpi wpilibNewCommands/src/main/native/include -r -f && \
cp ntcore/src/main/native/include/* wpilibNewCommands/src/main/native/include -r -f && \
cp hal/src/main/native/include/* wpilibNewCommands/src/main/native/include -r -f && \
cp wpimath/src/main/native/include/* wpilibNewCommands/src/main/native/include -r -f && \
cp wpimath/src/main/native/eigeninclude/Eigen wpilibNewCommands/src/main/native/include -r -f && \
cp hal/build/generated/headers/* wpilibNewCommands/src/main/native/include -r -f && \
./gradlew wpilibNewCommandsBaseLinuxx86-64DebugSharedLibrary


# Move needed files into one location
RUN mkdir $TEMPPATH/to_copy && \
Expand All @@ -90,9 +110,9 @@ RUN echo 'root:root' | chpasswd

RUN apt-get -y update

RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends tzdata
RUN DEBIAN_FRONTEND="noninteractive" apt install -y --no-install-recommends tzdata

RUN apt-get -y install --no-install-recommends \
RUN apt -y install --no-install-recommends \
linux-image-generic:amd64 \
systemd-sysv \
dbus \
Expand Down Expand Up @@ -135,6 +155,7 @@ RUN mv -n ./libhel.so \
./libcscorejni.so \
./libcscored.so \
./libopencv*.so* \
./libwpilib*Commands*.so* \
./libntcorejni.so \
./libntcored.so \
/lib/
Expand Down
23 changes: 12 additions & 11 deletions emulation/java_vm/wpi_cross/FRCDriverStation.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
--- ./hal/src/main/native/sim/FRCDriverStation.cpp 2020-12-30 02:01:20.371892128 -0500
+++ ./hal/src/main/native/sim/FRCDriverStation2.cpp 2020-12-30 02:02:19.458557374 -0500
@@ -292,6 +292,10 @@
--- ./hal/src/main/native/sim/FRCDriverStation.cpp 2021-03-27 16:47:26.558444755 -0700
+++ ./hal/src/main/native/sim/FRCDriverStation2.cpp 2021-03-27 16:47:13.921777667 -0700
@@ -288,6 +288,11 @@
}
}

+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+
+#pragma GCC diagnostic push
+#if defined(__GNUC__) && (__GNUC__ > 8)
+ #pragma GCC diagnostic ignored "-Wstringop-truncation"
+ #pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
char* HAL_GetJoystickName(int32_t joystickNum) {
HAL_JoystickDescriptor joystickDesc;
if (HAL_GetJoystickDescriptor(joystickNum, &joystickDesc) < 0) {
@@ -307,6 +311,8 @@
@@ -303,6 +308,8 @@
}
}

+#pragma GCC diagnostic pop
+
void HAL_FreeJoystickName(char* name) { std::free(name); }

int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis) {
void HAL_FreeJoystickName(char* name) {
std::free(name);
}

0 comments on commit 0f88db0

Please sign in to comment.