PathPlanner x and y Issues

Hello,

Our team wishes to use PathPlanner in autonomous mode this year, but it appears that the x- and y-values in the program itself are switched in the JSON files, causing the robot to (obviously) move the wrong way. Is there any way to fix this?

Thanks

Post your code to see how your building your trajectory.

My PathPlanner values were correct when I used the Pathlib provided by path planner.

Hmmmm. +x should be defined as either:

  1. Forward, relative to the robot when looking top-down at it
  2. Toward the opposing alliance wall, when looking top-down at the field.

+y follows a right-hand reference frame convention (IE, perpendicular to +x, at an angle of 90 degrees counter-clockwise when measured from the top).

The wpilib docs have more info, including pictures.

When you say the X/Y values are switched, are you saying the generated trajectory does not follow the reference frame convention described in wpilib? Or do you need to convert wpilib’s reference frame into a different convention?

1 Like

Sorry, it turns out that we just read the values wrong and the x and y values aren’t switched. It’s still not going the right direction, though.

When we asked it to move forward, it moved to the left. When we asked it to move to the left, it did this thing where it quickly went back and forth (probably around 6in max each way) and then sped northwest. I looked at the wpilib document and it mentioned inverting the gyro, but I’m not quite sure where exactly to stick a negative sign.

Here’s our code: https://github.com/Barlow-Robotics/MecanumCommand-Imported

I would make a private method in your DriveSubsystem class that returns a Rotation2D of your gyro using something like

return Rotation2d.fromDegrees(-1 * gyro.getAngle());

and then replace all your gyro.getRotation2d() calls with calls to the private method. I think that would work

I’m fairly sure Gyro#getRotation2d flips the angle already

1 Like

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