Like all other teams we are trying to use our axis camera to track the retro reflective targets. there are many good examples and tutorials showing how to setup vision but they are all lacking one basic part. How do you control a motor with it? I have not seen a solid answer from any tutorial or forum. I seen on one of the posts that there is a value of 1 to -1 but I am unable to locate that in the example code.
For experimentation our team is using the example that came with lab view that lets you adjust the HSL to find your retro reflective target. so far we have the HSL tuned to find our target . The values are in the 90’s but the numbers are blue(not sure why that is). The frame is following our target perfectly but is always displaying in accurate distances like 50 feet when we are about 6 feet away(again not sure why).
If someone could provide a picture or upload code that will move a motor to try and center the vision target in the center of the camera , I would greatly appreciate it
It’s very hard to provide a generalized code, since everyone’s robot is different.
Conceptually, it’s very simple, if the target is left of the center of the camera, turn left, if the target is right of the center, turn right.
It doesnt have to be specific to our robot. Even if you could add on to the example provided by in labview that would be helpful. We are using the Axis M1011 camera. and we have all types of motor controllers so it doesnt matter what gets used. I just need an example showing how the our target on the camera gets tied into moving a motor. From there i can create a code specific to our robot.
Take a look at the attached example. It’s just a very simple (and incomplete) example of how to use the tracked goal to center your robot on a target.
Basically, the PID block shown will try to turn the robot left and right (using values from -1 to 1) so that the Goal X that it is reading will approach 0 (the assumed center of the screen.)
Alternatively, you could simply code something along these lines: IF Goal X < 0, THEN Motor Output = 1, ELSE IF Goal X > 0, THEN Motor Output = -1. You get the idea.
(One other thing…because all the goals are different shapes, you probably will not be able to accurately read how far away from the goals you are.)


As for the distance being off, how large is the target? The code uses assumptions about the physical target size to estimate distance. If you shrink the target rect, this illusion will cause the robot to think it is farther away.
Greg McKaskle
bvisness
i am not very familiar with PID controls but i plan to do some rearch and learn more. you code looks simple enough but i have one final question before i can test it. where does my “Goal X” get its data from. i know that there is a value of -1 to 1 in the vision example from NI that i need to route to the “goal X” but i cannot find where that value is at in the NI example.
Greg McKaskle
i have three targets made. one is 29x24(low goal), 54x21(middle goal), and 54x12(high goal). they all report inaccurate distances whether im using one or all three. would you happen to know what it means when your scores are in blue? the instructions say orange is too below, and green is above the limits but it says nothing about what blue means.
Blue means that the aspect ratio is more like the outer 2-point goals than the inner 3-point goal.
To debug the distance and other stuff, I’d recommend running on the PC, or if running on the cRIO, turn on the View buttons. This will let you see if the camera is in focus, is pointed at the targets, is too close, etc.
After that, you can trace the numbers being calculated through the Compute Distance VI. It is pretty simple code. It may not be obvious at first what it is doing, but it is not complicated. Please ask questions if something doesn’t make sense and you’ve discovered why your numbers are off by that much.
Greg McKaskle
If you have any trouble on how to integrate the example code into your existing robot code, there is a tutorial if you go to the tutorials section when you first launch labview.