Skip to content

Commit

Permalink
Update for 2025 firmware (#9)
Browse files Browse the repository at this point in the history
* Update for 2025 firmware

* Update to 2025

* Update actions version

* Update actions version
  • Loading branch information
jwbonner authored Nov 12, 2024
1 parent 61f29d1 commit f753e13
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 76 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
- name: Build with Gradle
run: ./gradlew build --max-workers 1 ${{ matrix.build-options }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
architecture: ${{ matrix.architecture }}
- name: Build with Gradle
run: ./gradlew build -Pbuildalldesktop
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs
Expand All @@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/build-tools
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: combiner/products/build/allOutputs
- name: Flatten Artifacts
Expand All @@ -85,7 +85,7 @@ jobs:
- name: Combine
run: ./gradlew publish -Pthirdparty
working-directory: combiner
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Maven
path: ~/releases/maven/development/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ By default, this project builds against the latest WPILib development build. To

## Data Format

### Revision 2
### Revision 2/3

Revision 2 = 2024, Revision 3 = 2025 (no model frames)

- "Raw/Persistent"
- Buffer Length, Not Published (uint32)
Expand Down
16 changes: 8 additions & 8 deletions URCL.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"fileName": "URCL.json",
"name": "URCL",
"version": "2024.1.0",
"frcYear": "2024",
"version": "2025.0.0-beta-1",
"frcYear": "2025",
"uuid": "84246d17-a797-4d1e-bd9f-c59cd8d2477c",
"mavenUrls": [
"https://raw.githubusercontent.com/Mechanical-Advantage/URCL/2024.1.0"
"https://raw.githubusercontent.com/Mechanical-Advantage/URCL/2025.0.0-beta-1"
],
"jsonUrl": "https://raw.githubusercontent.com/Mechanical-Advantage/URCL/maven/URCL.json",
"javaDependencies": [
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-java",
"version": "2024.1.0"
"version": "2025.0.0-beta-1"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-driver",
"version": "2024.1.0",
"version": "2025.0.0-beta-1",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
Expand All @@ -34,7 +34,7 @@
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-cpp",
"version": "2024.1.0",
"version": "2025.0.0-beta-1",
"libName": "URCL",
"headerClassifier": "headers",
"sharedLibrary": false,
Expand All @@ -49,7 +49,7 @@
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-driver",
"version": "2024.1.0",
"version": "2025.0.0-beta-1",
"libName": "URCLDriver",
"headerClassifier": "headers",
"sharedLibrary": false,
Expand All @@ -62,4 +62,4 @@
]
}
]
}
}
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'cpp'
id 'java'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'edu.wpi.first.NativeUtils' version '2024.6.1'
id 'edu.wpi.first.NativeUtils' version '2025.3.0'
id 'edu.wpi.first.GradleJni' version '1.1.0'
id 'edu.wpi.first.GradleVsCode' version '2.1.0'
}
Expand Down Expand Up @@ -33,7 +33,6 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4"
implementation "com.fasterxml.jackson.core:jackson-core:2.12.4"
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4"
// implementation 'edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:4.8.0-2'
}

// Set up exports properly
Expand Down Expand Up @@ -98,5 +97,5 @@ model {
apply from: 'publish.gradle'

wrapper {
gradleVersion '8.4'
gradleVersion '8.10.2'
}
4 changes: 1 addition & 3 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ nativeUtils {
configureDependencies {
wpiVersion = "2025.+"
opencvYear = "frc2024"
googleTestYear = "frc2024"
niLibVersion = "2025.0.0"
opencvVersion = "4.8.0-2"
googleTestVersion = "1.14.0-1"
opencvVersion = "4.8.0-4"
}
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'maven-publish'

ext.licenseFile = files("$rootDir/LICENSE.txt")

def pubVersion = '2024.1.0'
def pubVersion = '2025.0.0-beta-1'

def outputsFolder = file("$buildDir/outputs")

Expand Down
37 changes: 6 additions & 31 deletions src/main/driver/cpp/URCLDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ extern "C" {
constexpr HAL_CANManufacturer manufacturer = HAL_CAN_Man_kREV;
constexpr HAL_CANDeviceType deviceType = HAL_CAN_Dev_kMotorController;

constexpr int firmwareApi = 0x98;
constexpr int firmwareApiClass = 9;
constexpr int firmwareApiIndex = 8;
constexpr int firmwareApi =
(firmwareApiClass & 0x3f) << 4 | (firmwareApiIndex & 0xf);
constexpr int firmwareMessageId = ((deviceType & 0x1f) << 24) |
((manufacturer & 0xff) << 16) |
((firmwareApi & 0x3ff) << 6);
constexpr int firmwareMessageIdMask = 0x1fffffc0;

constexpr int modelApi =
0x300 | 155; // Parameter Access | Parameter Number (Device Model)
constexpr int modelMessageId = ((deviceType & 0x1f) << 24) |
((manufacturer & 0xff) << 16) |
((modelApi & 0x3ff) << 6);
constexpr int modelMessageIdMask = 0x1fffffc0;

constexpr int periodicApiClass = 6; // Periodic Status
constexpr int periodicApiClass = 46;
constexpr int periodicMessageId = ((deviceType & 0x1f) << 24) |
((manufacturer & 0xff) << 16) |
((periodicApiClass & 0x3f) << 10);
Expand All @@ -46,14 +42,12 @@ char *periodicBuffer;
int32_t halStatus;
uint32_t timeOffsetMillis;
uint32_t firmwareStreamHandle;
uint32_t modelStreamHandle;
uint32_t periodicStreamHandle;
uint32_t persistentMessageCount = 0;

uint32_t readCount = 0;
uint64_t devicesFound = 0;
uint64_t devicesFirmwareReceived = 0;
uint64_t devicesModelReceived = 0;
uint64_t devicesCANReady = 0;
HAL_CANHandle devicesCANHandles[64];

Expand All @@ -68,9 +62,6 @@ void URCLDriver_start(void) {
HAL_CAN_OpenStreamSession(&firmwareStreamHandle, firmwareMessageId,
firmwareMessageIdMask, maxPersistentMessages,
&halStatus);
HAL_CAN_OpenStreamSession(&modelStreamHandle, modelMessageId,
modelMessageIdMask, maxPersistentMessages,
&halStatus);
HAL_CAN_OpenStreamSession(&periodicStreamHandle, periodicMessageId,
periodicMessageIdMask, maxPeriodicMessages,
&halStatus);
Expand Down Expand Up @@ -132,22 +123,16 @@ void URCLDriver_read(void) {
if (readCount >= 20) {
readCount = 0;
uint64_t unknownFirmwareDevices = devicesFound & ~devicesFirmwareReceived;
uint64_t unknownModelDevices = devicesFound & ~devicesModelReceived;
for (uint8_t i = 0; i < 64; i++) {
bool unknownFirmware = (unknownFirmwareDevices >> i) & 1;
bool unknownModel = (unknownModelDevices >> i) & 1;
if ((unknownFirmware || unknownModel) &&
((devicesCANReady >> i) & 1) == 0) {
if (unknownFirmware && ((devicesCANReady >> i) & 1) == 0) {
devicesCANHandles[i] =
HAL_InitializeCAN(manufacturer, i, deviceType, &halStatus);
devicesCANReady |= (uint64_t)1 << i;
}
if (unknownFirmware) {
HAL_WriteCANRTRFrame(devicesCANHandles[i], 0, firmwareApi, &halStatus);
}
if (unknownModel) {
HAL_WriteCANRTRFrame(devicesCANHandles[i], 0, modelApi, &halStatus);
}
}
}

Expand All @@ -165,16 +150,6 @@ void URCLDriver_read(void) {
devicesFirmwareReceived |= (uint64_t)1 << deviceId;
}

// Read model messages
HAL_CAN_ReadStreamSession(modelStreamHandle, messages, maxPersistentMessages,
&messageCount, &halStatus);
for (uint32_t i = 0; i < messageCount; i++) {
writeMessagePersistent(messages[i]);
uint8_t deviceId = messages[i].messageID & 0x3f;
devicesFound |= (uint64_t)1 << deviceId;
devicesModelReceived |= (uint64_t)1 << deviceId;
}

// Read periodic messages
HAL_CAN_ReadStreamSession(periodicStreamHandle, messages, maxPeriodicMessages,
&messageCount, &halStatus);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/littletonrobotics/urcl/URCL.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public static void start(Map<Integer, String> aliases) {
// Start publishers
persistentPublisher = NetworkTableInstance.getDefault()
.getRawTopic("/URCL/Raw/Persistent")
.publish("URCLr2_persistent");
.publish("URCLr3_persistent");
periodicPublisher = NetworkTableInstance.getDefault()
.getRawTopic("/URCL/Raw/Periodic")
.publish("URCLr2_periodic");
.publish("URCLr3_periodic");
aliasesPublisher = NetworkTableInstance.getDefault()
.getRawTopic("/URCL/Raw/Aliases")
.publish("URCLr2_aliases");
.publish("URCLr3_aliases");
notifier = new Notifier(() -> {
var data = getData();
persistentPublisher.set(data[0]);
Expand Down Expand Up @@ -137,9 +137,9 @@ public static void start(Map<Integer, String> aliases, DataLog log) {
periodicBuffer.order(ByteOrder.LITTLE_ENDIAN);

persistentLogEntry = new RawLogEntry(log, "URCL/Raw/Persistent", "",
"URCLr2_persistent");
periodicLogEntry = new RawLogEntry(log, "/URCL/Raw/Periodic", "", "URCLr2_periodic");
aliasLogEntry = new RawLogEntry(log, "/URCL/Raw/Aliases", "", "URCLr2_aliases");
"URCLr3_persistent");
periodicLogEntry = new RawLogEntry(log, "/URCL/Raw/Periodic", "", "URCLr3_periodic");
aliasLogEntry = new RawLogEntry(log, "/URCL/Raw/Aliases", "", "URCLr3_aliases");
notifier = new Notifier(() -> {
var data = getData();
persistentLogEntry.update(data[0]);
Expand Down
12 changes: 6 additions & 6 deletions src/main/native/cpp/URCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ void URCL::Start(std::map<int, std::string_view> aliases) {
// Start publishers
persistentPublisher = nt::NetworkTableInstance::GetDefault()
.GetRawTopic("/URCL/Raw/Persistent")
.Publish("URCLr2_persistent");
.Publish("URCLr3_persistent");
periodicPublisher = nt::NetworkTableInstance::GetDefault()
.GetRawTopic("/URCL/Raw/Periodic")
.Publish("URCLr2_periodic");
.Publish("URCLr3_periodic");
aliasesPublisher = nt::NetworkTableInstance::GetDefault()
.GetRawTopic("/URCL/Raw/Aliases")
.Publish("URCLr2_aliases");
.Publish("URCLr3_aliases");

aliasesPublisher.Set(aliasesVector);

Expand Down Expand Up @@ -134,11 +134,11 @@ void URCL::Start(std::map<int, std::string_view> aliases,
periodicBuffer = URCLDriver_getPeriodicBuffer();

persistentLogEntry = wpi::log::RawLogEntry{log, "/URCL/Raw/Persistent", "",
"URCLr2_persistent"};
"URCLr3_persistent"};
periodicLogEntry =
wpi::log::RawLogEntry{log, "/URCL/Raw/Periodic", "", "URCLr2_periodic"};
wpi::log::RawLogEntry{log, "/URCL/Raw/Periodic", "", "URCLr3_periodic"};
aliasesLogEntry =
wpi::log::RawLogEntry{log, "/URCL/Raw/Aliases", "", "URCLr2_aliases"};
wpi::log::RawLogEntry{log, "/URCL/Raw/Aliases", "", "URCLr3_aliases"};

aliasesLogEntry.Append(aliasesVector);

Expand Down

0 comments on commit f753e13

Please sign in to comment.