OCCRA
Go to Post If I find a student on my team who came through FIRST having learned nothing more then he wanted to go to MIT, I'll give my self a pat on the back and start counting down to kickoff. - Andy A. [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
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 02-08-2018, 11:02 AM
celttechie celttechie is offline
Registered User
FRC #3160
 
Join Date: Jan 2017
Location: Grove, OK
Posts: 8
celttechie is an unknown quantity at this point
PID Tuning workflow/methods? (for drivetrain)

Hello all,

I'm wondering if anyone has some tried and true methods for tuning PID controls.

We are using TalonSRX controllers and the SRX mag encoders this year.

We are running differential/tank drive with two motors on each side, with the mag encoders connected to the first motor on the side (the master) and then the second motor on that side is set to follower mode pointing at the master (so it is the "slave").

I'd like to get PID values and then also tune the drivetrain so it runs true.

Any tips and advice would be appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-08-2018, 11:07 AM
celttechie celttechie is offline
Registered User
FRC #3160
 
Join Date: Jan 2017
Location: Grove, OK
Posts: 8
celttechie is an unknown quantity at this point
Re: PID Tuning workflow/methods? (for drivetrain)

Code wise, here's what we have so far:

import wpilib
import ctre
from ctre import WPI_TalonSRX as Talon
from robotmap import motor_id


class Robot(wpilib.IterativeRobot):

def robotInit(self):
"""
This function is called upon program startup and
should be used for any initialization code.
"""
self.driveLeftMaster = Talon(motor_id.lm)
self.driveLeftSlave = Talon(motor_id.ls)
self.driveRightMaster = Talon(motor_id.rm)
self.driveRightSlave = Talon(motor_id.rs)

self.driveLeftSlave.follow(self.driveLeftMaster)
self.driveRightSlave.follow(self.driveRightMaster)
self.driveLeftMaster.configSelectedFeedbackSensor( ctre.FeedbackDevice.CTRE_MagEncoder_Relative, 0, 0)
self.driveRightMaster.configSelectedFeedbackSensor (ctre.FeedbackDevice.CTRE_MagEncoder_Relative, 0, 0)
Reply With Quote
  #3   Spotlight this post!  
Unread 02-08-2018, 11:29 AM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #6367 (), FRC #7240 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,391
virtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond reputevirtuald has a reputation beyond repute
Re: PID Tuning workflow/methods? (for drivetrain)

When using the CTRE products, I highly recommend reading their software guide, which discusses many of these topics (including a whole section on closed-loop PID tuning).

https://github.com/CrossTheRoadElec/...ster/README.md
__________________
Maintainer of RobotPy (Python for FRC) & WPILib Contributor
Creator of pyfrc (Robot Simulator + utilities for Python), pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript), and lots more...

Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
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 10:08 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