Our FRC team has been using YAGSL code to attempt to set up swerve on our robot. This is our first year doing swerve, so we had to get code set up from scratch. We picked that code because it could be configured to work with the Pigeon 2.0 gyro and thrifty bot encoders. Our swerve base configuration is mk4i. Also, we are using all of our motor controllers and gyro through CAN but only the gyro is from CTR Electronics. We have been having issues with the way the Pigeon 2.0 gyro communicates with the code. When the robot is enabled, the wheels turn and spin randomly. Also, the smartdashboard is displaying all information except for the gyro values. Also, in the driverstation console, there is an error that can be seen below.
You will need to use Phoenix tuner to set the Pigeon 2 to the right firmware. I believe that for YAGSL, we had to set it to use Phoenix 5. But, you can try Phoenix 5 or Phoenix 6.
Setting it to phoenix 5 worked for us, thanks. The gyro is not giving any errors and the angles are reading on shuffleboard.
An issue persists, however, that when we enable the robot, the wheels all start turning in a direction without any controller input, and they just keep spinning. When we decrease the p value in the code, their random turning decreases, but the steering decreases too. There are no errors in the console. Why would the swerve be turning without input? We are testing it on wood blocks and cant figure it out.
Have you checked your angle readings? Open SmartDashboard, you should see the absolute and relative encoders reading the same value. (You may have to add relative encoder values, I think had to add them back in) You can also look at the setpoint for each angle motor and see if that makes sense.
One thing that I am doing is modifying the teleop to just have drive at a fixed velocity, so I can check that things move in the right direction.
These are the absolute and relative encoder values right after we initialize the code. When we move the wheels, the relative encoder values change, but we are never able to get the absolute encoder numbers to change.
We found out that when our robots rotation is at 0 degrees, the motors all freak out and spin in random directions, but when we rotate the gyro with our hand then the wheels angle stop spinning and the wheels just consistently drive in a random direction. We don’t know which encoder readings we should use to set the absoluteEncoderOffsets, but we dont think fixing those offsets would end up solving this problem.