takeSnapshot can be used in a number of ways. takeSnapshot is filtering all the objects** that have been received from the vision sensor into an array of objects that you are interested in, you access the array of filtered objects using the “objects” array. The objects we receive from the vision sensor in the brain have already been sorted by size, the largest object is always received first. When takeSnapshot is used like this
Vision.takeSnapshot(0);
We are asking for all objects (ie. they matched any signature or color code), the largestObject in this case is just a copy of Vision.objects[0].
If takeSnapshot is used like this,
Vision.takeSnapshot( 1 );
or more likely with your code like this
Vision.takeSnapshot( SIG_1 );
we are asking for objects that match the first signature (1 is the same as SIG_1 in this case)
the returned objects array will contain only those objects that match SIG_1, however, if there are other objects (ie. signatures being detected) the largest may not have been the first one we received from the vision sensor, that’s the bug we have, the largestObject could have incorrect info copied into it in this case.
so the workaround would be to check objectCount and if > 0 use the first element of the objects array rather than the largestObject variable.
Vision.takeSnapshot( SIG_1 );
if( Vision.objectCount > 0 ) {
// do something with Vision.objects[0]
}
The bug was found and fixed back in October. Unfortunately, although the VCS team has the latest SDK which we continue to update with fixes and features, customers using VCS cannot access that until VCS itself has another release.
Using the vision sensor has a learning curve, it’s not easy, compared to other sensors like potentiometers or quad encoders, it’s quite a bit more difficult because the variables, the lighting, the background, the exact way objects reflect the light falling on them, make setting up the signatures the vision sensor is using a bit tricky. It’s probably on par with tuning a PID loop, however, I have seen students successfully use it with reliable results, just expect to invest time playing with it to understand the limitations it has.
** an object being the coordinates and size of an area that matches a programmed signature.