AutoLog Annotation Kotlin Support
Opened this issue · 2 comments
When using the AutoLog decorator I'm not seeing the classes it's supposed to generate. I have this in my build.gradle
, which looks like it's supposed to set up autolog:
dependencies {
....
def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version"
}
Here's the AutoLog code:
@AutoLog
class IntakeInputs {
var feedVelocityHz = Rotation2d()
var rollersVelocityHz = Rotation2d()
}
I've checked the build/
folder for the classes, but I don't see anything. Building also fails because IntakeInputsAutoLogged
doesn't exist.
Here's the setup I'm using:
- Kotlin 1.9.22
- AdvantageKit 3.0.0
- Intellij IDEA
While I don't have a lot of experience with Kotlin, my understanding is that Java annotation processors aren't compatible with Kotlin code. Kotlin has alternative annotation processing systems (Kapt and KSP), which have different APIs. Unfortunately, that means you'll need to write the toLog
and fromLog
methods on the inputs class manually. As far as I know, all of the other standard features of AdvantageKit are compatible with Kotlin.
In addition, while browsing code online, I found this really cool kotlin AutoLog implementation from 9432. We personally use a custom implementation that's slightly different than the loggable inputs model of advantagekit, but for most teams, this probably does the job.
Note: this implementation doesn't include implementations for Pose2d and the Translation/Transform classes, as well as wpilib's unit system. You also need to mark the class as open in order for it to be extendable.