Path Weaver issue

When using path weaver we can use the example code but anytime we use the path weaver with our own path we can not get it to run anything but a straight line any help would be appreciated.

https://github.com/Team2883/Competition_Code_2020

1 Like

You’re probably going to have to give more information for people to help. For example, there appears to be two versions of your robot code at that link, and I don’t see any Path Weaver paths.

Updated, I think they got it uploaded.

You are passing exampleTrajectory to the ramsetteController in getAutonomousCommand(). I think you want to pass trajectory1, which is generated from the pathweaver output.

Did not work

Team 2883’s code on GitHub has been updated and now only has the one version rather than two or three, thank you for the notification of this slip up.

In the comments of your code you say that the gear ratio is 26:1, but then you set you gearRatio variable to 28.5. Could you clarify where the 28.5 came from?

I think I have had the same issue. The example program worked for me as well, but my JSON file path did not. For me, the initial odometry position was not set to the position of the initial position of the path, as seen in my post. This would cause the robot to drive to some random position on the field and then follow the path. To fix it, in your Ramsete Command add
m_driveTrain.resetOdometry(trajectory.getInitialPose());
(Probably at line 163 in RobotContainer.java or somewhere after you define your trajectory)
Also, in your code you are using the example code’s exampleTrajectory instead of your custom JSON file trajectory. Make sure you are using the trajectory you want to use.

I am a programmer of team 2883, and we tried implementing the getInitialPose() into the Ramsete Command, and trajectory still does not work.
Here is a screenshot.

We tried this as you can see below one of our programmers has screen shot the code he changed

First off, you are using the variable ‘trajectory’ outside of it’s scope. To fix this, define ‘trajectory’ outside of the try catch loop, and only set its value in the try catch loop. Also, try putting the resetOdometry line of code outside of the constructor for the Ramsete command, it’s a function, and so it needs to be on its own line. I’d suggest putting it on the line after the } of the catch and before RamseteCommand ramseteCommand = …

Also, note that under ‘trajectory’ there is a red squiggle line. This means there is a compiler error, and if you hover it, a message will pop up explaining it and a solution to fix it. That usually can help problems like these.

Thanks I will get them to try this

Seems like we have it moving but our turns and distances are not right it makes part of the path then stops short.

Could you send a video of it driving and an image of your path in PathWeaver?

Start by making sure that each wheel encoder is reporting an accurate distance. You can do this by adding the left and right wheel distances to Smartdashboard. the call you want is .getSelectedSensorPosition() for Talons after you adjust for gear ratio, wheel circumference, and encoder ticks.

We ran a simple test trajectory to go forward 1 meter and then measured how far the robot moved. We tuned the PID values to get that dialed in before moving on to more complex paths.

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