My team uses kotlin, and for some reason when we use advantagekit’s recordOutputs method and pass in an array of swervmodulestates, it throws an error. our code is linked HERE
For SwerveModuleStates
and similar objects, I think you need to specify the the array size for AdvantageKit to log it properly. I don’t think swerveDrive.states from YAGSL defines the array size due to it being variable on how you set it up. See the Recording Outputs section of the AdvantageKit Docs on how to log the states.
Even if I pass in something like this it throws the same error
var states: Array<SwerveModuleState> = arrayOf(
SwerveModuleState(0.0, Rotation2d.fromDegrees(0.0)),
SwerveModuleState(0.0, Rotation2d.fromDegrees(0.0)),
SwerveModuleState(0.0, Rotation2d.fromDegrees(0.0)),
SwerveModuleState(0.0, Rotation2d.fromDegrees(0.0)),)
For structs, recordOutput
uses a vararg parameter to accept either an array or list of parameters in Java. For Kotlin, to looks like you need to use the spread operator to pass in an array:
Logger.recordOutput("Swerve States", *swerveDrive.states);
Let me know if you’re still seeing any issues after that change.
Alright thank you, I wont be able to test until at least Tuesday unfortunately
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.