Swerve drive moves randomly when joystick is released

We are using YAGSL. Our modules are MK4is with NEO motors, CANcoders, and L2 gear ratio. I started with the config from the known configs repo for MK4is. I then changed the CAN IDs, and the wheels were running.

The problems I’m having are

A) The wheels steer (not drive) randomly when I let go of the stick. The wheels remain still for half a second, then start steering seemingly randomly. This happens even with the joystick unplugged, so I don’t think it’s a stick drift issue. This problem has been dubbed “party mode” because it seems very random. Lowering the P gain for the steering made them all jitter around a set point, but with that the P gain was too low for actual driving.

B) The “party mode” described above messes with the wheel steering angle. After letting go of the stick and pressing it in the same direction as before, the wheels will all face - different direction than before, and a different direction than each other. We had a few runs where the wheels were all super close to being aligned with each other, but then “party mode” would kick in when I let go of the stick, and the wheels would be facing the wrong direction next time I pushed the stick.

Here is my code. Any help is appreciated.

Could you please take a video with FRC Web Components and your controller in view?

Unfortunately I won’t have access to the chassis until Friday. I will do that when I get access to the chassis.

Context for observations: our team is using the same hardware aside from navX MXP, but not YAGSL. I see two likely issues:

  • Minor: The X and Y axes are reversed for the left joystick, assuming you intend field-relative control. To completely resolve this, the X joystick axis also needs to be inverted to correspond to the Y field axis.
  • Major: MK4i motors are inverted. It looks like you may have pulled from the MK4 example, but strangely the MK4i example only has half the motors inverted. I may be missing something about the examples, but I do know from experience that direction mismatches and angle conversion errors can cause behavior similar to what you’re seeing.
1 Like

We fixed it by inverting the turning motors. Thanks to all the help!

1 Like

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