OCCRA
Go to Post NASA rarely launches another rocket just so the programmers can see if they've fixed a bug. - Greg McKaskle [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 07-29-2018, 06:54 PM
Tom Line's Avatar
Tom Line Tom Line is offline
Don't lay blame. Fix probems.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 3,131
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Motion Profiling - Turning in place / Talon SRX

So we're working on implementing motion profiling. We're using Vannaka's GUI to generate paths, but it doesn't (and I assume by extension Pathfinder doesn't) support a motion profile to turn a robot without forward motion. We're using Talon SRX's for motor controllers.

We've considered sliding into motion magic mode and using a gyro to control the endpoint just for turns in place. Then switch back into motion profiling mode for the next move.

Is there another way that's better?
Reply With Quote
  #2   Spotlight this post!  
Unread 07-29-2018, 07:21 PM
jproney's Avatar
jproney jproney is offline
Registered User
FRC #5818
Team Role: Programmer
 
Join Date: Jun 2016
Rookie Year: 2016
Location: California
Posts: 22
jproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud ofjproney has much to be proud of
Re: Motion Profiling - Turning in place / Talon SRX

Quote:
Originally Posted by Tom Line View Post
We've considered sliding into motion magic mode and using a gyro to control the endpoint just for turns in place. Then switch back into motion profiling mode for the next move.
Personally, I've found the Motion Magic + gyro control method to be extremely effective for turning in place. If you find that your drivetrain squirms awkwardly during the turn, try temporarily putting one side of the drivetrain into Follower mode and reversing its polarity while using the other side to follow your Motion Magic setpoint. This guarantees that both sides of the robot are travelling at similar speeds throughout the turn.

Using the Talon SRX's new Motion Profile Arc mode to integrate gyro feedback might be even more effective, although I haven't personally tried that yet.

Last edited by jproney : 07-29-2018 at 07:24 PM.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-29-2018, 07:33 PM
asid61's Avatar
asid61 asid61 is online now
Design Simple
AKA: Anand Rajamani
FRC #1072 (Harker Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 3,020
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

Quote:
Originally Posted by Tom Line View Post
So we're working on implementing motion profiling. We're using Vannaka's GUI to generate paths, but it doesn't (and I assume by extension Pathfinder doesn't) support a motion profile to turn a robot without forward motion. We're using Talon SRX's for motor controllers.

We've considered sliding into motion magic mode and using a gyro to control the endpoint just for turns in place. Then switch back into motion profiling mode for the next move.

Is there another way that's better?
We found ourselves in that exact situation a few weeks ago. Our solution was to use regular PID turn with Motion Magic (although that had its own issues*) after a motion profile or just PID to position, and to set the tolerance on the motion profile encoders to a high value to force it to end early. We also implemented ways to "save" encoder counts between commands so that we don't start each command at 0.
If you want to be sketchy, you can try and execute a turn right at the very end of the profile, and set your wheelbase width to be lower. That way, your velocity is already low enough to make the turn smoothly.

The Talon SRX Motion Profile Arc is interesting, and it is better than the regular Motion Profile by quite a bit, but the lack of a custom velocity feedforward for both sides of the drivetrain was a big letdown. I attribute at least some of the error in our motion profile to that problem. We're looking at odd workarounds to get custom velocities in, but it probably won't be implemented until Winter.

*Although a motion magic turn was fairly fast, it still overshot a considerable amount on our robot with any amount of PID constants. We had to choose between having an F term and a P term in some cases, and eventually settled on just using an F term and hoping that the combined command would straighten the robot out as it drove. That works pretty well for the last cube of our auton.
__________________
Team 1072 2017-present
Team 299 2017
Team 115 2013-2016 (student)

2018 Davis Finalists (w/ 6474 and 3880), 2018 Roebling Winners (w/ 3476, 1323, and 1778)


Last edited by asid61 : 07-29-2018 at 07:36 PM.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-30-2018, 07:25 AM
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 2,283
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

Based on your wheelbase can calculate how far your wheels move for a given angle, generate a path straight for that distance, then reverse one side.
Reply With Quote
  #5   Spotlight this post!  
Unread 07-31-2018, 08:43 PM
Tom Line's Avatar
Tom Line Tom Line is offline
Don't lay blame. Fix probems.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 3,131
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

That's a neat workaround matt. I should have thought of that trick.

So in going to implement this whole system I have a somewhat unrelated question.

Heading is integrated into the TalonSRX motion profiling through a cascaded PiD loop. But in the case where you are using a differential drivetrain (tank) and are feeding different motion profiles to each side, do you feed your heading to each side as well and use the same heading constants on both sides?

It also appears that vannaka's motion profile generator exports Talon SRX csvs (which don't contain heading) or Jaci's output, which only maps the centerpoint of the robot.

How did you go about getting the heading portion into your code (assuming you guys were using TalonSRX csv's, which is a big assumption).
Reply With Quote
  #6   Spotlight this post!  
Unread 07-31-2018, 09:35 PM
Prateek M's Avatar
Prateek M Prateek M is offline
Kotlin Master Race
FRC #5190 (Green Hope Falcons)
Team Role: Programmer
 
Join Date: May 2018
Rookie Year: 2018
Location: Cary, North Carolina
Posts: 33
Prateek M is on a distinguished road
Re: Motion Profiling - Turning in place / Talon SRX

I haven't used the Talon SRX Motion Profiling mode after the heading control mode came out (we moved to doing it RIO-side) but here is my take on it.
Quote:
Originally Posted by Tom Line View Post
It also appears that vannaka's motion profile generator exports Talon SRX csvs (which don't contain heading) or Jaci's output, which only maps the centerpoint of the robot.
You can generate a profile for the center of the robot using Pathfinder (what the Vannaka generator uses) and split it into the robot's different sides using the Tank Modifier. The two trajectories have data about dt, position, velocity, heading (and some more info). This CSV can easily be programatically converted into Talon SRX compatible arrays (just multiply the dt by 1000, and then append the position and velocity terms from the Pathfinder CSV to the array -- this is what Vannaka's generator does internally). Then you can feed the heading from the original CSV into the secondary heading control loop.

There might be more efficient ways to do this, this is just how I assume it'd be done. Currently, we are exploring other options for trajectory tracking on the RIO using more advanced controllers as compared to a basic PIDVA on position and velocity along the path.

Last edited by Prateek M : 07-31-2018 at 10:41 PM. Reason: Grammar
Reply With Quote
  #7   Spotlight this post!  
Unread 07-31-2018, 11:00 PM
asid61's Avatar
asid61 asid61 is online now
Design Simple
AKA: Anand Rajamani
FRC #1072 (Harker Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 3,020
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

Quote:
Originally Posted by Tom Line View Post
That's a neat workaround matt. I should have thought of that trick.

So in going to implement this whole system I have a somewhat unrelated question.

Heading is integrated into the TalonSRX motion profiling through a cascaded PiD loop. But in the case where you are using a differential drivetrain (tank) and are feeding different motion profiles to each side, do you feed your heading to each side as well and use the same heading constants on both sides?

It also appears that vannaka's motion profile generator exports Talon SRX csvs (which don't contain heading) or Jaci's output, which only maps the centerpoint of the robot.

How did you go about getting the heading portion into your code (assuming you guys were using TalonSRX csv's, which is a big assumption).
CTRE has a short description of the implementation in the Motion Profile Reference manual. Basically, you do all calculations on the Right talon with a SensorSum selected sensor, using its own quadrature sensor as well as the SelectedSensor of the Left Talon (which is set to be quadrature sensor as well). Then, you make the Left Talon follow the Right Talon's output, with inversion of the Auxiliary output enabled. This gives you regular output for going straight and differential output for turning along the path.
However, the lack of a dedicated feedforward velocity for the left and right sides means that your closed loop is doing way more work for the turning than it should need to, and in our case it's led to some... interesting movements (although the final result is still pretty accurate). I've thought about setting up the SensorSum on an independent Talon and running SelectedSensor on the Left and Right drivetrain Talons, but we might just move to a non-Talon option in the future.
__________________
Team 1072 2017-present
Team 299 2017
Team 115 2013-2016 (student)

2018 Davis Finalists (w/ 6474 and 3880), 2018 Roebling Winners (w/ 3476, 1323, and 1778)

Reply With Quote
  #8   Spotlight this post!  
Unread 08-01-2018, 01:02 AM
Tom Line's Avatar
Tom Line Tom Line is offline
Don't lay blame. Fix probems.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 3,131
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

Quote:
Originally Posted by asid61 View Post
CTRE has a short description of the implementation in the Motion Profile Reference manual. Basically, you do all calculations on the Right talon with a SensorSum selected sensor, using its own quadrature sensor as well as the SelectedSensor of the Left Talon (which is set to be quadrature sensor as well). Then, you make the Left Talon follow the Right Talon's output, with inversion of the Auxiliary output enabled. This gives you regular output for going straight and differential output for turning along the path.
However, the lack of a dedicated feedforward velocity for the left and right sides means that your closed loop is doing way more work for the turning than it should need to, and in our case it's led to some... interesting movements (although the final result is still pretty accurate). I've thought about setting up the SensorSum on an independent Talon and running SelectedSensor on the Left and Right drivetrain Talons, but we might just move to a non-Talon option in the future.
Ok. Brain melted. Heading back to the Motion Profile manual for some more "light" reading.
Reply With Quote
  #9   Spotlight this post!  
Unread 08-03-2018, 09:59 AM
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 659
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Motion Profiling - Turning in place / Talon SRX

Quote:
Originally Posted by asid61 View Post
...However, the lack of a dedicated feedforward velocity for the left and right sides means that your closed loop is doing way more work for the turning than it should need to...
I was thinking about this earlier this summer. I just put my thoughts into a tracker on how to further improve the feature.
https://github.com/CrossTheRoadElec/...-lib/issues/49
TLDR: Replace PID[0] target vel with PID[0] arb-feed-forward and PID[1] arb-feed-forward. This gives you straight and turn feed-forward motor outputs, and you can do kV, kA, kS, etc. in the application in a more straight-forward fashion.
__________________
Omar Zrien - CTR Electronics - Cross The Road Electronics - Chief Software/Owner
CTRE New products | CTRE/FRC Source Examples | FRC Installer (for Talon SRX and more)
Get Latest Updates on Facebook | Twitter
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 09:41 PM.

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


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