Swerve Drive/ Thrifty Encoder

All of our values appear correct the state equals the goal everything seems correct. I’ve talked to other team mentors and he was confused aswell as he helped me with the code and his team has built a swerve aswell

So this offseason is my teams first time ever trying to build a swerve, we started with a prototype robot and now they’re waiting for the code to be working. We use timed robot code as it is the only code I’ve been taught to use. When I run the code all the wheels run in the correct directions but as soon as I try to move the directions of the swerve module then they all move to random directions, I’ve logged the data like the pid controllers goal and it matches up with the desired state of each module. Any ideas on what’s my issue?

Can we get a link to your code in github? Maybe a screenshot or two of the logs? Graphs from advantage scope could be very helpful.

1 Like

Try this project, the gitbook outlines everything to do and where you might run into errors.

We need a bit more information on your swerve. What type of swerve modules do you have? Have you set a zero (or offset) for your azimuth encoders?

It sounds like you have the offset all at 0. Typically, you need to move the modules to their zero position, read the current position (for each), and set an offset for each module in the code.

The reason for this is that the encoder reads the magnet location to set an absolute position within 1 turn. Unless you assembled them with the magnet at exactly the right position (very unlikely), they don’t know where zero is supposed to be.

It could also happen if you use an offset in your cide that’s not set on the sparkmax when you have an absolute encoder attached.

I believe your teammate has a thread on this issue here:

Yes I believe this is the code. If not he has sent the link to the github page somewhere else in this page.

I like the idea of using this though no one in our team really knows how to use command based

It’s mk4i swerve

I want to suggest for you to use YAGSL (Welcome to Yet Another Swerve Document | YAGSL) to setup and use as it will handle many of the edge cases and is fairly easy to setup.

However if you’re doing this not to get your robot up and running as fast as possible and mainly for learning experiences keep at it!

1 Like

Problem solved it working now thanks tho

1 Like