|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Project Link
Pathfinder is an API for Motion Profiling. Give it a few waypoints and some information about your Robot and it will generate a nice smooth trajectory for your robot to follow to avoid jerkiness and keep your robot's autonomous movements accurate. Pathfinder can generate paths for both Tank and Swerve drive systems, as shown in the images below: ![]() ![]() (red = front wheels, blue = back wheels. Drivebase constantly facing forward) Pathfinder's actual generation code is all written in C, so it's very fast, meaning profiles can be generated on the fly. Pathfinder supports C, C++ and Java currently, and doesn't have any dependencies! Because it doesn't have any dependencies, you can even use it in your non-frc projects if you want to. Pathfinder can use any type of encoder as a feedback device to keep your robot on track. All the parameters are exposed, so you can run the control loop at any speed you like. The wiki contains instructions for setup and some demo code for generation and following in both Java and C++. If you use Toast, it will also work in simulation if you're running Windows or Mac. If you're on linux, you can build and install the library manually with the instructions in the readme. Special thanks to Austin Schuh, Jared Russel and Tom Bottiglieri for pioneering motion profiling code in FRC, and for giving this wonderful talk. Some of the generation code was inspired by Team 254's 'TrajectoryLib', although heavily modified to be more efficient and to work in C. |
|
#2
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
This looks really cool! I was just working on integrating 254's TrajectoryLib into our code, but I might try this instead.
I know 254 did trajectory generation off of the robot because it was too slow. I assume that the combination of the faster roboRIO processor and the more efficient C implementation made it feasible to move the generation on to the robot. How long does it usually take to generate the trajectories? |
|
#3
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
|
|
#4
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
What advantages does this have over 254's TrajectoryLib? The trajectory following code seems very similar to 254's, but did you make any changes to the generation algorithm other than rewriting it in C? The main reason I am asking this is that TrajectoryLib seems to fit more easily into my robot code than your library, and I'm trying to decide whether I should switch right now.
|
|
#5
|
|||||
|
|||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
What's the advantage to using this over, say, a well-tuned PID loop? I find this quite interesting and I'm considering using this on our robot, but I'm wondering what there is to gain from using it.
|
|
#6
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
The main advantages are the speed and portability. Pathfinder will run on either Java or C++ robots, and also has the added support for Swerve Drive. As for integrating it into you robot code, it should be a fairly similar experience to TrajectoryLib |
|
#7
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
I am curious, though, why you chose to do the tick to distance conversion within Pathfinder. Both the Talon SRX and the WPILib Encoder object will do distance scaling for you, so why didn't you just use that? My original plan was to have a bunch of pre-generated trajectories and just choose to load the one for our selected autonomous. I have decided to use your library after all, and generate multiple trajectories concurrently in the background. This makes the whole process simpler to manage. |
|
#8
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
Quote:
|
|
#9
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Dependencies have nothing to do with this. If you are using this library outside of FRC, you can very easily do the distance conversion yourself, but when using it with WPILib, the built in conversion makes things more complicated.
|
|
#10
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
I understand what you are saying, but that doesn't make the dependency on WPILib disappear.
|
|
#11
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
I've also added File Serialization. It will export as a binary format to save space, or as a CSV file. In C++ this will be the functions in `io.h`. In Java, these functions are under the `Pathfinder` class. |
|
#12
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
|
|
#13
|
|||
|
|||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
My one question is why are you generating these 200 points? Because that seems like a lot. Each spline covers about 2", and you have 199 points where the quintic constraints have you driving straight locally (Since the second derivative is zero when it approaches the waypoint in the spline configuration we developed). I suspect this would make the robot drive a little twitchy, especially when trying to turn. |
|
#14
|
||||
|
||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Quote:
The reason so many points are generated is because of the nature of the control loop. Each point has a dt value (i.e. how long this control loop iteration lasts before moving onto the next) - in our case, it was 1 / 50. Each iteration (which is timed with the Notifier class from WPIlib) will fetch the next segment and process it. It is possible to look at the second derivs in order to reduce the amount of points, but that would (at least in the current algorithm) add more time to the actual generation sequence. I can modify the algorithm to correct for this and suffer next to no time overhead. Maybe something to put on my todo list The path didn't jitter at all, in fact it was very smooth. Turning was very smooth and didn't seem to have any issues |
|
#15
|
|||||
|
|||||
|
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive
Cool!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|