-
Notifications
You must be signed in to change notification settings - Fork 0
Navigation Example
Besides the popular task of locating the Skystone, a broader use of Vuforia is to navigate all over the game field using the 8 perimeter images and 4 Skybridge images. The FTC sample Op Modes for webcam contain a small bug: headings originate along the -Y axis instead of +X. This deviates from the standard FTC axis system and the regular (RC camera) Vuforia sample Op Modes. The difference exists for the Java and Blocks versions of the sample Op Modes.
In November 2019 this was reported in an FTC Forum post, and submitted as an FTC SDK issue.
Part of a Java-only solution was later posted to that Forum thread. The posted section of code uses a significantly different transformation method that avoids using a certain (suspected faulty) matrix. That Java code could not be converted into Blocks; several key Vuforia-related elements simply didn't exist in Blocks. I chose this as a "real" exercise to implement the new myBlocks. Namely, to create a myBlock of the FTC sample Op Mode for webcam, edited with the posted solution to correct the heading error.
I got it running first in Android Studio. The combined Java code is posted here; simply add that file to the TeamCode folder, insert a Vuforia key, and build the APK. The myBlock itself doesn't look very exciting:
/images/0100-webcamNav-v02.png
When placed in the INIT section of a blank Op Mode, this myBlock initializes Vuforia, enables the Camera Stream, and provides telemetry of the robot's location on the FTC game field (when a target image is visible). The Z-angle headings correctly originate along the +X axis.
Note: teams wouldn't bother to develop this particular Block, since there's an easy workaround. But this exercise demonstrated the potential of FTC myBlocks, to do tasks previously not available with standard Blocks.
1-26-2020 update: Simply copying the Android Studio code into OnBot Java, the Op Mode built cleanly and ran correctly. No edits needed, except of course the class name to match the Op Mode. So, providing any team with that Java code as a text file, along with the RC APK, would allow them to enter their Vuforia key, 'Build Everything', and immediately have a working myBlock with correct webcam navigation.
.
Questions, comments and corrections to [email protected]
-
Simple Example
-
More Info
-
Other Examples
-
Summary