We are creating swerve code for our sds mk4 drive. We’re using neos with can spark maxes and the navx2. We currently do not have any absolute encoders, we’re just manually resetting them to zero for now.
The issue is that the lateral movement is working perfectly fine but rotation does not. When the robot rotates, the wheels properly go at the 45 degree angle each (i.e making an octagon) but the drive motors are not going the right direction. For instance, when inputting a positive omega, the backleft and frontright drive motors are driving in the wrong direction.
We’ve ensured that:
turning CCW on the navx is positive
turning the rotation motor of the wheels CCW is positive
The bevels are facing left
turning the drive motors CCW is positive
We’ve checked all of that to the best of our ability, there is a chance we might’ve made a mistake so if our issue sounds like something is wrong concerning the inversion of inputs then we can check again
I know you said you confirmed the orientation of things, but I’d recommend running through these steps one by one just to be 100% sure. If you have things double-inverted, it very easily could behave this way (lateral movement will still work correctly, but rotation will be backwards)
Thank you for your response! We appreciate the help.
We checked everything (drive encoders, rotation encoders and navx) and did find that our navx needed to be inverted. We still have the same issue with the rotation unfortunately.
Yes, we’ve tested on the ground. The Swervedrive sits there because the wheels fight each other. And I will say I think no to “translational axis changing based off of your robot heading?” but I don’t quite understand what that means. The heading shouldn’t have anything to do with it, as the drive method we’re using on SwerveDrive is robot oriented.
Here’s a simple diagram to show how the wheels are moving incorrectly
I will also note that when we inverted the navx, all the wheels switched drive direction (i.e the wheels that were driving in the correct direction are now not and the the wheels that were driving in the wrong direction are now correct.)
The graphic is very helpful! Have you tried switching the ID’s for your back left and front right modules. I think you may have swapped those by accident.
Actually on further inspection this wasn’t exactly the case.
We swapped the ids of the front right module and the back left module and it worked. But we checked the rev hardware client and the ids were correct. So having the ids swapped incorrectly is making it work. If I had to guess we have another configuration issue that this wrong configuration is fixing but eh, if it works it works.
EDIT: We figured out that the locations of our modules were incorrect. In essence, swapping the wheel ids was a bandaid fix on that issue.
The only other possible explanation which is less likely is you didn’t have your bevels facing left when getting the absolute encoder offset or used a negative of what you were reading, or you got the front and back mixed up