Go to Post I think it's important to keep FIRST's most important award as the top point getter [in Fantasy FIRST]. It's help reinforce that the Chairman's award, Engineering Inspiration and Woodie Flowers award are actually important and FIRST is about more than just the robots. - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 17-02-2012, 09:36
guoruiwu1994 guoruiwu1994 is offline
Registered User
FRC #1815
 
Join Date: Feb 2010
Location: Toronto
Posts: 15
guoruiwu1994 is an unknown quantity at this point
Using PID controls to center robot on target with camera

Using the camera, we can get how many pixels we are off target. Is there a way to feed that into the PID controls and then have the PID controls output into the robotdrive?

As far as I know, in the provided PID function you have to give it a source (such as an encoder), you cannot give it a number. Also, I'm not sure if the PID output works with robotdrive (arcade mode).
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2012, 09:40
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: 1,715
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: Using PID controls to center robot on target with camera

Are you programming in the command based style? If so it is actually really easy to do with a PID subsystem.
Reply With Quote
  #3   Spotlight this post!  
Unread 17-02-2012, 10:35
guoruiwu1994 guoruiwu1994 is offline
Registered User
FRC #1815
 
Join Date: Feb 2010
Location: Toronto
Posts: 15
guoruiwu1994 is an unknown quantity at this point
Re: Using PID controls to center robot on target with camera

What do you mean by command based style?
Reply With Quote
  #4   Spotlight this post!  
Unread 17-02-2012, 10:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Using PID controls to center robot on target with camera

Quote:
Originally Posted by guoruiwu1994 View Post
What do you mean by command based style?

See the WPILib Cookbook located in the Documents area on the WPILib FIRSTForge project:


http://firstforge.wpi.edu/sf/go/doc1297?nav=1




Last edited by Ether : 17-02-2012 at 10:55.
Reply With Quote
  #5   Spotlight this post!  
Unread 17-02-2012, 10:42
guoruiwu1994 guoruiwu1994 is offline
Registered User
FRC #1815
 
Join Date: Feb 2010
Location: Toronto
Posts: 15
guoruiwu1994 is an unknown quantity at this point
Re: Using PID controls to center robot on target with camera

Right now, we are using IterativeRobot.
Reply With Quote
  #6   Spotlight this post!  
Unread 17-02-2012, 10:50
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: 1,715
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: Using PID controls to center robot on target with camera

You will have to create your own PID class that extends the current PID class and override some of the methods to get it to work the way that you want it to.
Reply With Quote
  #7   Spotlight this post!  
Unread 17-02-2012, 10:53
guoruiwu1994 guoruiwu1994 is offline
Registered User
FRC #1815
 
Join Date: Feb 2010
Location: Toronto
Posts: 15
guoruiwu1994 is an unknown quantity at this point
Re: Using PID controls to center robot on target with camera

Can you give me some example code on how to do that?
Reply With Quote
  #8   Spotlight this post!  
Unread 17-02-2012, 11:07
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: 1,715
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: Using PID controls to center robot on target with camera

Unfortunately there isn't really any example code, and I don't have any written right now.
Reply With Quote
  #9   Spotlight this post!  
Unread 17-02-2012, 11:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Using PID controls to center robot on target with camera

Quote:
Originally Posted by guoruiwu1994 View Post
Using the camera, we can get how many pixels we are off target. Is there a way to feed that into the PID controls and then have the PID controls output into the robotdrive?
A PID takes a setpoint and a processVariable as inputs, and adjusts its output to make the plant's output (the processVariable) equal to the setpoint.

You want the "how many pixels we are off target" to be zero, right?

So your setpoint would be 0 (zero), and "how many pixels we are off target" is your process variable. The output from the PID would be your drivetrain rotation command (assuming that "how many pixels we are off target" is a measure of aim, not range).


Reply With Quote
  #10   Spotlight this post!  
Unread 17-02-2012, 11:40
guoruiwu1994 guoruiwu1994 is offline
Registered User
FRC #1815
 
Join Date: Feb 2010
Location: Toronto
Posts: 15
guoruiwu1994 is an unknown quantity at this point
Re: Using PID controls to center robot on target with camera

The input of the PID wants a source though, not a number.
Reply With Quote
  #11   Spotlight this post!  
Unread 17-02-2012, 11:56
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: 1,715
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: Using PID controls to center robot on target with camera

http://www.wbrobotics.com/javadoc/ed...PIDSource.html
Create a new class that extends PIDSource and rewrite the pidGet() method to get the offset of the target from 120 and return that value.
Reply With Quote
  #12   Spotlight this post!  
Unread 17-02-2012, 12:11
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Using PID controls to center robot on target with camera

Quote:
Originally Posted by guoruiwu1994 View Post
The input of the PID wants a source though, not a number.
Give it a source that always returns zero for the setpoint.

Give it a source that returns "how many pixels we are off target" for the processVariable.


Reply With Quote
  #13   Spotlight this post!  
Unread 18-02-2012, 14:33
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Using PID controls to center robot on target with camera

https://github.com/jesusrambo/PurpaD...tRotation.java

Look through VerticalTurretRotation and HorizontalTurretRotation, that's how we do it.
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 11:17.

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