TalonSRX Swerve Autonomous Not Working

This is my teams first year with Swerve and its been a crazy season. Our regional starts Thursday and we don’t have a working autonomous yet. We’ve been using our practice bot to test various API’s such as CTRE’s MP or Pathfinder. With MP, we managed to get the Robot to move but it never went the correct distance and it would often curve while moving and not drive straight. After working on that for four days and getting nowhere, we switched to Pathfinder but can’t figure out what to do with the values you get from calling EncoderFollower.calculate. Does anyone know a solution for either of the two problems? At this point our goal is to tell the robot drive stright x distance, if there is a better way then please let us know.

It sounds like your trying to use tools that can do very sophisticated movement. There is a lot you can do with a swerve drive without using those more sophisticated methods.
For a really basic “drive forward” auto, you can just send a speed value to your normal swerve drive method. In other words, if you have a method that you currently send a gamepad axis to for driving forward, just call that same method using a fixed speed value. You could do that for a certain amount of time, or check a wheel encoder to see how far you’ve traveled.
You can do similar, simple actions such as driving at an angle and rotating without anything very complicated.

The issue is our goal is to have at least a single cube auto in the switch or scale. We need to be able to move perceive movements for that.

We’re using TalonSRXs on a tank drive; if you’re using motion profiling through talons we’ve got some basic versions that have been tested if you wanna check them out here. We’ve got code for Java and C++, methods located in drive train subsystem, called from EncoderDrive command located in drive commands folder.

With our swerve drive, during autonomous, we use an encoder for measuring distance traveled and a NavX to keep the robot driving in the commanded direction. You are welcome to come to our shop tonight if you want to talk through the details.

Trust me, motion profiling is not necessary to score the scale or the switch in auto.

We have functional two cube autos and don’t use motion profiling, you 100% do not need it for one cube. Complication makes everything harder, the simplest solution is better in most cases, especially when it comes to quick results.

The issue we had when we didn’t use motion profiling was the robot wasn’t going the correct distance (we converted circumference to encoder ticks) or driving straight. We weren’t sure how to fix driving straight since we were already using a PID loop for the wheels. Any suggestions?

Can you drive straight at all? I have never worked with motion profiling but it seems more likely that your position PID on your swerve drive isn’t working.

It generally drives straight but occasionally veers another direction. The angle. motor is kept at the desired angle during the movement so it won’t move.

If any of your swerve modules are slightly out of calibration (e.g. turned slightly when they’re supposed to be straight), then you’ll have difficulty driving straight in auto. In teleop the driver can compensate.

We try to calibrate our modules are closely as we can. Then we use gyro input to tweak the modules turn position slightly if we start rotating when we’re supposed to be driving straight. It’s not perfect but it works good enough.

We are currently trying to figure out motion profiling on our practice swerve chassis. At our first district we used talonSRX motion magic with small navX input correcting for heading. It worked great and we were able to hit 1 cube autos reliably including opposite side scale and switch. In our experience motion magic is much easier to get up and running and may be a good place to start.

How were you able to get it to go the correct distance? My team tried using CTRE’s excel sheet but it never went the desired distance. We then tried using a correction factor but that also never worked.