Ok everyone. First time user here and need some help. I am a mentor for an FRC team and am struggling with using the Limelight in Labview. Yes, I have been to the Limelight docs and have read them. It hasn’t helped me. I am trying to to make an aiming motor for a shooter arm to raise and lower according the the “ty” data from the Limelight. Making the motor move on a button has been no problem, making the motor aim with a button using Limelight is a bit more of a problem. I am not looking to drive my robot with this, yet. Need to learn the baby steps first. Going out online and searching for samples has NOT been helpful. Any suggestions or even a sample of a simple single motor controlled using Limelight data would be greatly appreciated. Thanks.
Look into closed-loop control (common example being PID).
Essentially you calculate the error (in this case, it’s given to you as ty
), then you turn the robot until ty
approaches zero.
this is not a final solution i would recommend PID like fletch1373
but if you want something quick and dirty you can divide ty by 20.5 and wire it to the input of a percent output motor (assuming the input to the percent output is a range from -1 to 1)
We may be able to better help you if you post the code that allows you to drive the motor with a button. You are not too far away from using vision to guide your arm.
It might help to think of “ty” like a joystick input in this case. Similar to @tylerhedge’s suggestion, if you multiply “ty” by something very small to begin with (something like .015), you can plug the resulting number into your motor controller’s percent output. If your arm moves in the wrong direction, make that number negative (-.015). If you can get this part working, you will have written a proportional control loop.
There might be a few more details to work out if your arm violently falls down when its motor is disabled.
I definitely agree with @Fletch1373. Your best bet is going to be some kind of closed-loop control system to precisely control your aiming motor. Although this won’t get you 100% of the way there, this simple control loop should get you relatively good aiming accuracy. As a disclaimer, my team uses Chameleon vision, not Limelight, but the only difference in LabView (as far as I’m aware) is where the network table data is located, so this should work. Let me know if it doesn’t.
The basic concept behind this is we calculate the difference between what our process variable (in your case ty) is and what we want it to be, and then use that as an input to the control system. The difference between the current process variable value and the target process variable value is called the error. In this example, we calculate the error by subtracting the limelight’s ty value from the “Target Value” control, multiply that by the value of the “Proportional Gain” control, and then write the resulting value to the setpoint of the motor.
Essentially what happens is as the error increases, more power is sent to the motor, causing it to turn, and thus reducing the error (assuming the motor isn’t reversed). As the error decreases, the power sent to the motor also decreases, until the error becomes so small that the motor stops moving. How large you set the “Proportional Gain” control changes how sensitive the system is to error: setting it too low will make the system respond too weakly to accurately aim your motor, but setting it too high will cause the system to “hunt”, which is where the system repeatedly overshoots its target. In general, it’s a good idea to set the proportional gain really small to begin with (like 0.0001), and slowly increase it until the system responds the way you want.
If you want the best accuracy, you’ll likely have to introduce integral and derivitave control to the system as well. As with most things, a good place to start is the Wikipedia page for PID:
Thank you all very much. I will take these suggestions and get back at it.
I appreciate it.
Hmmm…a bit of a strange question. Not sure this is going, but I’ll participate for now I guess.
Nope.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.