Hello,
We have been experiencing an issue where one of the drive motors on our swerve drive has not been inverting properly when booting up the bot (Front Left consistently, the issue doesn’t happen on other ). After restarting robot code, the motor inverts to the correct direction and the issue doesn’t happen again until the bot is rebooted a couple of times. It doesn’t happen each time, it takes quite a few reboots for the motor to not invert properly, but it happens.
When analyzing the situation further, we found out that when that motor doesn’t invert properly after boot-up, it drives correctly when giving it a signal through Phoenix Tuner X. What we did after that was increase the timeout to the setInverted() function (to 2 seconds!). This made the issue happen a lot less, but it still happens now and then.
I am leaning toward it being an issue with that specific motor, since the steering motors on the swerve drive invert properly (the other drive motors aren’t inverted), but I am not sure.
We are using Phoenix Pro for motor software.
This seems related to a race condition where the robot code tries to configure a CTRE device before Phoenix Server is fully initialized, so the command to configure the device doesn’t apply to a device. Given that it is consistently your Front Left motor, which is usually the first swerve module, and it only happens sometimes on reboot, this seems to match up.
As for solutions, you can use CTRE’s status signals to see if the configuration applied properly and try again.
Another solution if this is not possible (If you are using CTRE’s Swerve API), is to call Unmanaged.loadPhoenix() in Robot to force load the server right when the code starts and then add a wait to get it to load before the code starts configuring your motors. I would also try to put a bunch of print statements to see when the motor is configured and compare that to when the Phoenix Server has started in the log files.
We tried both of the solutions and none have seemed to work. We have the problem that a couple of the configurations( like neutral mode) don’t get configured to the falcon.
Thanks for the reply. I will emphasize that this only happens on one of our robots, Which is kind of weird. The error that I saw upon startup after putting a lot of debugging blocks is:
TxFailed - Could not transmit CAN Frame (StatusCode returned after inverting).
One time after seeing this returned code, it still worked and drove in the correct direction. The other time, it didn’t work.
On our other bot, the error doesn’t occur so it is hard to say what the problem is exactly (maybe a wiring problem, but I can’t find a logical reason for it).