|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Using PID on Talon SRX with Gyro for feedback
We are looking at off season activities and wanted to explore using the Talon SRX controller's internal PID capabilities on our drive system to drive both to a fixed distance (using a quadrature encoder) and in a straight line (using a gyro).
I'm not sure if this is possible; I'm looking for a sanity check on the concept. We have a tank drive six wheel drop center drive system. The thought was to wire the encoder to the left side Talon SRX, and use positional PID to control this side. We'd tune our PID with the right Talon slaved to the left. After tuning, the right Talon SRX would get attached to the Gyro, using the analog connection, just like wiring a potentiometer. We would read the current setting of the gyro before moving, and send that as the positional PID target for the right side. The thought is that as the left side starts to move, the right side will detect a direction change and speed up to correct. I know that this will require a great deal of tuning to get correct. What I don't know is if it is technically possible. Also, I know that in Labview there are a number of VI's that are used to get data from and to control the gyro. I believe that these expect the gyro to be attached to an analog port on the roborio. If the gyro is attached to the Talon SRX, I would assume that I can no longer use these VI's to get an angle, pitch, or yawl, or reset the angle to zero. That would be a major drawback to this approach, as we would no longer be able to say, turn 90 degrees in place. I suppose an alternative might be to put another gyro on an analog roborio port and use percent Vbus mode on the talons to turn that way. Has anyone done this type of control? or see reasons why it just plain won't work? We have code to do this without PID using victors or the old talons, but want to take advantage of the processing power in the new controllers. We used the PID capabilities of the Talon SRX on this past years robot, so we are familiar with CAN, the break out board, etc...[/size] |
|
#2
|
||||
|
||||
|
Re: Using PID on Talon SRX with Gyro for feedback
Put an encoder on each side (left and right). Average the left and right encoder counts and use that as the process variable for separate left/right closed-loop distance controllers. Use your gyro reading to keep the vehicle driving straight. Use the gyro reading as the process variable for separate left/right closed-loop orientation controllers. Sum the left (and right) distance and orientation controller outputs and use that sum as the command for the left (and right) wheels. |
|
#3
|
|||||
|
|||||
|
Re: Using PID on Talon SRX with Gyro for feedback
Using a gyroscope to drive straight inherently requires driving two motors differently based on a single input. The SRX controls seem to be aimed at controlling a single motor - or a second motor the same way using slaving.
Also, gyroscopes don't give you an output of what direction you're heading, but what your rate of rotation is. If you tried something like driving the left wheel to some specified number of RPM, and driving your right wheel until the gyroscope rotation rate was zero, you would probably end up on something pretty close to a straight line, but it wouldn't be any particular line; I expect that your heading would have changed significantly as you came up to speed. |
|
#4
|
|||||
|
|||||
|
Re: Using PID on Talon SRX with Gyro for feedback
(Emphasis mine)
Quote:
|
|
#5
|
||||
|
||||
|
Re: Using PID on Talon SRX with Gyro for feedback
I should have been clearer. I was suggesting an approach different from what the OP was considering. Thanks for the clarification.
|
|
#6
|
|||||
|
|||||
|
Re: Using PID on Talon SRX with Gyro for feedback
For single-input, single-output control, I think the Talon SRX is a good candidate to do all of the work for you.
For multi-input, multi-output control, you are better off having a high level controller running on the RoboRIO that sends lower level commands to the Talons. |
|
#7
|
||||
|
||||
|
Re: Using PID on Talon SRX with Gyro for feedback
Quote:
Code:
/** * Use a rate gyro to return the robots heading relative to a starting position. * The Gyro class tracks the robots heading based on the starting position. As * the robot rotates the new heading is computed by integrating the rate of * rotation returned by the sensor. When the class is instantiated, it does a * short calibration routine where it samples the gyro while at rest to * determine the default offset. This is subtracted from each sample to * determine the heading. */ |
|
#8
|
|||||
|
|||||
|
Re: Using PID on Talon SRX with Gyro for feedback
Quote:
I absolutely agree that once you bring the roboRIO or other external processor and a programming library into the mix, it becomes much more straightforward. Once we installed a working gyroscope, we were able to get our 2014 mecanum robot smoothly driving in field coordinates in a couple of hours. Driving a tank in a straight line should be about the same level of difficulty. |
|
#9
|
|||
|
|||
|
Re: Using PID on Talon SRX with Gyro for feedback
Thank you for your replies. I didn't know that the gyro signal was not a directional heading. Without that, I don't see how what I proposed could be feasible. We'll continue with our tried and true code to drive straight for a specific distance...
|
|
#10
|
|||||
|
|||||
|
Re: Using PID on Talon SRX with Gyro for feedback
If you're looking for an autonomous solution (that is, a few seconds worth), the SRX internals can be the solution, just not with a gyroscope. Put encoders on both gearboxes, and give them controls to drive at the same speed for the same duration, or to both drive to the same position (that is, the same number of encoder clicks). The first might result in you not pointing the correct direction at the end, and the second might result in a curvature that's corrected at the end. You could probably combine the two (start out with speed, and switch to position when you're about 3/4 of the way there) to get the best of both. If you calculate how many "excess clicks" correspond to a turn of a given angle, you can even use this to follow a more complex path.
|
|
#11
|
||||
|
||||
|
Re: Using PID on Talon SRX with Gyro for feedback
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|