top of page
Search
Writer's pictureOrEo BoTs

Our Autonomous Strategy to Detect Sleeve using OpenCV

(written by our coach)


The team has been using OnBot Blocks for programming Autonomous & Teleop phases. However, the team couldn't get FTC-ml to generate a model that works reliably. They spent numerous hours with different sleeves (colors, textures, shapes, etc.). For the first play, the Autonomous strategy was to just part in the RIGHT parking zone and hope that the judges roll the dice that matches RIGHT :)


All the different sleeves used by the team

FIRST ML tool chain validating detections


For the second play, the coach suggested they try out EasyOpenCV to detect the sleeve. This requires that we code in Java. The coach asked the team to look at this code from a different FTC team that uses EasyOpenCV for sleeve detection. The team copied the code to onBot-Java and were pleasantly surprised to see it work with no changes. The only issue was that the camera needs to aim properly at the target.


With the sleeve detection working, the team pondered how to convert their Autonomous block code into Java. Fortunately, the OnBot blocks page shows Java code as well. They copied the code to the onBot Java class from the earlier step and were able to integrate it easily.





Here are the steps:

  1. Upload EasyOpenCV library.

    1. Follow the steps at https://github.com/OpenFTC/EasyOpenCV in the section - Installation instructions (OnBotJava)

  2. You can now write code and reference OpenCV classes

  3. Create a new class called 'SleeveDetection.java' and copy code from this GitHub link

  4. Copy class 'VisionTest.java' (from the same GitHub link)

  5. Hit the Build button to ensure the copied code has no errors.

  6. Print the sleeve from that link and try running the Autonomous program. On the DS, it should show up with a special icon. If it detects the color, you are good to proceed to the next step.

  7. Here we are assuming that you have an autonomous blocks program that you are using. Copy your Autonomous blocks generated Java code to a new class (Say MyAuto.java). You have to tweak a few things like the name you want to display on DS. Hit the Build button to ensure everything builds properly.

  8. You will now selectively copy code from VisitionTest.java to MyAuto.java. This is the part that requires you to understand both classes a little bit. It helps if your autonomous blocks program has enough comments and they will get copied to the generated Java code and is easy to follow.


If you have any questions post a message.


8 views0 comments

Recent Posts

See All

Comments


bottom of page