Trouble With Autonomous Camera Tracking

For the past few days our programming team has tried to have the robot follow a target. We took the two color servo example from NI.com and instead of using the Panning servo we use that value output to run our Drive motors. We succeeded in having the robot turn left and right but it did not stop when the VT was in the center of vision again. It continues to turn left until it breaches the threshold set to turn right. In other words it keeps turning until it goes too far then turns the opposite direction until it goes too far. We are trying to set a “zero point” were if the values given are between 70-100 both drive motors are stopped. Unfortunately no attempts have been successful. Any ideas or help would be greatly appreciated.

                                    Programming of Team 1742 - Shockwave

You need to use a PID loop. What you are seeing is the classic under-damped system that starts to oscillate when it tries to hold a setpoint.

In other words, you’re turning TOO FAST toward the target, and the robot slides by it. Then it tries to turn back, and it turns TOO FAST. So it slides by it again.

You need to program a PID loop and use a low enough proportional gain so you don’t blow right by. Then use a small integral gain that will just “get you there”.

There is a PID white paper in chiefdelphi media that is excellent, and Labview provides a ready-made PID loop VI for you to use.

When we have it set on blocks so we control the position of the target it doesn’t stop turning left or right. The motor that was running continues to run unless we move the target to the other side of the vision field. Team 330 has an example of their code as well as a video that demonstrates it functioning but when we open it and look at it it just looks like a mess of everything. they said that they changed it from the base “Two Color Example” but we are having trouble following it.

i don’t even know how to connect the motors to the robot
if anyone can tell me please let me know

You want to wire your motors to your speed controls (we are using victors) those are connected to your digital sidecar through a PWM cable. that runs through a serial cable into the module in Slot 4 on your cRio. Everything as far as electronics and wiring i believe is located in the manual.

Our software team successfully finished that code yesterday. The way we did it involved panning the pan servo slowly across until it found the pink and green target (the color finder was some homemade code we found off the internet that works perfect). Then when it saw the pink and green target we would use an algorithm to find the middle of the target and pan the camera to move to it.

don’t know if this helped you at all but i am just reporting :smiley: