Hello! In the YAGSL Docs , the instructions say to create a swerve drive object. Do we put this in the Swerve Drive class, and where specifically? Or is this done automatically through the JSON files? Thank you!
1 Like
nstrike
December 28, 2023, 2:54am
2
The way i recommend is this.
/**
* Initialize {@link SwerveDrive} with the directory provided.
*
* @param directory Directory of swerve drive config files.
*/
public SwerveSubsystem(File directory)
{
// Angle conversion factor is 360 / (GEAR RATIO * ENCODER RESOLUTION)
// In this case the gear ratio is 12.8 motor revolutions per wheel rotation.
// The encoder resolution per motor revolution is 1 per motor revolution.
double angleConversionFactor = SwerveMath.calculateDegreesPerSteeringRotation(12.8, 1);
// Motor conversion factor is (PI * WHEEL DIAMETER IN METERS) / (GEAR RATIO * ENCODER RESOLUTION).
// In this case the wheel diameter is 4 inches, which must be converted to meters to get meters/second.
// The gear ratio is 6.75 motor revolutions per wheel rotation.
// The encoder resolution per motor revolution is 1 per motor revolution.
double driveConversionFactor = SwerveMath.calculateMetersPerRotation(Units.inchesToMeters(4), 6.75, 1);
System.out.println("\"conversionFactor\": {");
System.out.println("\t\"angle\": " + angleConversionFactor + ",");
System.out.println("\t\"drive\": " + driveConversionFactor);
System.out.println("}");
This file has been truncated. show original