SysId gains on SDS MK4i Modules

Hi,

Our team recently started using the SwerveDriveSpecialties MK4i Modules, and we are working on tuning the gains using the Sysid tool in Wpilib 2022. Has anyone had any success with this? So far we’ve gotten gain outputs with a decently high P and a very high D, especially when compared to the SDS suggested gains.

When we run the internal falcon 500 controllers with those generated gains, we slightly undershoot by a few degrees. If we try to set the angle to different angles in quick succession (for example, adding one degree each loop iteration) the output is very jerky and oscillates a lot.

We’ve successfully run the Sysid tool before so we aren’t sure what might be causing it to work like this on these modules. We suspect that part of it might be due to the delay in reading the CANCoder but we aren’t sure.

Any help or insight on why this might not be working would be greatly appreciated.

Thank you.

1 Like

Following this thread since we have a similar issue.

We have also run into issues with reading CANcoder sensor values with Sysid. Until this week, we couldn’t use sysid because of CAN errors with the TalonFX and CANCoders.

Yesterday, we tried using SysId to profile a TalonFX while using a CANCoder for rotation readings. The reported sensor units and the gains we on orders of 10e+46. I suspect we were not configuring one of the units correctly or SysId is mistakenly reading the CANCoder values.

1 Like

We haven’t done this yet because we are still waiting for our MK4i modules to ship, but I’m wondering if either of you are implementing a software PID controller using the CanCoder or if you are configuring the CanCoder as an external sensor for the Falcon500 and using the Falcon’s PID controller. I plan on going with the second option as we’ve using TalonSRX controllers with mag encoders in previous years with great success for our differential drives.

We are also waiting on our 4i’s. The CANcoder is planned to be used to give us our initial zero angle offset. After storing that value to the TalonFx, we plan on running it’s native pidcontroller \ motion magic.

1 Like

I assume you are not using SDS template code? How much more work is it to program the base swerve code from scratch?

1 Like

This is a copy of our code. Its challenging to keep everything straight. I recommend looking at our 2022 code. You can technically copy paste a lot of it. All changes should be done in the constants.java file.

With that said, it’s really rewarding to understand the code yourself, so that you can troubleshoot it.

Check out this thread about using SysID and SDS modules. @Bmongar and I both got similar results tuning MK4s and MK3s respectively. Our team has MK4is for the season, but haven’t characterized it yet.

To lock the modules into place for characterization I used some small cut blocks of wood and used clamps to hold them in place.

4 Likes

Some added notes for using the wood blocks to fix the Swerve drivetrain in place. For the Mk3s, the bevel gear can stick out a little from between the wheel supports and the wood can drag on it. To avoid this, I just turned all the bevel sides of the SDS Mk3s inboard and reversed the motors in SysId accordingly. I haven’t looked closely enough at the Mk4s and Mk4is to see if this is an issue.

Some team needs to create a nice 3d printed chuck that will do this and share the CAD. (hint, hint!)

Currently, we are running the module angle PID control on the roboRIO. It reads the cancoder angle, calculates the PID and SimpleMotorFeedforward output, and then sets the voltage to the falcon. It’s working as intended right now, but for whatever reason, SysId was reporting numbers orders of magnitude too big. I have yet to try it again.

1 Like

I would also add this code achieving a similar goal as @vargoose84 's code (just if you want another example!) SDS MK3 swerve base code

Does anyone have an “easy button” solution for locking the 4is in place? We were able to easily find a block of wood for the mk3s, the 4is seem to be a completely different question.

1 Like

I don’t (we’re using Mk4s) but I would suggest 3d printing something that mounts (maybe to a bumper rail)? Worked better than the wood block for us.

1 Like

There are some Kudos waiting for the first team that publishes an STL file for a 3d printable SDS MK4i wheel chuck that can hold the wheels straight. Don’t forget to brand it with your team number.

I think we are gently but firmly going to c-clamp the belt-driven pulley

1 Like

As it turns out, 4 well placed zip ties, one on each corner does the trick. I jammed the gears between the output motor and the first larger turn gear with a zip tie.

I used a large flat level, but any straight 1x1 or 1x2 will do, to align the wheels one one side at a time. If you’re using the sds-swervelib and/or their swerve-template code, point the wheel bevels towards the left side of the robot. While being held in alignment, apply zipties as shown in the photos below.

It was “good enough” to run through the SysId characterization.

Remember to remove zipties before trying to drive in serve mode!

Photos:

5 Likes

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