Swerve spinning erratic after putting bot in Teleop mode with yagsl example code

Hello,

We have built a new swerve this year using below components.
MK4i swerve
CTRE Encoder and Pigeon2.0
NEO Sparkmax for Angle and Driver Motors

Our code is generated based on YAGSL example from
GitHub - BroncBotz3481/YAGSL-Example: Yet Another General Swerve Library Example Project

We haven’t added any additional code.
We have gone through “When to Invert” and have updated configurations based on the reading from NetworkTables.

But it is not working as expected.

Appreciate any help/pointers to resolve this.

@nstrike seems like you have been big contributor for this amazing library. Hence tagging you. Hope you don’t mind it.

I dont mind tag’s and never will! It helps me keep things organized!

I will check your configs when you post your code. If i dont find anything i will need a video of your robot in a swerve widget.

I need your code in order to do anything. Please make a github repo for it!

Can you please describe HOW its not working as expected? What do you expect? What is it doing instead? Screenshots from tools like AdvantageScope speak volumes as well.

Lastly, a link to your actual code would help immensely when asking programming-related questions

1 Like

Thanks a lot @nstrike and @Fletch1373 . Here is the link to our code repo.

We have put the chassis on the wooden block. When I enable Teleop mode even without any user input it keeps rotating and spinning wheels.

Let me work on getting snapshot from AdvantageScope in parallel.

Set your factor to 0 here and what gearing is uour mk4i? L1, l2?

Change these to driveFieldOrientedAngularVelocity too

Thanks @nstrike . It is Mk4i L1. Based on their spec in MK4i Swerve Module – Swerve Drive Specialties we added angle GearRatio of 21.428 (Derived from 150/7:1) and Drive Ratio of 8.14.

For yagsl_example/src/main/java/frc/robot/RobotContainer.java at main · ambrish3281/yagsl_example · GitHub
Are you suggesting to replace driveFieldOrientedDirectAngleSim with driveFieldOrientedAngularVelocity ?

Essentially something as below.

drivebase.setDefaultCommand(!RobotBase.isSimulation() ?
driveFieldOrientedDirectAngle :
driveFieldOrientedAngularVelocity);

Likely not your problem, but definitely dont do this: yagsl_example/src/main/java/frc/robot/Robot.java at main · ambrish3281/yagsl_example · GitHub

And the function it calls definitely shouldnt be calling configureBindings()

Why not? I think I included that to be sure that the bindings are not present during autonomous. I can remove it if you think its an unnecessary complication

I mean, “setDriveMode()” doesn’t seem at all related to what its doing (admittedly I’m on my phone, so may have missed something). Also, the configureBindings call (by default) is called in the RobotContainer constructor. Is there a reason it should need to be called repeatedly?

More like

drivebase.setDefaultCommand(driveFieldOrientedAngularVelocity);

If i removed it from that constructor? :slight_smile:

Which I didn’t :man_facepalming:

Thank you @nstrike .
I have tried both changes suggested by you.
Now I see attached behavior.
When I press forward on my xbox joystick, I see wheels oscillating rather than moving forward.

Again thanks a lot for your quick help!

Did you try to tune your PID?

I am not sure how to approach that.
Any pointers on process to do it, will be helpful!

BTW, in console messages I see below periodically.

CAN frame not received/too-stale. Check the CAN bus wiring, CAN bus utilization, and power to the device.
from: pigeon 2 13 (“”) Status Signal AngularVelocityZWorld
at: Stack Trace not received for performance reasons.

I will tale care of that! Thanks!

Here is capture from AdvantageScope.

Thank you!

Thanks! Is that an issue OR just a cosmetic thing ?

Is your pigeon2 dropping connection, on a shaky surface, or do you have very high can utilization? I think this is an issue

CAN utilization is less than 40%. I have only 13 CAN devices. (8 sparkmax, 4 Encoders for swerve and Pigeon 2.0 IMU).
But I have put chassis on wooden block. So it may be shacking a bit.