Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Shooter Targeting with Camera (http://www.chiefdelphi.com/forums/showthread.php?t=110799)

nickcvet89 09-01-2013 02:51

Shooter Targeting with Camera
 
Hey guys, my team is interested in programming our robot to track the rectangles. As of right now we plan to use mecanum wheels, so we are only programming to track the rectangles to give us height to adjust our shooter. We figure with the mecanum wheels, we will be able to rotate towards the target on our own. How would we be able to use the camera to adjust the height of our shooter during teleop? Let's say for example we plan to use a motor like window motor for this function. We want to program our shooter to be a turret only the left to right would be left out of the program. I have no experience with the any of the camera programming from years past. Can someone please help with how to begin this program?

Greg McKaskle 09-01-2013 07:24

Re: Shooter Targeting with Camera
 
The camera defaults to using a coordinate system where 0,0 is in the top right of the image and the sizeX,sizeY is in the bottom right. Since this is pretty meaningless for driving a robot, the example code scales it to be 0,0 in the center with negative 1 at the top edge and positive 1 at the bottom edge.

Since this is somewhat like a joystick, it or the inverse of it should work better to move motors or servos.

The first thing I'd do is hold it by hand and plot the position on a chart or at least display it on the screen. Get a sense of what it outputs. Then pretend to be the motor, moving it according to the output number. This helps you to learn the relative magnitude, directions, and numeric signs of the values involved.

To control the motor, you have several options.
Bang-bang control- Your camera is either above, below, or on target. If below, turn motor at a fixed speed to move it up. If above, move the other way at a fixed speed. If on target (generally less than delta away), leave it there.

Proportional- Similar, but you use the distance away from the target to scale your motor speed to get there faster and slow down as you approach.

PID and other variations - An even more complex method of approaching the target faster but trying not to overshoot and trying to overcome nonlinear elements like stiction. I don't think it is necessary here.

My recommendation is to choose a slow to moderate speed and start with bang-bang or proportional.

Greg McKaskle

nickcvet89 10-01-2013 21:33

Re: Shooter Targeting with Camera
 
Thanks Greg, will try this soon.

propionate 11-01-2013 00:37

Re: Shooter Targeting with Camera
 
Even though your original question was answered, I would like to take this time to point out that the camera's ability to track improves dramatically with the addition of an LED ring around the camera's lens to illuminate the reflective tape. In addition, the website below provides some helpful walkthrough's if you have trouble setting up the camera:

http://wpilib.screenstepslive.com/s/3120/m/8731

nickcvet89 11-01-2013 19:12

Re: Shooter Targeting with Camera
 
Thanks. Will order the LED ring this weekend.

propionate 11-01-2013 22:37

Re: Shooter Targeting with Camera
 
Tip: Our team found blue and green to be the best colors to use in terms of LabVIEW being able to isolate the color/luminosity. They are relatively cheap however, and you may as well buy a number of different kinds.

Ido_Wolf 12-01-2013 08:59

Re: Shooter Targeting with Camera
 
Quote:

Originally Posted by propionate (Post 1213385)
Tip: Our team found blue and green to be the best colors to use in terms of LabVIEW being able to isolate the color/luminosity. They are relatively cheap however, and you may as well buy a number of different kinds.

Kind of a stupid reason to mention that, but at least in my region, while the official competition is held in a close hall, the off-season events occur under blue sky :P So I'd generally go with green as it seems to be the safest choice in any case.

Either way, when you go with intensity in the Monochrome options of Vision processing, it'd usually be the most "intense" color in the arena one way or another...though it seems to me that choosing a specific color in the monochrome tab eliminates other colors in the frame much better than intensity.

BenGrapevine 14-01-2013 13:16

Re: Shooter Targeting with Camera
 
Quote:

Originally Posted by Ido_Wolf (Post 1213556)
Kind of a stupid reason to mention that, but at least in my region, while the official competition is held in a close hall, the off-season events occur under blue sky :P So I'd generally go with green as it seems to be the safest choice in any case.

Either way, when you go with intensity in the Monochrome options of Vision processing, it'd usually be the most "intense" color in the arena one way or another...though it seems to me that choosing a specific color in the monochrome tab eliminates other colors in the frame much better than intensity.

A suggestion is a suggestion and I personally found it very helpful. I have been hounding vision topics to see if people actually recommend using them in the first place so color really doesnt matter to me (although it does appear from reading that cool colors work better).

nickcvet89 15-01-2013 01:34

Re: Shooter Targeting with Camera
 
I have noticed in some of the other threads here and on the vision proscessing section of the screensteps page that I should use the example "Rectangular Target- 2013.lvproj. The way I'm planning to track the center rectangle is to create what states the camera is at in the vision processing vi based on where it is located on the coordinate system (ex. center, above, below, notfound) and pass this info through the robot global data vi for use in my teleop or autonomous vi. I noticed from frcmastery.com videos that was the way they did vision processing in the past competitions. Am I right to think this way or is there an easier way of doing this?

propionate 15-01-2013 01:53

Re: Shooter Targeting with Camera
 
Hopefully I'm getting your post correct: You are going to integrate the Rectangular Vision Tracking VI into your robot project, store the target coordinates in global variables, and then use those coordinates to adjust the shooter in Auton/Teleop?

Sounds like the correct approach to me! Good luck.

nickcvet89 18-01-2013 00:08

Re: Shooter Targeting with Camera
 
yeah the one thing I noticed though, when I integrated the rectangular target example, the robot global data vi. in my project was overwritten with the one from the example. This created a problem in my code because the Robot Mode global variable no longer existed. Could I just copy the vision processing vi. from that example and overwrite the one in my project?

propionate 18-01-2013 01:46

Re: Shooter Targeting with Camera
 
I don't have a cRIO to test this code on here at home, but here's what I did just now (to a new 2013 robot project) that seems to work:

(Create a back-up of your program before following these steps. If you want to give this thread another day or two to see if someone responds with a more elegant or more correct solution, feel free to do so)

1. Create a copy of the "Rectangular Target - 2013" folder that can be found in your LabVIEW program files (let me know if you need help finding it).
2. Move this copied version of the folder into your project folder
3. Open up your project
4. Right click on Vision Processing.vi and click "replace," then select the Vision Processing VI in the "Rectangular Target - 2013" folder that you just copied.
5. Follow the prompts. You'll be told that there are conflicts. For all of them, select the file that was in your original project - not the one that is in the "Rectangular Target" folder.
6. The final prompt will ask again if you want to use the new Vision Processing VI instead of your original one. Confirm that you want to use the one in the "Rectangular Target - 2013" folder.

Once you save the project, go into the new Vision Processing VI and search for the broken wires. You will have to create a new global variable to replace the one that you told it not to reference anymore.

Greg McKaskle 18-01-2013 06:44

Re: Shooter Targeting with Camera
 
The steps you lay out sound similar to the Tutorial on LV's Getting Started screen that leads through the steps in incorporating the vision example.

Greg McKaskle

team3039 20-01-2013 00:43

Re: Shooter Targeting with Camera
 
I created a custom .vi based on the Rectangle Target Vision Processing example provided with LabVIEW to be incorporated into the dashboard. I'm currently working to put the controls on the dashboard to quickly change the settings of the vision processing on the go. If you want my custom .vi and experiment with it, I'd be happy to PM it to you with instructions on how to implement it.

joemost 20-01-2013 15:22

Re: Shooter Targeting with Camera
 
Has Anyone found any luck with tracking shapes other then rectangles. My team is looking to track objects like trapezoids and other shapes.

Any luck?


All times are GMT -5. The time now is 10:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi