Rasmsete Command with SparkMax

Hello. We are having difficulties with making our robot go forward correctly with the ramsete command. We tell it to go 3 meters, but it goes 1 meter.

When we get the setpoints for the velocities and it thinks that it has finished with a set point of 0m/s on the wheels. We also print out the pose, and the pose is correct with actually correct measurements.

Any help?

Also, here’s our github here if you’d like to take a look (Our ks, kv, and ka were done with the characterization tool).

Thanks!

This sounds like you may have confused units at one point. 1 meter ~ 3 feet

Beyond that, I’m not familiar enough with the new trajectory stuff, so I’ll let someone else jump in.

I doubt it. We transferred this from some previous work this year on a temporary drive train before build got us the current one. On that previous version, the units were all in meters so I don’t see how it would’ve changed.

Just a question, howcome you declare your motor controllers in the RobotContainer and not in your actual drive subsystem?

It’s just hard to follow the code since a lot of objects are declared in the RobotContainer and not their respective subsystem…

I don’t know exactly. My team has always done it this way. Sorry about that.

I would suggest reading the new Command Based Programming framework on docs.wpilib.org. It should help out a lot with structuring the code which would make it easier for you (or others) to troubleshoot. I’ll keep digging in the code to see if I can find anything.

You have made a units error. Taking the naive estimate of your top speed from your high-gear kV value (computed as 12 / kV) yields 300 units per second, and your low-gear yields 100 units per second.

Does that mean that kV should equal 2? If maxSpeed = 12/kV then kV - 12/maxSpeed = 12/6

As a rough theoretical guess, yes. In practice, it means you need to check your characterization config and see what you did wrong.

So after changing it to 2, it got closer to the end waypoint but it still stopped shy (ended at .6 for 1 meter endpoint and 1.9 for 3 meter)

You really should not just fudge the constants until it works. That’s not a good procedure. You need to fix your unit error and do it right, or your system will likely not be robust.

I can identify some points of potential error. Upon generating a characterization project, we changed some of the code there because it defaulted to brushed motors and when we changed it to brushless there was a problem with getting it to do anything so we changed some of the code to make it work better. We probably messed something up there.

This is likely because you used the SparkMax project preset instead of the Neo one. Since this seems to be a common point of confusion, we have renamed them to SparkMax (Brushed) and SparkMax (Brushless/Neo).

2 Likes

Oh, now that you’ve said that, that seems to be the problem. Thank you

Okay, so we switched over to the neo project type and ran the data logger, however when we analyse the data it doesn’t have significant changes to the output. The kV is still way too low (it outputs as 0.122). We are using the default numbers in the data analyzer, should we be changing them?

Are you sure you entered your wheel diameter correctly? Remember that you must enter everything in consistent units.

Yes, 6 inches. As far as we know, the only other input is gearing, which is 18.86.

Yes, but in what units did you enter those 6 inches?

We input it in inches, both in code and in the analyzer. Is it supposed to be in meters or another unit?

It’s supposed to be in whatever units you want your gains to be in. The tool has no way of knowing what units that value is in; it’s just a double.