Swerve Drive/ Thrifty Encoder

This is wolfgang first time doing swerve and were having some issue with Thrifty Absolute Magnetic Encoder its like the sensor are not reading, sometimes some wheels doesn’t change angles. Does anyone know how to fix this issue. Swerve Video

Welcome!

Could you provide more detail of what you are expecting to happen?
(E.g, drive to the left of the video, sit still with no motor motion, spin in a circle, etc)

Knowing the test program will help us diagnose the issue.

Now, assuming it is meant to be sitting still, does this behavior persist when the bot is placed on a carpet?

The default PID values (assuming they are in the correct ballpark for the gear ratios/motors/sensors) will assume some level of friction against the floor. Sitting up on blocks means this doesn’t happen and you may get some erratic behaviour.

1 Like

Can you output the swerve encoder position to the smart dashboard and see if it updates correctly if the module is turned by hand?

1 Like

This is another video showing what does on the floor . When i move the joystick a liitle bit that what it does it like it doesnt listen to the controller

It does update when its moved manually

Ok. Very helpful video.

I would double check all your ratios and conversion factors, Also do what @chadr03 said and make sure you get the values out of the encoders you are expecting on the smart dashboard.

Next step beyond that is to dig into PID values and any gyro feedback you may be using for field-centric control.

I suspect you have conversion factors/ratios wrong somewhere which is causing the PID controllers to give wild results. The reason I say this is because you said :

Which to me reads as : turn the bot on (things are zeroed out and happy), bump the joystick (some input), this behavior happens

Im happy to share the code if u want to have a look

It is good the encoder seems to be working if it is giving a value when you turn by hand.

My next question is how your code is utilizing the encoder information?

Is it just using the thrifty encoder it as a seed and controlling the motor with the motor’s built-in encoder or is it using the thrifty encoder value directly for feedback?

I think for much more help you would need to post your code. A link to a github repository is the best method to share.

Code Let me know if it doesnt works

I don’t think the reop is public.

I can get to your teams page, but not that repo

Oh i think its private let me make it to public

New code link

link still not working for me

is there other way i can share maybe zip?

Go into repository settings then scroll to the bottom where it says “Change visibility”. Set it to public and we can link to specific parts of your code and configuration that are likely incorrect.

This is much easier than sending a zip file back and forth.

1 Like

It should work now Code

1 Like

the code is time based

The value you are passing into your swerve to calculate the turn power encoder angle is the following:

m_turningEncoder.absPosition(encoderOffset)

I would recommend updating your SmartDashboard output to the same value that the turn calculator is based on

for example

replace the frontLeft.m_turningEncoder.getDistance()
with frontLeft.m_turningEncoder.absPosition(encoderOffset)

Then turn the module by hand note what the value of this is when it is forward, pointed right, back, and left.

do this for all modules.

This will clear a few things up for me.

1 Like

Hey I’m also from this team I’m the one who has been working on the code lately. We did test today with the suggestion and it didn’t seem to solve the issue any other ideas? We are trying to see if it has anything to do with the values the controller is sending by adding a slider.

After you update the dashboard printout to the value that is used for the module then calculations. What values did you see on your dashboard when you pointed the module in different directions?

Forward=?
Right=?
Back=?
Left=?