BroncBotz3481/YAGSL

Tuning webpage puts "conversionFactor" in the wrong file

Closed this issue · 2 comments

I generated a config for SwerveDrive using https://broncbotz3481.github.io/YAGSL-Example/, and the robot code reports:

Unrecognized field "conversionFactor" (class swervelib.parser.json.SwerveDriveJson), not marked as ignorable (3 known properties: "imu", "invertedIMU", "modules"]) at [Source: (File); line: 8, column: 24] (through reference chain: swervelib.parser.json.SwerveDriveJson["conversionFactor"])

If I remove conversionFactor from swerveDrive.json, the code crashes again (but differently):

Error at swervelib.parser.SwerveParser.createSwerveDrive(SwerveParser.java:139): Unhandled exception: java.lang.NullPointerException: Cannot assign field "angle" because "swervelib.parser.SwerveParser.physicalPropertiesJson.conversionFactor" is null

Since SwerveParser.java gets the angle and drive conversion factors from physicalproperties.json,

  public SwerveDrive createSwerveDrive(SimpleMotorFeedforward driveFeedforward, double maxSpeed,
                                       double angleMotorConversionFactor, double driveMotorConversion)
  {
    physicalPropertiesJson.conversionFactor.angle = angleMotorConversionFactor;
    physicalPropertiesJson.conversionFactor.drive = driveMotorConversion;
    return createSwerveDrive(driveFeedforward, maxSpeed);
  }

I tried moving "conversionFactor" to physicalProperties.json, and the code works.

Sorry! I mustve misread my own notes! I will fix this tonight.

Just fixed that! Thank you for pointing it out!