Hey,
Does anyone have experience with programing rectangular swerve (either with SDS official code or not…)?
Does it affect any algorithm?
Could you explain what you mean by ‘rectangular’? I think you’re referring to a non-square drivebase. In that case, the module angle for the turning contribution is not exactly 45°, its the atan of length/2 and width/2 (in a square chassis, length and width are the same, so atan(length/2 / width/2) is 45°). I haven’t worked with any official code so someone else should be able to chime in.
If you mean rectangular as in not a square but still a rectangle with 90degree angles we have some experience. Last year and this year we made a swerve with a frame of 27’ width and 24’ length. All this did coding wise was change the kinematics numbers that you put in The built in kinematics does the math and takes care of the angle for you. The same should be the same with the base mk4 code and we have our code published on github if it helps.
I am not familiar with SDS code but the WPI lib asks for module positions to account for this and Strike Force’s third coast uses track width/length to account for it.
With the SDS code all you need to do is set up the Kinematics for your geometry you use the offsets from center of rotation for each module. If what you mean is non square. The example will work for a rectangle as well as a square because it sets based on track width and wheel base (length)
private final SwerveDriveKinematics m_kinematics = new SwerveDriveKinematics(
// Front left
new Translation2d(DrivetrainGeometry.TRACKWIDTH_METERS / 2.0, DrivetrainGeometry.WHEELBASE_METERS / 2.0),
// Front right
new Translation2d(DrivetrainGeometry.TRACKWIDTH_METERS / 2.0, -DrivetrainGeometry.WHEELBASE_METERS / 2.0),
// Back left
new Translation2d(-DrivetrainGeometry.TRACKWIDTH_METERS / 2.0, DrivetrainGeometry.WHEELBASE_METERS / 2.0),
// Back right
new Translation2d(-DrivetrainGeometry.TRACKWIDTH_METERS / 2.0, -DrivetrainGeometry.WHEELBASE_METERS / 2.0));
To clerify i meant a non square shape, rectangle with 90deg…
It is what @andrew2 is saying. Start from a point at the center of your rectangular chassis. Then use the Translation2d()
method to identify where your modules are relative to that point.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.