-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose holomonic preview path in PathPlannerPath #443
Expose holomonic preview path in PathPlannerPath #443
Conversation
If you want to reset a holonomic robots pose for every path, use a pose created from the position of the first point and the robot’s current rotation. There’s no need to load and use all of this. This also allows for doing some pretty bad things, like resetting your rotation to, say, 45 degrees when the robot ended the last path with a rotation of 0 degrees. Now the path following for future paths will be completely messed up because it needs to be able to accurately drive field relative, but the robots 0 no longer matches up with the field 0. |
This game is a bad example, because you pretty much always know your the rotation you need to start at to get your robot to score. But lets think about 2022. I can have a 5 ball that starts at ~30 degrees. I might find change around my starting angle to better hit the hub and drive the rest of the waypoints to pickup the other balls. I might also have a two ball on the far side that starts at -20. I like being able to aim the robot in the gui, and have the ability, not requirement, to have the first thing in my auto be "path 0 says you are actually here". Hopefully in time you have localization and can comment out the seeding command and trust your sensors, but when I have just a chassis week 2 or my camera is broken I want that ability. I agree that it is a terrible idea to reset between Path0 and Path1 if you are stringing them together, just for the very start of your autonomous. That was a pain point last year if you had to do something complicated for stringing paths together, and I'm glad it is no longer the implicit default. Also, they gryo is a relative sensor, so I can't simply rely on that during boot. If I know I have to line up at 180 this year and seed my state estimate with that, but then the drive team shimmies the robot into position, I read a different state than reality. |
This is what the auto starting pose in the GUI is for.
Your pose should only be reset as the first command in an auto, so it won't do it until actually enabled. This is what auto builder/PathPlannerAuto does. Whatever happens during setup should have no effect on it. If they line it up wrong your angle is going to be messed up regardless unless you are using localization over an initial auto pose. |
For something like a two ball last year I probably wouldn't make an auto mode, just use the path directly. I'd personally probably do the same for a five ball, the auto builder API is super nice, but I think we'll still do most of the in-between path stuff ourself in code. We had like 15 modes where the only thing different was which path we drove after scoring. It seems like a big burden to make 15 autos just to be able to set the initial rotation. If we had to add an additional command in there we would have to touch 15 files instead of our one command that takes the path as a parameter. We also create test paths purely for tuning, like "drive 10ft and do a 180", and it again feels cumbersome to have to make a path and auto for that |
The PathPlannerAuto class has methods to get the starting pose and list of all paths in the auto, so I still suggest using the auto files even if you don't use auto builder.
In this case I'd create an auto file for the first path to make use of the starting pose in the auto editor. Anyways, I'd be OK with a method similar to the ones in PathPlannerAuto like Another (probably better) option would be to have a |
1676461
to
6008cfd
Compare
I made some updates that get it pretty close to option 2. I think you kind of need it to be part of the constructor to keep it consistent when you call the "copy constructor" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nitpick improvements and it should be all good.
pathplannerlib/src/main/java/com/pathplanner/lib/path/PathPlannerPath.java
Outdated
Show resolved
Hide resolved
@@ -38,6 +39,7 @@ public class PathPlannerPath { | |||
* @param globalConstraints The global constraints of the path | |||
* @param goalEndState The goal end state of the path | |||
* @param reversed Should the robot follow the path reversed (differential drive only) | |||
* @param previewStartingRotation The settings used for previews in the UI | |||
*/ | |||
public PathPlannerPath( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an overload for this constructor that doesn't need a previewStartingRotation? This constructor can be used for on-the-fly generation as well so it would be nice to not need to give it one.
pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cpp
Outdated
Show resolved
Hide resolved
…nerPath.java Co-authored-by: Michael Jansen <[email protected]>
…annerPath.cpp Co-authored-by: Michael Jansen <[email protected]>
Similar to #423 . In a localization-less environment it is handy to know the starting pose for swerve paths. This uses the preview state heading, if it is set so you can reset your pose and drive exactly what you see in the gui.