|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools |
Rating:
|
Display Modes |
|
#8
|
||||
|
||||
|
Re: WPILib PID controller object
Quote:
---------------------------------------- I have a CamSource.h which is: ---------------------------------------- #include "WPILib.h" class CamSource : public PIDSource { public: CamSource(); double PIDGet(); void SetSource(double); private: double source; }; ------------------------------------------------ My CamSource.cpp file is: ---------------------------------------- #include "CamSource.h" CamSource :: CamSource() {} void CamSource :: SetSource (double sourcedum) { source = sourcedum; } double CamSource :: PIDGet() { return source; } ---------------------------------------- Then in my main code I do the following to use it. Basically I set the CamSource to what the X difference on the camera is, and then feed it to my PIDController. RobotCode.h: ---------------------------------------- PIDController *turretCamControl; CamSource *CameraBrains; RobotCode.cpp ---------------------------------------- CameraBrains = new CamSource(); turretCamControl = new PIDController(CamP, CamI, CamD, CameraBrains, TurretPIDMotor); Then in my teleoperated periodic: turretCamControl->Enable(); CameraBrains->SetSource(horizontalDestination); turretCamControl->SetSetpoint(0); ----------------------------------------- I think it will work, at least it compiles fine. horizontalDestination is the normalized X parameter from the camera. Thanks for your help, what you have outlined is pretty much the route I went as well. I don't know why, WPI couldn't just write a controller that allows us to just input a dang variable. It would be much easier. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| void* pointer to object in C++ | byteit101 | C/C++ | 6 | 14-01-2009 17:15 |
| UI Board Object Specs | 3DWolf | Control System | 2 | 10-12-2008 16:13 |
| Demo: Simple robot arm with a PID controller | mtomczak | Programming | 1 | 17-01-2008 02:17 |
| rangefinding/object detection | sciguy125 | Electrical | 14 | 13-01-2008 20:36 |
| Object Enablers | SherryG | Inventor | 1 | 07-04-2006 10:01 |