Brighton-FTC / FTC-2023

BSD 3-Clause Clear License
1 stars 0 forks source link

Research identifying pieces w/ CV #26

Open WebCoder49 opened 1 year ago

12sliu commented 1 year ago

https://docs.ftclib.org/ftclib/vision/high-goal-detection

UGBasicHighGoalPipeline pipeline = new UGBasicHighGoalPipeline();
camera.setPipeline(pipeline);

// Red Goal
if (pipeline.isRedVisible()) {
    Rect redRect = pipeline.getRedRect();
    Point centerOfRedGoal = pipeline.getCenterofRect(redRect);

    telemetry.addData("Red goal position",
                        centerOfRedGoal.toString());
}

// say we have a point called 'centerOfCamera'
double xDist = Math.abs(centerOfCamera.x - centerOfBlueGoal.x);
double yDist = Math.abs(centerOfCamera.y - centerOfBlueGoal.y);
double dist = Math.hypot(xDist, yDist);

// assume we have a method that turns the robot at some speed,
// but clamps it to [-1, 1]
while (true) {
    if (centerOfCamera.x < centerOfBlueGoal.x - TOLERANCE) {
        turn(dist);    // turning right is positive input
    } else if (centerOfCamera.x > centerOfBlueGoal.x + TOLERANCE) {
        turn(-dist);
    } else {
        turn(0);
        break;
    }
}

My idea is we steal this but replace the colour with whatever colour the pieces are. If this works, we should be able to identify if there is a piece on screen, turn to face it, and then move forward until distance sensors detect something. There's also something with pitch and yaw that I have no clue about in the link provided.

WebCoder49 commented 1 year ago

This repo contains the training scripts for TensorFlow Object Detection.

12sliu commented 1 year ago

took the base tensorflow thing and made some modifications, should detect if there is bolt, bulb, or panel and then send telemetry message, now looking at custom tensorflow thing

WebCoder49 commented 1 year ago

@12sliu , this diagram (Leconfield's House Robotics Conceptual Flowchart) may be a useful idea for custom sleeves using TFOD.

image

12sliu commented 1 year ago

stuck on how to install protobuf compiler, needs to be installed for installing tensorflow api

given the complexity of making a custom model, I think we should focus on getting what we have working first, then trying to train a tfod model

WebCoder49 commented 1 year ago

I agree with you. Just in case you get onto the stage of using a custom model, this may be useful in how to install TFOD, and it doesn't look like you would need to install TensorFlow separately.

12sliu commented 1 year ago

Image cannot install tensorflow api, have asked mr tattam for help, has anyone encountered this before?

removing use-feature from command results in this Image

am completely stuck, if nobody has a solution I'll post it on stack overflow

https://towardsdatascience.com/how-to-install-tensorflow-2-object-detection-api-on-windows-2eef9b7ae869 https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tf-models-install https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/eager_few_shot_od_training_tf2_colab.ipynb instructions to install

WebCoder49 commented 1 year ago

@12sliu , have you directly downloaded the python training scripts from here? I remember downloading these, opening PyCharm (with the educational discount) and then using it to install the libraries it said were needed; I did not look at any external docs.

WebCoder49 commented 1 year ago

If you use PyCharm with a venv interpreter then install the libraries in Ctrl+Alt+S > Project > Python Interpreter that may work. image

WebCoder49 commented 1 year ago

Also, you are using some bash commands like cp, etc. They don't work on Windows command.exe. However, if you open PowerShell from the start menu and use the same commands that may fix it.

WebCoder49 commented 1 year ago

I would recommend: 1) Do what you are doing, but in PowerShell, not CMD.exe 2) If that doesn't work, try using PyCharm

One last note: I don't think you need to install the generic TensorFlow Object Detection from a repo to use the FTC one; all you should need to download (excluding pip installs) is this repository.

12sliu commented 1 year ago
The conflict is caused by:
    tf-models-official 2.11.4 depends on tensorflow-addons
    tf-models-official 2.11.3 depends on tensorflow-addons
    tf-models-official 2.11.2 depends on tensorflow-addons
    tf-models-official 2.11.0 depends on opencv-python-headless==4.5.2.52
    tf-object-detection-api 0.1 depends on sacrebleu<=2.2.0
    tf-models-official 2.10.1 depends on sacrebleu==2.2.0
    tf-models-official 2.10.0 depends on opencv-python-headless==4.5.2.52
    tf-models-official 2.9.2 depends on tensorflow-addons
    tf-models-official 2.9.1 depends on tensorflow-addons
    tf-models-official 2.9.0 depends on tensorflow-addons
    tf-models-official 2.8.0 depends on tensorflow-addons
    tf-models-official 2.7.2 depends on tensorflow-addons
    tf-models-official 2.7.1 depends on tensorflow-addons
    tf-models-official 2.7.0 depends on tensorflow-addons
    tf-models-official 2.6.1 depends on tensorflow-addons
    tf-models-official 2.6.0 depends on tensorflow-addons
    tf-models-official 2.5.1 depends on tensorflow-addons

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: Cannot install tf-object-detection-api and tf-object-detection-api==0.1 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Error when I tried to install from pycharm

Image some details

Also ran same thing in Powershell, tried doing tf1 first and seemed to succeed, but then tf2 failed

I think I downloaded the repository you mentioned, what to do with it?

If this somehow manages to work, I assume we will skip everything about practising with the API and go directly to making video for training. When would this be arranged?

sorry for many question

WebCoder49 commented 1 year ago

I'm afraid that I'm quite busy with FRC at the moment; I will address this as soon as possible. I would recommend downloading the scripts from the repository and opening the training folder in PyCharm, then:

I wouldn't recommend installing the library from PIP, as it's likely to overcomplicate it. They are more utility scripts than a coherent module.

12sliu commented 1 year ago

even if I pulled a all-nighter, we don't have a video of the custom sleeve, so can't begin to do things

will probably try to finish for proof of concept after tmw ftc done

12sliu commented 1 year ago

waiting for sleeve to be made and video made, working on mecanum drive since I am relatively certain we are doing that

sbottingota commented 1 year ago

@12sliu, could you design and print out the custom sleeves for CV? (Order of Mo)

WebCoder49 commented 1 year ago

@12sliu, could you design and print out the custom sleeves for CV? (Order of Mo)

@12sliu this document may be useful if you have not seen it already: https://www.firstinspires.org/sites/default/files/uploads/resource_library/ftc/signal-sleeve-template.pdf

12sliu commented 1 year ago

Thanks Oliver.

Are we using April Tags or Tensorflow still? If Tensorflow, do I just stick whatever I want on the sleeve as long as the three sides are unique?

12sliu commented 1 year ago

Never mind, apparently Benji from engineering has gotten the sleeve designed and done. Apparently there is some miscommunication.

WebCoder49 commented 1 year ago

Never mind, apparently Benji from engineering has gotten the sleeve designed and done. Apparently there is some miscommunication.

Yes; I think I just saw a Teams message from Benji.