-
Notifications
You must be signed in to change notification settings - Fork 64
Detecting VuMarks
STATUS: COMPETITION READY. WIKI PAGE WIP. LAST UPDATED: 02/12/2019 DogeCV 2019.1
This is a tutorial for how to detector VuMarks using DogeCV. You will need to feed DogeCV a Vuforia license key - if you do not already have one, this video explains how to get one. Now, before calling detector.init()
, you'll need to feed add the following line to your code:
detector.VUFORIA_KEY = "--YOUR KEY. THEY'RE FREE FOR FTC STUDENTS--";
Next, you'll likely want to change the camera's position. Use the following three lines of code to set the position of the phone's (or webcam's) lens relative to the robot center. If you need to move in the opposite direction (e.g. if the camera is on the left), just use a negative number.
detector.setCAMERA_FORWARD_DISPLACEMENT(x); //Sets value in INCHES
detector.setCAMERA_LEFT_DISPLACEMENT(y); //Sets value in INCHES
detector.setCAMERA_VERTICAL_DISPLACEMENT(z); //Sets value in INCHES
Finally, in the method parameters for detector.init()
, you'll need to tell DogeCV to look for VuMarks. If you're using the front or the back cameras, use the line below, setting the CameraMode
as appropriate:
detector.init(hardwareMap.appContext,CameraViewDisplay.getInstance(), DogeCV.CameraMode.FRONT, true);
Or, if you're using a webcam, see that tutorial, and simply replace the detector.init()
call given there with the one below:
detector.init(hardwareMap.appContext,CameraViewDisplay.getInstance(), DogeCV.CameraMode.WEBCAM, true, webcamName);`
This will allow DogeCV to scan for VuMarks. Now, after you have run detector.enable()
, you'll be able to access information related to the VuMarks through four methods:
detector.isVuMarkVisible();
detector.findVuMark();
detector.getRobotTranslation();
detector.getRobotOrientation();
You can find the full method parameters below, and here is an example of how to use them, taken from within an OpMode
:
@Override
public void loop() {
//Telemetry feed from VuMark Detector
if(detector.isVuMarkVisible()) { //Checks if a VuMark is visible right now
telemetry.addData("Visible Target", detector.findVuMark().name()); //Retrieves the name of the current VuMark
VectorF translation = detector.getRobotTranslation(); //Obtains current robot location, as a vector in inches
if(translation != null) {
telemetry.addData("Pos (in)", "{X, Y, Z} = %.1f, %.1f, %.1f",
translation.get(0), translation.get(1), translation.get(2));
}
Orientation rotation = detector.getRobotOrientation(); //Obtains current robot orientation, as a set of angles in degrees
if(rotation != null) {
telemetry.addData("Rot (deg)", "{Roll, Pitch, Heading} = %.0f, %.0f, %.0f", rotation.firstAngle, rotation.secondAngle, rotation.thirdAngle);
}
}
else {
//No visible VuMark
telemetry.addData("Visible Target", "none");
}
// Update telemetry
telemetry.update();
}
- More stability testing
- Check position feedback with more real-world robots
- None yet. Please report them if you find any!
- Levi
detector.init(Context context, ViewDisplay viewDisplay, DogeCV.CameraMode cameraMode, boolean findVuMarks)
-
2019.1
- Major re-work. First time with full detector integration.
-
2018.2
- Initial implementation of Dogeforia