Conversation
|
This PR also creates an empty Drivetrain class and a new launch file to make it easier to add to later. |
|
Apparently, we have a rectangular swerve drive, so we need to rewrite the code for that. |
|
Swerve finished |
GalexY727
left a comment
There was a problem hiding this comment.
I didn't make it through pose2d, translation2d, or rotation2d, and think that it might be beneficial to have unit tests for them which we can probably steal from wpilib directly. We would want that on some other directory, but still accessible from the main repository, most likely. Maybe it would be enough to have them ran through GitHub Actions, but that seems a little extra.
Overall, looks good! I left a lot of mostly cosmetic comments, but do want you to quickly look at the one regarding swerve::optimize, regarding the modulus operator. Well done Kyle!
|
Regarding the switch to swerve, however, I think it might be useful to keep the legacy drivetrain code in case we ever decide to switch off of swerve, even if it is in a year. I don't think it's as easy as just making an IO implementation, but it can still be a lone, untouched file without causing any collateral damage. |
|
I added the old SlugbotDriver code in a commented out file so we can reference it in the future if needed. I don't think we need the Webots code, since it basically just sets the motors. |
|
Great judgment, thank you! |
|
Is this ready for merging or should we wait for something like cad so we can set track width? |
|
We should not merge this yet. |
This PR will improve the drivetrain speed and angle calculations. Previously, we made the wheels turn to turn the robot, which allowed the robot to drive without completely breaking the simulator physics. However, it still wasn't completely accurate, since the outer wheels have to travel a longer distance than the inner wheels, while the current code just drives them at the same speed.
To fix this, I modeled the robot's driving as following a circular path directly to the left or right of the center wheels. I calculate the radius of that circle, then figure out the speeds needed for each wheel to follow that path. The front and back wheels now rotate to be tangent to that circle as well.
The code in SlugbotDriver will not need to change if we switch to 4 wheels instead of 6., since the back wheels follow the circle the same way as the front ones. The center of the circle will be in line with the non-turning wheels instead of the center wheels.
This might not be perfect yet since there is a constant at the top of the code for the distance between wheels on the same side, but I don't want to try to get that from the proto file when we are getting the real CAD soon.