Go to Post There is nothing wrong with being great and being proud of it. - TubaMorg [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-02-2013, 19:23
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,574
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
PID Positional Control (Java)

Hello all.

Recently I've been attempting to write some code to control a motor to travel to setpoint (like spin half a revolution) and then stop. I've been using a quadrature encoder to obtain my distance traveled data. I've had little to no success with either CAN Positional control or using an adapted methods of PID-DEMO and ArmDemo. So my question is are there any teams using Java that would be willing to share their code from past robot arms that had positional control. That would help me a lot I believe.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
  #2   Spotlight this post!  
Unread 18-02-2013, 09:39
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: PID Positional Control (Java)

Hi, PID is a great tool, I understand you are using jaguars, you may want to hook the encoders directly into the DSC, When in java use the encoder as a PID source and then start tuning your variables. We have had issues in the past with jaguars we no longer use them.

Above robot init
Code:
Victor motor;
Encoder encoder;
PIDController pid;
In your robot init
Code:
motor = new Victor(1); # or jaguar
encoder = new Encoder(1,2); # A channel B channel
enncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance);
PID = new PIDController(0.01,0,0.01,encoder,motor);
In teleop ECT
Code:
PID.enable();
PID.setSetpoint(10.0);
Hope this helps, Please don't hesitate to PM me if you need anything,
-Matt
__________________
2015-2016 CSA
Software Engineering Student @ Johnson & Wales University
Team 228, Gus Robotics Inc.
Facebook
FLL Mentor for 1107, Edison Eagles!
2015- CT State Champions
2012- WPI Finalist(Thanks 1884 and 549), Spirt, Best Website
2011- WPI Chairman's award winners!
2010- WPI Champions! (thanks 230 & 20), WPI Engineering Inspiration, CT Best Website, CT VEX Champions (VRC228, VRC228b) (21-1-0)
2009- QCC VEX Champions (VRC228) (11-0-0), Innovate Award (VRC228)
  #3   Spotlight this post!  
Unread 19-02-2013, 00:56
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: PID Positional Control (Java)

Does the setpoint have to be a distance, or can we set the setpoint to a certain number of counts?
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
  #4   Spotlight this post!  
Unread 19-02-2013, 01:08
Ty Tremblay's Avatar
Ty Tremblay Ty Tremblay is offline
Robotics Engineer
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Alton NH
Posts: 832
Ty Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond reputeTy Tremblay has a reputation beyond repute
Re: PID Positional Control (Java)

Quote:
Originally Posted by F22Rapture View Post
Does the setpoint have to be a distance, or can we set the setpoint to a certain number of counts?
"Distance" is just a descriptor. You can use whatever you want. If you want a certain number of counts just set your "distance per count" to 1.

Basically, distance per count allows you to put units into your PID instead of relying just on counts. You could translate counts into inches, feet, etc.

Edit: Please note this is using WPILib Java. If you're not using WPILib, the lines of code mentioned above won't work out of the box.
__________________
Closed Thread


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 03:03.

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