We are having an issue with our swerve drive where some of the modules will rotate to a seemingly random position then rotate back to where it started the first time the robot is enabled after power on or code is deployed. Usually only one or two modules will exhibit this behavior, and which ones do changes every so often. We are using SDS MK4i modules with Falcons and CANcoders, and our code is based of of team 364’s swerve code.
Our solution for now is going to be to bind a button for resetToAbsolute and add a reset routine at the start of auto and tele. This seems to happen randomly for us also on a seemingly random module once in a while. That initial issue was solved early January, this popped up recently and we can’t seem to diagnose root cause. No magnet slipping, no offsets changing, just unsure why at the start it isn’t going to the same position.
Someone mentioned sticky faults in that same git issue, I’ll have to check that tonight, but our CAN bus is not long or seeing faults.
We’re binding a button, and reseeding every second when the robot is disabled. We can reproduce the problem pretty consistently if we redeploy/restart robot code and hit Enable as fast as possible when the driverstation connects. If we wait just a moment before enabling, we can avoid the issue.
At events, the robot always sits in the disabled state for a bit before the match starts, so we’re hoping it will be OK. The unknown is if the robot reboots during a match. In this case, the wheels will probably need a manual reset since the robot becomes enabled immediately.
We implemented BaseFalconSwerve from 364 and are experiencing the same thing. It only happens occasionally though, maybe half of enables it jumps more than one revolution. I think it has to do with the zeroing from the absolute encoder.
I just took a quick look at the code, but is there anyplace you’re handling the fact that the Falcon’s encoder does not wrap? One rotation is 2048, two rotations is 4096. Link to our code for this.
I’m also not able to find where the conversion from degrees to talon native units happens. This looks like the code is setting the falcon’s encoder with degrees, but I can’t find a coefficient being configured. I’m probably just missing it.
No, we haven’t found a solution, although we haven’t investigated this much further as we have been more focused on other priorities. I was actually just about to bump this thread.
I can’t check now because I don’t have access to a bot. I would recommend running with the debugger attached and putting a break point in the setAngle method and see where the odd value is coming from. What method is passing it down. There may be something odd with initialization order.