Quote:
Originally Posted by l0stboy
That makes sense. Would there be link anywhere for some sample code of that?
|
If you look at the GearsBot sample program included with the Netbeans install it should serve as an example. There are a few differences, it uses an ultrasonic rangefinder to drive its PID loop. And it uses 2 motors.
You can modify the RobotDrive constructor to take all 4 of your motors. one you do that, the rest will be unchanged.
And you only need to use a PID subsystem if you intend to use encoders. If you aren't installing encoders change the PIDSubsystem to a Subsystem and remove all the methods and code that pertain to the PID loop stuff (returnPIDInput and usePIDOutput).
If you do have encoders, then instead of using rangefinder.getVoltage() as the feedback element, you'll read the encoder value and use that. The PID constants (Kp, Ki, and Kd) will have to be adjusted to account for the range of values the encoders will return. And the set point will be in the same units that the encoder is returning, such as encoder count that represents the distance you need to drive.
Brad