![]() |
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). |
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.
|
Re: Using PID controls to center robot on target with camera
What do you mean by command based style?
|
Re: Using PID controls to center robot on target with camera
Quote:
See the WPILib Cookbook located in the Documents area on the WPILib FIRSTForge project: http://firstforge.wpi.edu/sf/go/doc1297?nav=1 |
Re: Using PID controls to center robot on target with camera
Right now, we are using IterativeRobot.
|
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.
|
Re: Using PID controls to center robot on target with camera
Can you give me some example code on how to do that?
|
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.
|
Re: Using PID controls to center robot on target with camera
Quote:
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). |
Re: Using PID controls to center robot on target with camera
The input of the PID wants a source though, not a number.
|
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. |
Re: Using PID controls to center robot on target with camera
Quote:
Give it a source that returns "how many pixels we are off target" for the processVariable. |
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. |
| All times are GMT -5. The time now is 11:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi