Move Back to the old Swerve Drive Odometery

The update of the previous SwerveDriveOdometry took an argument of the SwerveDriveState which was velocity and angle instead of position.

I mostly care about this for simulation purposes, but is this kept somewhere else in the library now?

With this current implimentation it breaks my sim system

As far as I know, no it’s actually gone. You can probably go back through older versions of WPIlib and copy the old class (and it’s dependent classes that might have changed) and just use that/those instead.

It’s also probably smart to update your sim system but it’s understandable if you can’t for now.

The reason for the switch is accuracy because before the underlying code did module velo * dt to approximate how far it went and then the new one actually uses real displacement.

For your sim a hacky fix can be creating a module position array and doing += moduleState.velo * 0.02 every cycle before passing it in?

You could probably use the FPGA timestamp and calculate a delta with it to help make it even less hacky. Might be good enough to just have that be your final fix.

1 Like

How does it break your simulation? You can still construct SwerveDriveOdometry using SwerveModulePosition and then create a separate function call to generate the old SwerveModuleState. See these examples for reference.

even better is

+= (old module velo + current module velo) * dt / 2

That’s true, I think this is definitely the way to go about it when it comes to simulations. I haven’t really worked with notifiers (I think that’s the word/class/concept) but if you want to maybe you can use those to run the simulation faster than once every ~20ms? I don’t think it’d help very much but you could do that and be even more accurate (again I haven’t worked with them so I’m not even sure if that’s how they work and if it’s even possible to do that lol).

I’m curious now, how accurate can you get simulations? I think a bigger error factor is just inaccuracies relative to your physical system and not the simulation speed.

Hate having to cjange it

IS there an actual correct way to wire this odometery now for real devices?

Call the drive motors falcons velocity and set that?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.