MAXSwerve Odometry and Pathplanner Issues

So I’m not sure what information needs to be provided, but I am trying to set up and test a new drive station for our team, now including Field2d and such. The issue is that, though the controls for the actual swerve modules are correct, y up is forward, y down is back, x left is left, x right is right, etc, but when using Field2d, the odometry is completely wrong, y up makes the bot move right, y down moves left, x left moves back, x right moves forward. It’s odd. On top of this, I have some test paths in PathPlanner that just taxi forward from the center of the speaker, but it ends up doing a weird path not only physically but also on Field2d with an odd curve.
Constants.java (7.1 KB)
Main.java (411 Bytes)
Robot.java (3.5 KB)
RobotContainer.java (2.4 KB)
DriveSubsystem.java (12.4 KB)
MAXSwerveModule.java (7.7 KB)

2 Likes

Just looked over that, and adjusting that did make the movement a bit better, path-planner is still not moving where it should and now its origin is completely off, and the field visualizer randomly resets the robot back to the origin and stops tracking odometry. Alongside this, when tracking odometry, field2d has started changing the direction of movements, like the normal straight x and y movements work. However, as soon as you combine the two, moving straight in the x causes some weird sideways/curved movements. It’s probably something stupid, but I’m kinda stumped.
Robot.java (3.9 KB)

It is better to create a github repo so we can see the changes and view it without downloading your files.

1 Like

Sorry about that, we’re a new team so we just have to get everything set up haha

1 Like

You might check in pathplanner in the auto about whether the Starting Pose Preset is checked.

I’m not exactly certain the issues you are seeing. The drive subsystem looked pretty similar. You are using the ADIS gyro so the direction there is correct.

1 Like

You probably hit the same mismatch here we did.

private void driveRobotRelative(ChassisSpeeds speeds) {
    drive(speeds.vxMetersPerSecond, speeds.vyMetersPerSecond, speeds.omegaRadiansPerSecond, false, false);
  }

The drive method is accepting joystick values (-1 to 1) but you are trying to feed it meters per second in pathplanner.

edit: The fastest fix to try would be to divide vx and vy by your constants for max Speed in meters/sec and divide omega vy the max angular Speeds in radians.

This should be prechecked, yes?

I’ll try this, do you mind if I ask questions if I have any issues? Also, do you have any snippets of this being implemented? Thanks!

We have used it checked. But you have to set the starting spot to match your path.

That would be alright.

I have the starting position correct, but issues still persist. I added a video of it being weird during auto, i.e. not moving the drive straight when the path is a straight line (theres also times where it will move the drive straight but the field2d path will be curved), I also showed how the controls change during the moves, such as when you move to the side, moving forward or back completely changes from moving straight in either direction to moving at a weird curve.

Video

Every time I see a MAXSwerve + Pathplanner post, I always point people to take a look at 2846 Firebear’s github. I would copy/paste the supplementary methods into your drive subsystem and see if this fixes the issue. This is how we got Pathplanner working on our robot last year! Best of luck!

I’ve been trying to work with this for a little over two hours now, and I’m having an issue where I cannot figure out how to import the org.littletonrobotics.junction? Theres no docs online, the links I’ve found lead to github where it says nothing is found. I’m at a loss, any help?

I’d probably just ignore autolog and delete anywhere they use it for now. Although some logging of your commanded and outputted speed might help you chase down what is happening. We used Monologue this year.

I didn’t separate out as much from the template drive method as FireBears which has two drive methods to deal with the robot relative driving.

Just to point out in the drive method where they multiply by your max drive speeds to go from joystick values (0-1) to real speeds (0-maxSpeed). And I’ve highlighted past there for changes for driving robot relative. You can get rid of any of the logging lines (this.log() or @Logged).

edit: When you get to any spot to ask for more help make sure to update your Github

Ok so I figured out logger and stuff, I wanted to continue doing that so hopefully I could get data faster and such, but now that I have no errors, none of my widgets appear, when opening up elastic, there is no smartdashboard dropdown menu for widgets, even though I defined them, the simplest ones at least, the same way as before. Now I have a list of things to do

  1. How can I display my widgets again?
  2. How can I use the new logger to access the module speeds for the robot velocity widget, but also the swerve drivetrain widget?
  3. Autochooser now doesn’t work anymore, how to fix this?
  4. How can I use all of this new logging and formatting to more reliably update field2d?

edit: So I was able to get the widgets to work again, including autochooser, now I just need to figure out how to update field2d properly and get the robot velocity for the widget as well as the swervedrivetrain widget.

(Github has been updated)
For reference, I am trying to replicate the example elastic dashboard as a base goal.

I am actually switching over to swerve drive this year what is this called? I would like to implement it into my teams drive station

You must be looking at Elastic the dashboard they are using.

The dashboard? It’s Elastic dashboard, we like it so far.
Elastic
Our GitHub
If you need any help, we just had to go through alot of the initial setup and stuff for widgets, so I can help if needed :slight_smile: