Go to Post I can't wait until IFI starts their FRC sized competition and quickly overtakes FRC. - AdamHeard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-27-2016, 10:27 AM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 251
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
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.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #2   Spotlight this post!  
Unread 03-27-2016, 12:51 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
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?
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 03-27-2016, 01:00 PM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 251
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by lopsided98 View Post
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?
I've tested with a rate of 50Hz for the profile update, and with about ~200 generated points it takes roughly 3 seconds to generate on the RoboRIO. This year, I used this to generate the profiles before the match had begun so they were ready at the beginning of auton, by providing it with the defense layout of the field and where my robot is on the field as soon as my driver station had connected. Once the robot had received word of where it was, it would generate the trajectory and hold on to it until Autonomous
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #4   Spotlight this post!  
Unread 03-27-2016, 04:18 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #5   Spotlight this post!  
Unread 03-27-2016, 08:42 PM
Oromus's Avatar
Oromus Oromus is offline
Lead Programmer, Community Liason
AKA: Ryan
FRC #1902 (Exploding Bacon)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Florida
Posts: 80
Oromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to behold
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.
__________________


2016 Roles: Manipulator, Strategy Co-Lead, Programmer
2016 Orlando Regional: Quarterfinalist (Captain w/ 1557, 5557 and 4352)
2016 Rocket City Regional: Quarterfinalist (w/ 283 and 34), Regional Chairman's Award Winner
2016 Championship: N/A (had fun and was inspired, that's what counts)
-------------
2015 Role: Programmer
2015 GSCR: Quarterfinalist (w/ 4189 and 4026), Regional Chairman's Award Winner
2015 Orlando Regional: Semifinalist (w/ 456 and 86), Imagery Award Winner
2015 Championship: Pit Safety Award Winner
Reply With Quote
  #6   Spotlight this post!  
Unread 03-27-2016, 08:54 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by Oromus View Post
What's the advantage to using this over, say, a well-tuned PID loop?
Explained here, starting at 14:50


Reply With Quote
  #7   Spotlight this post!  
Unread 03-27-2016, 10:06 PM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 251
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by lopsided98 View Post
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.
The most major modification is C rewrite, however the structure has been changed, and some of the more mathematical functions of the library have been optimized.

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
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #8   Spotlight this post!  
Unread 03-27-2016, 10:24 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by Jaci View Post
The most major modification is C rewrite, however the structure has been changed, and some of the more mathematical functions of the library have been optimized.

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
The main reasons I feel it is harder to integrate are the lack of the ability to load trajectories from files and that it assumes that the encoder values are not already scaled to physical units. This second limitation can be easily worked around with some math.

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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #9   Spotlight this post!  
Unread 03-27-2016, 10:42 PM
GBilletdeaux930's Avatar
GBilletdeaux930 GBilletdeaux930 is offline
Registered User
AKA: Greg
FRC #0930 (Mukwonago Bears)
Team Role: Coach
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Milwaukee,Wisconsin
Posts: 171
GBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to all
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by lopsided98 View Post
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?
Quote:
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.
Probably for that reason right there.
Reply With Quote
  #10   Spotlight this post!  
Unread 03-27-2016, 10:48 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by GBilletdeaux930 View Post
Probably for that reason right there.
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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #11   Spotlight this post!  
Unread 03-27-2016, 11:08 PM
GBilletdeaux930's Avatar
GBilletdeaux930 GBilletdeaux930 is offline
Registered User
AKA: Greg
FRC #0930 (Mukwonago Bears)
Team Role: Coach
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Milwaukee,Wisconsin
Posts: 171
GBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to all
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by lopsided98 View Post
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.
I understand what you are saying, but that doesn't make the dependency on WPILib disappear.
Reply With Quote
  #12   Spotlight this post!  
Unread 03-28-2016, 12:01 AM
artK artK is offline
Just Another Person
AKA: Art Kalb
no team (No Team)
 
Join Date: Dec 2011
Rookie Year: 2010
Location: Rochester, NY
Posts: 119
artK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond reputeartK has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by Jaci View Post
I've tested with a rate of 50Hz for the profile update, and with about ~200 generated points it takes roughly 3 seconds to generate on the RoboRIO. This year, I used this to generate the profiles before the match had begun so they were ready at the beginning of auton, by providing it with the defense layout of the field and where my robot is on the field as soon as my driver station had connected. Once the robot had received word of where it was, it would generate the trajectory and hold on to it until Autonomous
This is awesome! Do you have any video of this running on your robot during auto?

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.
__________________
Art Kalb
Team 254 (2011-2014): Head Scout, Programmer
2011, 2014 World Champions
Reply With Quote
  #13   Spotlight this post!  
Unread 03-28-2016, 01:26 AM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 251
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by lopsided98 View Post
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.
This has been fixed in the latest commit. Now we have a Distance Follower, which ditches the encoder conversion, assuming you are giving it values in meters (or whatever unit you're using everywhere else). The EncoderFollower still exists for people who want to feed it ticks, though.

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.
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #14   Spotlight this post!  
Unread 03-28-2016, 01:32 AM
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 251
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Quote:
Originally Posted by artK View Post
This is awesome! Do you have any video of this running on your robot during auto?

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.
We don't have a video running auto, in my initial code repo all this was done on a coprocessor (and worked flawlessly on a practice field), however we had some issues with FMS not forwarding ports at the regional I went to, so I turned Motion Profiling off in favor for just a 'go forward for x encoder ticks'.

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
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Reply With Quote
  #15   Spotlight this post!  
Unread 03-28-2016, 10:07 AM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Pathfinder - Fast Motion Profiling for Java and C++, Tank and Swerve Drive

Cool!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:43 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi