Skip to content

Commit

Permalink
Merge branch 'main' into factories-in-command-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputer314 committed Dec 8, 2024
2 parents aa15a53 + d5edb40 commit dcd36be
Show file tree
Hide file tree
Showing 96 changed files with 2,038 additions and 1,161 deletions.
56 changes: 56 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'2027':
- base-branch: '2027'
'component: apriltag':
- changed-files:
- any-glob-to-any-file: apriltag/**
'component: command-based':
- changed-files:
- any-glob-to-any-file: wpilibNewCommands/**
'component: cscore':
- changed-files:
- any-glob-to-any-file: cscore/**
'component: datalogtool':
- changed-files:
- any-glob-to-any-file: datalogtool/**
'component: epilogue':
- changed-files:
- any-glob-to-any-file: epilogue-*/**
'component: examples':
- changed-files:
- any-glob-to-any-file: wpilib*Examples/**
'component: glass':
- changed-files:
- any-glob-to-any-file: glass/**
'component: hal':
- changed-files:
- any-glob-to-any-file: hal/**
'component: ntcore':
- changed-files:
- any-glob-to-any-file: ntcore/**
'component: outlineviewer':
- changed-files:
- any-glob-to-any-file: outlineviewer/**
'component: sysid':
- changed-files:
- any-glob-to-any-file: sysid/**
'component: teamnumbersetter':
- changed-files:
- any-glob-to-any-file: roborioteamnumbersetter/**
'component: wpilibc':
- changed-files:
- any-glob-to-any-file: wpilibc/**
'component: wpilibj':
- changed-files:
- any-glob-to-any-file: wpilibj/**
'component: wpimath':
- changed-files:
- any-glob-to-any-file: wpimath/**
'component: wpinet':
- changed-files:
- any-glob-to-any-file: wpinet/**
'component: wpiunits':
- changed-files:
- any-glob-to-any-file: wpiunits/**
'component: wpiutil':
- changed-files:
- any-glob-to-any-file: wpiutil/**
2 changes: 1 addition & 1 deletion .github/workflows/comment-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: Install wpiformat
run: pip3 install wpiformat==2024.45
run: pip3 install wpiformat==2024.50
- name: Run wpiformat
run: wpiformat
- name: Run spotlessApply
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- container: wpilib/roborio-cross-ubuntu:2025-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
- container: wpilib/raspbian-cross-ubuntu:bookworm-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
- container: wpilib/aarch64-cross-ubuntu:bookworm-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
4 changes: 2 additions & 2 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat==2024.45
run: pip3 install wpiformat==2024.50
- name: Run
run: wpiformat
- name: Check output
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
with:
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat==2024.45
run: pip3 install wpiformat==2024.50
- name: Create compile_commands.json
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sentinel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- container: wpilib/roborio-cross-ubuntu:2025-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
- container: wpilib/raspbian-cross-ubuntu:bookworm-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
- container: wpilib/aarch64-cross-ubuntu:bookworm-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2025.7.1"
implementation "edu.wpi.first:native-utils:2025.9.0"
}
7 changes: 6 additions & 1 deletion developerRobot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ This command builds everything.

## Simulation

This command runs the C++ subproject on desktop.
This command runs the Java project on desktop.
```bash
./gradlew developerRobot:run
```

This command runs the C++ project on desktop.
```bash
./gradlew developerRobot:runCpp
```
Expand Down
3 changes: 3 additions & 0 deletions developerRobot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ dependencies {
implementation project(':cameraserver')
implementation project(':wpilibNewCommands')
implementation project(':apriltag')
implementation project(':wpiunits')
implementation project(':epilogue-runtime')
annotationProcessor project(':epilogue-processor')
}

tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ public String elementAccess(Element element) {

private static String fieldAccess(VariableElement field) {
if (field.getModifiers().contains(Modifier.PRIVATE)) {
// (com.example.Foo) $fooField.get(object)
return "(" + field.asType() + ") $" + field.getSimpleName() + ".get(object)";
// ((com.example.Foo) $fooField.get(object))
// Extra parentheses so cast evaluates before appended methods
// (e.g. when appending .getAsDouble())
return "((" + field.asType() + ") $" + field.getSimpleName() + ".get(object))";
} else {
// object.fooField
return "object." + field.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,32 @@

package edu.wpi.first.epilogue.processor;

import java.util.Optional;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;

public class SendableHandler extends ElementHandler {
private final TypeMirror m_sendableType;
private final TypeMirror m_commandType;
private final TypeMirror m_subsystemType;
private final Optional<TypeMirror> m_sendableType;
private final Optional<TypeMirror> m_commandType;
private final Optional<TypeMirror> m_subsystemType;

protected SendableHandler(ProcessingEnvironment processingEnv) {
super(processingEnv);

m_sendableType =
lookupTypeElement(processingEnv, "edu.wpi.first.util.sendable.Sendable").asType();
Optional.ofNullable(
lookupTypeElement(processingEnv, "edu.wpi.first.util.sendable.Sendable"))
.map(TypeElement::asType);
m_commandType =
lookupTypeElement(processingEnv, "edu.wpi.first.wpilibj2.command.Command").asType();
Optional.ofNullable(
lookupTypeElement(processingEnv, "edu.wpi.first.wpilibj2.command.Command"))
.map(TypeElement::asType);
m_subsystemType =
lookupTypeElement(processingEnv, "edu.wpi.first.wpilibj2.command.SubsystemBase").asType();
Optional.ofNullable(
lookupTypeElement(processingEnv, "edu.wpi.first.wpilibj2.command.SubsystemBase"))
.map(TypeElement::asType);
}

@Override
Expand All @@ -30,20 +38,28 @@ public boolean isLoggable(Element element) {

// Accept any sendable type. However, the log invocation will return null
// for sendable types that should not be logged (commands, subsystems)
return m_processingEnv.getTypeUtils().isAssignable(dataType, m_sendableType);
return m_sendableType
.map(t -> m_processingEnv.getTypeUtils().isAssignable(dataType, t))
.orElse(false);
}

@Override
public String logInvocation(Element element) {
var dataType = dataType(element);

if (m_processingEnv.getTypeUtils().isAssignable(dataType, m_commandType)
|| m_processingEnv.getTypeUtils().isAssignable(dataType, m_subsystemType)) {
// Do not log commands or subsystems via their sendable implementations
// We accept all sendable objects to prevent them from being reported as not loggable,
// but their sendable implementations do not include helpful information.
// Users are free to provide custom logging implementations for commands, and tag their
// subsystems with @Logged to log their contents automatically
// Do not log commands or subsystems via their sendable implementations
// We accept all sendable objects to prevent them from being reported as not loggable,
// but their sendable implementations do not include helpful information.
// Users are free to provide custom logging implementations for commands, and tag their
// subsystems with @Logged to log their contents automatically
if (m_commandType
.map(t -> m_processingEnv.getTypeUtils().isAssignable(dataType, t))
.orElse(false)) {
return null;
}
if (m_subsystemType
.map(t -> m_processingEnv.getTypeUtils().isAssignable(dataType, t))
.orElse(false)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public ExampleLogger() {
@Override
public void update(EpilogueBackend backend, Example object) {
if (Epilogue.shouldLog(Logged.Importance.DEBUG)) {
backend.log("x", (double) $x.get(object));
backend.log("x", ((double) $x.get(object)));
}
}
}
Expand All @@ -252,6 +252,59 @@ public void update(EpilogueBackend backend, Example object) {
assertLoggerGenerates(source, expectedGeneratedSource);
}

@Test
void privateSuppliers() {
String source =
"""
package edu.wpi.first.epilogue;
import java.util.function.DoubleSupplier;
@Logged
class Example {
private DoubleSupplier x;
}
""";

String expectedGeneratedSource =
"""
package edu.wpi.first.epilogue;
import edu.wpi.first.epilogue.Logged;
import edu.wpi.first.epilogue.Epilogue;
import edu.wpi.first.epilogue.logging.ClassSpecificLogger;
import edu.wpi.first.epilogue.logging.EpilogueBackend;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
public class ExampleLogger extends ClassSpecificLogger<Example> {
private static final VarHandle $x;
static {
try {
var lookup = MethodHandles.privateLookupIn(Example.class, MethodHandles.lookup());
$x = lookup.findVarHandle(Example.class, "x", java.util.function.DoubleSupplier.class);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("[EPILOGUE] Could not load private fields for logging!", e);
}
}
public ExampleLogger() {
super(Example.class);
}
@Override
public void update(EpilogueBackend backend, Example object) {
if (Epilogue.shouldLog(Logged.Importance.DEBUG)) {
backend.log("x", ((java.util.function.DoubleSupplier) $x.get(object)).getAsDouble());
}
}
}
""";

assertLoggerGenerates(source, expectedGeneratedSource);
}

@Test
void privateWithGenerics() {
String source =
Expand Down Expand Up @@ -294,7 +347,7 @@ public ExampleLogger() {
@Override
public void update(EpilogueBackend backend, Example object) {
if (Epilogue.shouldLog(Logged.Importance.DEBUG)) {
logSendable(backend.getNested("chooser"), (edu.wpi.first.wpilibj.smartdashboard.SendableChooser<java.lang.String>) $chooser.get(object));
logSendable(backend.getNested("chooser"), ((edu.wpi.first.wpilibj.smartdashboard.SendableChooser<java.lang.String>) $chooser.get(object)));
}
}
}
Expand Down Expand Up @@ -1503,7 +1556,7 @@ public ExampleLogger() {
@Override
public void update(EpilogueBackend backend, Example object) {
if (Epilogue.shouldLog(Logged.Importance.DEBUG)) {
var $$theField = (edu.wpi.first.epilogue.I) $theField.get(object);
var $$theField = ((edu.wpi.first.epilogue.I) $theField.get(object));
if ($$theField instanceof edu.wpi.first.epilogue.Base edu_wpi_first_epilogue_Base) {
Epilogue.baseLogger.tryUpdate(backend.getNested("theField"), edu_wpi_first_epilogue_Base, Epilogue.getConfig().errorHandler);
} else {
Expand Down
2 changes: 1 addition & 1 deletion shared/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nativeUtils {
configureDependencies {
opencvYear = "frc2025"
niLibVersion = "2025.0.0"
opencvVersion = "4.8.0-2"
opencvVersion = "4.10.0-3"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion shared/opencv.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def opencvVersion = '4.8.0-2'
def opencvVersion = '4.10.0-3'

if (project.hasProperty('useCpp') && project.useCpp) {
model {
Expand Down
4 changes: 2 additions & 2 deletions upstream_utils/sleipnir.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def copy_upstream_src(wpilib_root):
def main():
name = "sleipnir"
url = "https://github.com/SleipnirGroup/Sleipnir"
# main on 2024-09-18
tag = "8bbce85252bc351c5aacb0de9f50fa31b8b9e1ae"
# main on 2024-12-07
tag = "01206ab17d741f4c45a7faeb56b8a5442df1681c"

sleipnir = Lib(name, url, tag, copy_upstream_src)
sleipnir.main()
Expand Down
Loading

0 comments on commit dcd36be

Please sign in to comment.