OnBotJava issue!

We followed the directions in the manual 6.2 (obj) And when build and after we hit INIT after a few seconds we get the following error
“Robot Status: EMERGENCY STATUS
To attempt to recover, please restart the robot,
error: User code threw an uncaught exception:
RunTimeException - TFObjectDectector
loadModelFromFile failed”

Any help would be appreciated!

Please answer these questions:

(1) What is the name of your model file?
(2) How did you upload it to your Robot Controller?
(3) What is the filename/path used in your code for the filename?
(4) Are you using a Control Hub or an RC Phone?

The reason I ask about the name is because some characters don’t translate well to the OS on the Control Hub, and so the file will get renamed on the Control Hub. For example, the downloader will turn “MyFile-1.tflite” to “MyFile_1.tflite” silently because dashes aren’t allowed on the Control Hub.

Furthermore, I recommend rebooting the Control Hub so that its light is Green and plugging it into a Laptop. Browse to the Control Hub (it’ll show up in your File Explorer left-pane as “Control Hub” usually) and navigate to:

/FIRST/tflitemodels/

And make sure your file is there and that it’s called what you think it should be called. I get the error you showed all the time when I misspell the filename, the filename got changed on me, or I just completely get the path wrong.

If none of this helps, then we can look at the Control Hub log files to see what “really” happened. Here’s a good howto for getting access to the log files:

Paste the contents of your log file to a reply and we can look through it for you.

-Danny

1 Like
  1. The model file is TeamMarker.tflite.
  2. The file was uploaded through OnBot Java.
  3. private static final String TFOD_MODEL_ASSET = “TeamMarker.tflite”;
    private static final String[] LABELS = { “8866 blackmarker” };
  4. We are using a Control Hub.
  5. we will email the log file, the text is too long for this platform.

I assume what you mean in (2) is that the file is uploaded using the upload feature in the management interface on the webpage (as per Step 5 in Section 6.2 of the ftc-ml user manual - if you use the standard upload mechanism, you MUST alter your TFOD_MODEL_ASSET path. In your case, it would be:

private static final String TFOD_MODEL_ASSET = "/sdcard/FIRST/tflitemodels/TeamMarker.tflite”;

The only time you can guarantee that a file name will work without providing a full path is when you’re using files provided by the SDK built into the software, or added as an asset in Android Studio, otherwise anything you upload yourself should include the full path to the file (like shown above). I know that some people have said “they got it to work”, but I’ve absolutely never been able to upload files through the webpage uploader (for OnBotJava and Blocks) and not provide the full path to the file.

Since you also provided your model labels, I want to add that I hope you only have ONE label in your model - you should make sure ALL of the labels in the model are listed in your code in the order they are shown in the dataset (alphabetical). One common misconception is that you only have to list the labels you want the model to report, and that is NOT the case; the SDK doesn’t read the labels and do any filtering, the model needs the list of all the labels in order to be able to report the correct label for the object it’s detecting.

That worked amazingly well! Thank You So Much!
Now for our next question:
Where would we put our team marker file in our current programs? We have attached our code. What we do currently is rely on the “No Object Detected” value to move left and look for the duck, If it’s not on the center, we move left and look again, if it’s not on the center or left we know where it is. Will the “no object detected” still be able to be used with our "/sdcard/FIRST/tflitemodels/TeamMarker.tflite” file?
here is our code:
@Autonomous(name = “Red_Carousel_Duck”, group=“Pushbot”)
public class Red_Carousel_Duck extends LinearOpMode {

HardwarePushbot robot = new HardwarePushbot(); // Use a Pushbot’s hardware
private ElapsedTime runtime = new ElapsedTime();

private VuforiaCurrentGame vuforiaFreightFrenzy;
private TfodCurrentGame tfodFreightFrenzy;
private DcMotor left1;

Recognition recognition;

/**

  • This function is executed when this Op Mode is selected from the Driver Station.
    */
    @Override
    public void runOpMode() {
    robot.init(hardwareMap);
    List recognitions;
    int index;
vuforiaFreightFrenzy = new VuforiaCurrentGame();
tfodFreightFrenzy = new TfodCurrentGame();

// Sample TFOD Op Mode
// Initialize Vuforia.
vuforiaFreightFrenzy.initialize(

, // vuforiaLicenseKey
hardwareMap.get(WebcamName.class, “Webcam 1”),
// cameraName
“”, // webcamCalibrationFilename
false, // useExtendedTracking
false, // enableCameraMonitoring
VuforiaLocalizer.Parameters.CameraMonitorFeedback.NONE, // cameraMonitorFeedback
0, // dx
0, // dy
0, // dz
AxesOrder.XZY, // axesOrder
90, // firstAngle
90, // secondAngle
0, // thirdAngle
true); // useCompetitionFieldTargetLocations
// Set min confidence threshold to 0.7
tfodFreightFrenzy.initialize(vuforiaFreightFrenzy, (float) 0.85, true, true);
// Initialize TFOD before waitForStart.
// Init TFOD here so the object detection labels are visible
// in the Camera Stream preview window on the Driver Station.
tfodFreightFrenzy.activate();
// Enable following block to zoom in on target.
tfodFreightFrenzy.setZoom(2.5, 16 / 9);
telemetry.addData(“DS preview on/off”, “3 dots, Camera Stream”);
telemetry.addData(“>”, “Press Play to start”);
telemetry.update();
// Wait for start command from Driver Station.
waitForStart();
if (opModeIsActive()) {
// Put run blocks here.
// while (opModeIsActive()) {
// Put loop blocks here.
// Get a list of recognitions from TFOD.
{ recognitions = tfodFreightFrenzy.getRecognitions();
// If list is empty, inform the user. Otherwise, go
// through list and display info for each recognition.
if (recognitions.size() == 0) {
telemetry.addData(“TFOD”, “No items detected.”);

//nothing on the center square, move left and look again

I’m not sure what you’re asking here, I’m not sure if you’re asking “how do I change my current program to use my new model?” If you’re using OnBotJava, you merely have to make the same changes to your existing program that you did to the sample program using Section 6.2.

There should be no need to change the algorithm you’re using to detect a Duck versus your new object, if you’ve restricted your vision such that you’re not going to have more than one “new” marker in your camera view at any given time. With only one object - and a custom object at that - in your model file that should make it fairly difficult to receive false positives, but it’s certainly not guaranteed. Make sure your minimum recognition level is set appropriately in your code to filter out false positives (whose level can only be determined through lots of testing with your object).

Good luck!

I noticed that your code looks like the code that is generated by the blocks editor.

The java class TfodCurrentGame is generated by Blocks for the blocks that are optimized for Freight Frenzy. Those blocks, and the java class TfodCurrentGame will only load the default model for Freight Frenzy. You can’t tell it to load a different model that looks for your custom element.

If you are going to use OnBotJava, I suggest you create your opmode in OnBotJava, using one of the following samples: ConceptTensorFlowObjectDetection, ConceptTensorFlowObjectDetectionWebcam, or ConceptTensorFlowObjectDetectionSwitchableCameras.

Then, change the line

tfod.loadModelFromAsset(TFOD_MODEL_ASSET, LABELS);

to

tfod.loadModelFromFile(<your file>, <your labels>)
1 Like

Vuforia key removed from post. Please do not post vuforia keys along with sample software.

This topic was automatically closed after 15 hours. New replies are no longer allowed.