From 8c0f40d814a46c46e85246a226f92446ae4e93e1 Mon Sep 17 00:00:00 2001 From: jiru-shan <90534758+jiru-shan@users.noreply.github.com> Date: Mon, 3 Oct 2022 18:39:06 -0700 Subject: [PATCH 1/5] code that simply doesnt work(i test when I get back) --- .DS_Store | Bin 0 -> 8196 bytes TeamCode/.DS_Store | Bin 0 -> 6148 bytes TeamCode/src/.DS_Store | Bin 0 -> 6148 bytes TeamCode/src/main/.DS_Store | Bin 0 -> 6148 bytes TeamCode/src/main/java/.DS_Store | Bin 0 -> 6148 bytes TeamCode/src/main/java/org/.DS_Store | Bin 0 -> 6148 bytes .../src/main/java/org/firstinspires/.DS_Store | Bin 0 -> 6148 bytes .../main/java/org/firstinspires/ftc/.DS_Store | Bin 6148 -> 6148 bytes .../org/firstinspires/ftc/teamcode/.DS_Store | Bin 0 -> 6148 bytes .../org/firstinspires/ftc/teamcode/Claw.java | 51 -------------- .../firstinspires/ftc/teamcode/ClawTest.java | 9 ++- .../firstinspires/ftc/teamcode/Intake.java | 51 ++++++++++++++ .../teamcode/pipelines/colorDetection.java | 63 +++++++++++++++--- 13 files changed, 107 insertions(+), 67 deletions(-) create mode 100644 .DS_Store create mode 100644 TeamCode/.DS_Store create mode 100644 TeamCode/src/.DS_Store create mode 100644 TeamCode/src/main/.DS_Store create mode 100644 TeamCode/src/main/java/.DS_Store create mode 100644 TeamCode/src/main/java/org/.DS_Store create mode 100644 TeamCode/src/main/java/org/firstinspires/.DS_Store create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/.DS_Store delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Claw.java create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Intake.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b49b4aeea971149753384f6d81bf01707a030bcf GIT binary patch literal 8196 zcmeHM!EVz)5S?v8iwfY(=3>n__tjm~8U>63|D^)_ z{a~Xqwlq!@%C8PIG6euuF)R!E$O9zD*4WZGQ7EbKsj>&5sY0h1LeX*GW^-Um<3ypN zlTdULI^VC$h~w2d|frof1wn9`Du?X6!aGom#=G%sdvDn9>9_5x*Neh_wz2U| z%vGuv=4+O4a=%q_5H@`Xw+;r*X-uj)_Bbx-Dz&D*|)ZCkH>ZE z+Re?oy9dW_-j3dl-+#oiqX>OQ(~`QLwx7^DCCqCljiV&y*9AOt{!i619izaxDo|10 zS2_Rh%>MoVT<2h%8wHF4e^&uf-Enr>n8V4rU7il-+BWI|Di^k!D3la5G93rXbR0PS c!w`KNrp#$+oG8QyiuoZx%3vC!z#moMC!m5q82|tP literal 0 HcmV?d00001 diff --git a/TeamCode/.DS_Store b/TeamCode/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ccd9da17b0c34dea6d95e52cc295c4041648caa6 GIT binary patch literal 6148 zcmeHK&2G~`5S~p^*aQ$cAkhobUbsb7>L4Tzl}spy-jIyoK&#fSqt=q~R_b#qZ6Cc0VI=_tLQ9H^>nBwMOxbHL~cOJ zwrn4EH)pdT2zn|Q4CXyGdlmG1>c!yYeBPE%pKtH%9euv|GW$CJ_T6ZKHvq4IwZ|S8 z@B=}UtO)1PxX5*Jg3N-wU@@`+tN<&pMg{yQNIqEOoIDjPzzWicKkNg5Z zM`w1o1+Cshq|CtVo6OE^n73g!!x-c4s9j~O$QTo#h?zVL-w4j5E=b0BvVa`dXhiZR zh-3iIxFE^@X8`vu$9l|XA&bB4-x191zAI6M%;SRbuy6MHHRwm-FsW4DcqW@$SzQyN zAPO6WYp*NEUg9UCq3aJW@#)l0x`DCJq>SdaADoAsakIE}EaSuvgIg+`aYrMK!~ikynE~wmK#F+(pZwhas~{SP0b*b|8Q{6PS9hT{ zbGI&3iFd69+5$zvxK!gj1q^i+Lo8m!B~T^cx6lA|45k{v142IniUt~pfj?#714Z;& A@Bjb+ literal 0 HcmV?d00001 diff --git a/TeamCode/src/main/.DS_Store b/TeamCode/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..256578cd52ab6bf51e546070b5be30a25a9745d1 GIT binary patch literal 6148 zcmeHK&2AGh5FRHfI6;U=Ahj1HU${k8x05tK6fj( zJpP1p7z-j!qj8bz;w^k8z6pXs=rTRxE=DfWh%O5=zzi@0SIvOG#N>^uUWn&s2AF|= zjsbH&D5$~EW9`sh9cb(m0N8@t3T*RpXmXUt&|~coBM{+Ifi6|}Cx&q8@GBn|daNC~ zbQ1pYA^gh1zfgo-9rG(2P9k*3Ei=FjEHlt_-L9$sk1v1!FDG%28DIwfD+WYsH`*Oy zOTM$rSMG6dCiV&|~co9ti&kSQ@xt2L31mKLCl# Bc5MIv literal 0 HcmV?d00001 diff --git a/TeamCode/src/main/java/.DS_Store b/TeamCode/src/main/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e0a871fd5e2789e3bbbaf95436c7d1581b2cadda GIT binary patch literal 6148 zcmeHK!AiqG5Z!I7ZYyFBf*y16R-{cu@F2vhhu(yU9#k~3r47VvX;X{VN`6EC$S?47 zbY^#25cMX4Wd>&7WOio5ybZe`$7s-()4=8aBeG|qy zgeP2%YL2v3k!=&N|jV; zrF7|c^~g_ybU0`P{d0Ue4$^K&_KDW<%nriSs6DzWuN~+l4WgvoH_1_}4Ivk2QPR?* zh8`xZfmz456G|0T@v6Kr9=onvaol=+QgOz+ZnffU*LNn9qFUdq?KQ7&?;pmGlc#69 z6B0gBBddf{cmadTyYu@=tdkCSrqRi}Y=SCsK%&RJaEnmtAS4b*Zdwk#AsN8|P-~MwEg5fQJ4BEM`8VK? z_yRr$-t2BFP@zW@&^&4Ojdy3(_FHS$Lquw_nC=q|h)BbjJ3TbN0gtm?LMQa>fR&r0 zp`1#pX$}_r3kvYs?a~{pSA})^dHpJyQGHz4*I8jRMDZtb0K50y0p69F*|MI8%&*zJ z$m?b_`ldQN-D}rxXx-QS-TtfO%r28AZ5H(;tzPiele9U@g8$Uo;=)g}XZdV-GPr$c z%O=gsS>=-R=?oz+pXcS&E+=+TPHQ($;s>E6j;Z?%e|XlSDGcs(?$htX(g?vEd= z*FAmb?*60W({~>}uFlt=KD(D9g^$_cR^SbNfpdje?~|%5Z21;Zn;ABl!lHmEAPQ`i z0%4QVH@E7ky$Or!WS`wVp3h;JBk0v3wNo!5q+U*a63ZThHhL P*&Uxcv^ z;R%;x`40@>-sQ!mNX5lL{AK@kVP@mqh$)1k!eRfGcKJ2DjiY{At-i@zzA!hxpj1hf zmP+UTwI2FukPiBdpm&N-he3KBl6|Cg{AmZ_anv2Q$}4+1NrNcq_Dpir=|afaNtAT- zu%QP@r*GEr?SxWARcw{lMkCjCD~?;Qk1Nh-+pSid&HC1OTvV&;wVi|Z&HcmZas2db zcS6EPYGj#k0xw`td3Sy{6n literal 0 HcmV?d00001 diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/.DS_Store b/TeamCode/src/main/java/org/firstinspires/ftc/.DS_Store index 24698b5421d2b01cfac1aef9e66def2d200186da..6f4c0632d23e8a770d87eb4ede6aa9c7352b756a 100644 GIT binary patch delta 375 zcmZoMXfc=|#>B)qu~2NHo}wr-0|Nsi1A_nqLo!1?LkdHxXHI_d#*NDv>p?Oc3?&Sy z42cZ6$g)W}`AI-IpcV#4AlCa220#`T^-1N$1yJ=TlL~S&i%Sd)t}`+*v#_$Ub8v8R zaPe}*2501#2bUz4lomTB7Da=20f{9U^+`}pNPd0}oSm2ymYG@}FCgNapI4HYnU`7w z)}5J>3RDsko|%`DU+$D&nwL@xHYgY(!NI}F!5J?gQC)3hWTc~DWNcikqfl*WWT2y9 zVr*7h%gG_GYG~`3kXu<*T~k{(6XX>cV7LGS1`PP2G>n?HvF8!XW_AvK4q!lT-1wb& aGQWtf2uK#BqX9yLHE#|P*}y!pfdv5bxL@c1 delta 88 zcmZoMXfc=|#>CJzu~2NHo}wrt0|NsP3otMwGvqU*Fr=0R7v)VXRA*$|tjhd|Wpe`a nOs3839Q+(WEt>(@U{vNu7J1?a)s!(({o zw>0F4b}OtCut!wPSN{^b_I8PFgPkDiWD|qFFEMuJj4NWvC;hhYq)mEC8HF@P#As7I zad#=6O+$*|5m+&$Jin?U;`7yvU@{tN4Sxi~Bpwyr?oUzMs^7Z3ZCMSgvD0`xIL{`7 z!Y{_7zMsG3(lfs}4|M({%aVEC51z--B1zht{pKQMWS4pO1 z6fg?hC Date: Fri, 7 Oct 2022 20:25:25 -0700 Subject: [PATCH 2/5] slightly suspicious code --- .../firstinspires/ftc/teamcode/Camera.java | 16 +++---- .../ftc/teamcode/CameraTest.java | 17 ++++++- .../firstinspires/ftc/teamcode/ClawTest.java | 45 ------------------- .../ftc/teamcode/IntakeTest.java | 34 ++++++++++++++ .../teamcode/pipelines/colorDetection.java | 12 ++--- 5 files changed, 60 insertions(+), 64 deletions(-) delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ClawTest.java create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeTest.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Camera.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Camera.java index 3c1a055d..849a3664 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Camera.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Camera.java @@ -15,13 +15,6 @@ public class Camera OpenCvWebcam camera; colorDetection pipeline; - public Camera.State state; - public enum State - { - ONE, - TWO, - THREE - } public Camera(HardwareMap hardwareMap, Telemetry telemetry) { int cameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName()); @@ -44,12 +37,13 @@ public void onError(int errorCode) } }); } - public void update() + + public OpenCvWebcam streamSource() { - state=pipeline.getOutput(); + return camera; } - public Camera.State getState() + public int getState() { - return state; + return pipeline.getOutput(); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/CameraTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/CameraTest.java index 0f635b0c..6b4dd244 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/CameraTest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/CameraTest.java @@ -1,21 +1,34 @@ package org.firstinspires.ftc.teamcode; +import com.acmerobotics.dashboard.FtcDashboard; +import com.acmerobotics.dashboard.telemetry.TelemetryPacket; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +@TeleOp public class CameraTest extends LinearOpMode + { + FtcDashboard dashboard; + TelemetryPacket packet; Camera camera; @Override public void runOpMode() throws InterruptedException { + packet=new TelemetryPacket(); + dashboard=FtcDashboard.getInstance(); + camera=new Camera(hardwareMap, telemetry); + dashboard.startCameraStream(camera.streamSource(),30); waitForStart(); while(opModeIsActive()) { - camera.update(); - telemetry.addData("Status:", camera.getState()); + packet.put("Zone:", camera.getState()); + dashboard.sendTelemetryPacket(packet); + + telemetry.addData("Zone:", camera.getState()); telemetry.update(); } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ClawTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ClawTest.java deleted file mode 100644 index 218fdc5a..00000000 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ClawTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.firstinspires.ftc.teamcode; - -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.util.ElapsedTime; - -public class ClawTest extends LinearOpMode -{ - Intake claw; - ElapsedTime time; - @Override - public void runOpMode() throws InterruptedException - { - - time=new ElapsedTime(); - claw=new Intake(hardwareMap); - - waitForStart(); - - claw.update(); - - time.reset(); - while(time.seconds()<3) - { - - } - - claw.setState(Intake.State.PARTIAL); - claw.update(); - - time.reset(); - while(time.seconds()<3) - { - - } - - claw.setState(Intake.State.CLOSE); - claw.update(); - - time.reset(); - while(time.seconds()<3) - { - - } - } -} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeTest.java new file mode 100644 index 00000000..f83b863b --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/IntakeTest.java @@ -0,0 +1,34 @@ +package org.firstinspires.ftc.teamcode; + +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +@TeleOp + +public class IntakeTest extends LinearOpMode +{ + Intake intake; + + @Override + public void runOpMode() throws InterruptedException + { + intake=new Intake(hardwareMap); + + waitForStart(); + + while(opModeIsActive()) + { + if(gamepad1.a) + { + intake.setState(Intake.State.IN); + } + else if(gamepad1.b) + { + intake.setState(Intake.State.OUT); + } + else if(gamepad1.x) + { + intake.setState(Intake.State.OFF); + } + } + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java index 20dda6fb..f7502d35 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java @@ -15,13 +15,13 @@ public class colorDetection extends OpenCvPipeline { Mat finalMat; - Camera.State state; + int state=1; Telemetry tel; public colorDetection(Telemetry tel) { this.tel=tel; - state=Camera.State.ONE; + state=1; } @@ -86,15 +86,15 @@ public Mat getZone(Mat input) if(bAvg.val[0]*1.7 Date: Sun, 9 Oct 2022 13:03:42 -0700 Subject: [PATCH 3/5] why do i not have a single pink object in my house --- .gitignore | 1 + .../teamcode/pipelines/colorDetection.java | 119 ++++++++++++------ 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 7d82b7e2..75a7df0e 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,4 @@ lint/generated/ lint/outputs/ lint/tmp/ # lint/reports/ +TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/eocvsim_workspace.json diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java index f7502d35..2164fdad 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pipelines/colorDetection.java @@ -1,7 +1,7 @@ package org.firstinspires.ftc.teamcode.pipelines; import org.firstinspires.ftc.robotcore.external.Telemetry; -import org.firstinspires.ftc.teamcode.Camera; +//import org.firstinspires.ftc.teamcode.Camera; import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; @@ -9,9 +9,13 @@ import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.core.Size; +import org.opencv.imgproc.CLAHE; import org.opencv.imgproc.Imgproc; import org.openftc.easyopencv.OpenCvPipeline; +import java.util.ArrayList; +import java.util.List; + public class colorDetection extends OpenCvPipeline { Mat finalMat; @@ -27,76 +31,110 @@ public colorDetection(Telemetry tel) public Mat preProcessing(Mat input) { - Mat canYouNotBeNormal=new Mat(); - Core.normalize(input, canYouNotBeNormal, 20, 200, Core.NORM_MINMAX); - //canYouNotBeNormal=normalizeV2(laCringe); + Mat blur=new Mat(); + Imgproc.blur(input, blur, new Size(3,3)); - //LAB - Mat LAB =new Mat(); - Imgproc.cvtColor(canYouNotBeNormal, LAB, Imgproc.COLOR_RGB2Lab); + Mat colorSpace1=new Mat(); + Imgproc.cvtColor(blur, colorSpace1, Imgproc.COLOR_RGB2Lab); - //Blur - Mat blurred=new Mat(); - Imgproc.blur(LAB, blurred, new Size(3, 3)); + Mat colorLetter1=new Mat(); + Core.extractChannel(colorSpace1, colorLetter1, 0); - //Dilate - Mat dilate=new Mat(); - Mat kernel=new Mat(); - kernel=Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3)); - Imgproc.dilate(blurred, dilate, kernel, new Point(1.5, 1.5), 1); + Imgproc.equalizeHist(colorLetter1, colorLetter1); + Core.insertChannel(colorLetter1, colorSpace1, 0); + + Mat RGB=new Mat(); + Imgproc.cvtColor(colorSpace1, RGB, Imgproc.COLOR_Lab2RGB); + + Mat colorSpace2=new Mat(); + Imgproc.cvtColor(RGB, colorSpace2, Imgproc.COLOR_RGB2YCrCb); + + List channels=new ArrayList(); + Core.split(colorSpace2, channels); + CLAHE cl=Imgproc.createCLAHE(2.5, new Size(8, 8)); + for(Mat m:channels) + { + cl.apply(m, m); + } + Core.merge(channels, colorSpace2); + Imgproc.cvtColor(colorSpace2, colorSpace2, Imgproc.COLOR_YCrCb2RGB); - Scalar lower=new Scalar(50, 1, 1); - Scalar higher=new Scalar(255, 255, 255); + //Mat canYouNotBeNormal=new Mat(); + //Core.normalize(input, canYouNotBeNormal, 20, 200, Core.NORM_MINMAX); + //canYouNotBeNormal=normalizeV2(laCringe); + //LAB + Mat LAB =new Mat(); + Imgproc.cvtColor(colorSpace2, LAB, Imgproc.COLOR_RGB2Lab); - Mat mask=new Mat(); - Core.inRange(dilate, lower, higher, mask); + Mat temp2=new Mat(); + Rect rect=new Rect(50, 100, 100, 100); - Mat kernel1=new Mat(); - Mat morphed=new Mat(); - kernel1=Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(6,6)); - Imgproc.morphologyEx(mask, morphed, Imgproc.MORPH_OPEN, kernel1); + temp2=LAB.submat(rect); - Mat morphed01=new Mat(); - kernel1=Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4,4)); - Imgproc.morphologyEx(morphed, morphed01, Imgproc.MORPH_CLOSE, kernel1); - Mat temp=new Mat(); - Core.bitwise_and(LAB, LAB, temp, morphed01); + //Mat mask01=new Mat(LAB.rows(), LAB.cols(), CvType.CV_8U, Scalar.all(-1)); + //Imgproc.rectangle(mask01, rect, new Scalar(255), -1); + //Core.bitwise_and(temp, temp, temp2, mask01); - Mat temp2=new Mat(); - Rect rect=new Rect(50, 100, 50, 100); - Mat mask01=new Mat(LAB.rows(), LAB.cols(), CvType.CV_8U, Scalar.all(0)); - Imgproc.rectangle(mask01, rect, new Scalar(255), -1); - Core.bitwise_and(temp, temp, temp2, mask01); return temp2; } public Mat getZone(Mat input) { + //Mat H; + Mat A, B; A=new Mat(); B=new Mat(); + //=new Mat(); Core.extractChannel(input, A, 1); Core.extractChannel(input, B, 2); + // Core.extractChannel(input, H, 0); - Scalar aAvg=Core.mean(A); - Scalar bAvg=Core.mean(B); + Scalar a=Core.mean(A); + Scalar b=Core.mean(B); - if(bAvg.val[0]*1.7140) { state=2; } - else if(aAvg.val[0]-bAvg.val[0]<=30) + else + { + state=3; + } +*/ + //pink + if(bAvg*1.5100) { state=3; } //update the state + + return input; } @@ -108,9 +146,10 @@ public Mat processFrame(Mat input) temp=preProcessing(input); Mat temp2=new Mat(); temp2=getZone(temp); + tel.addData("State", state); + tel.update(); - - return null; + return temp; } public int getOutput() From 4f94c5f3f05fe28a167876e9011f8ade651c8ceb Mon Sep 17 00:00:00 2001 From: jiru-shan Date: Sun, 9 Oct 2022 20:40:57 -0700 Subject: [PATCH 4/5] f --- .../src/main/java/org/firstinspires/ftc/teamcode/Intake.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Intake.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Intake.java index 8e33f401..5c0ede09 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Intake.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Intake.java @@ -2,6 +2,7 @@ import com.arcrobotics.ftclib.hardware.ServoEx; import com.qualcomm.robotcore.hardware.CRServo; +import com.qualcomm.robotcore.hardware.DcMotorSimple; import com.qualcomm.robotcore.hardware.HardwareMap; public class Intake @@ -19,6 +20,8 @@ public Intake(HardwareMap hardwareMap) intake1=hardwareMap.get(CRServo.class, "intake1"); intake2=hardwareMap.get(CRServo.class, "intake2"); + intake1.setDirection(DcMotorSimple.Direction.REVERSE); + setState(State.OFF); } From 6461907290a92fa94bf14aaea775807c247553ff Mon Sep 17 00:00:00 2001 From: jiru-shan <90534758+jiru-shan@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:51:03 -0700 Subject: [PATCH 5/5] vision and slides --- .../org/firstinspires/ftc/teamcode/.DS_Store | Bin 6148 -> 6148 bytes .../firstinspires/ftc/teamcode/Slides.java | 109 ++++++++++++++++++ .../teamcode/pipelines/colorDetection.java | 10 +- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Slides.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/.DS_Store b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/.DS_Store index 9f26f265c179a26bf49d89f693f709b0b803421d..8b14399144528f6957d403e78c9865319cc067b9 100644 GIT binary patch delta 36 scmZoMXfc@J&&a+pU^g=(`(z%L^3CsAN*OoLV9RHm*sx$TJI7ys0Nw!%jQ{`u delta 143 zcmZoMXfc@J&&ahgU^g=(*JK`+a!yVLXNDYxM27Oo6Idja7}hf|FzEdU10aimffpvt z5WLaF>Yq(_{$Ffs9z`P diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Slides.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Slides.java new file mode 100644 index 00000000..ba9cd81c --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Slides.java @@ -0,0 +1,109 @@ +package org.firstinspires.ftc.teamcode; + +import com.qualcomm.robotcore.hardware.DcMotorEx; +import com.qualcomm.robotcore.hardware.DigitalChannel; +import com.qualcomm.robotcore.hardware.HardwareMap; + +public class Slides { + + DigitalChannel limitSwitch; + public DcMotorEx slidesLeft; + public DcMotorEx slidesRight; + //slides is 17.5 inches tall + static final double HIGH = 16; //in inches, 33.5 - 17.5 (high junction height - slides height) + static final double MID = 6; //in inches, 23.5 - 17.5 (mid junction height - slides height) + static final double LOW = 0; //in inches, low junction is 13.5 inches + static final double THRESHOLD=20; + + public targetPos target; + public enum targetPos { + HIGH, MID, LOW + } + + public State state; + public enum State + { + MOVING, STOPPED, RESETTING + } + + public Slides(HardwareMap hardwareMap) { + slidesLeft = hardwareMap.get(DcMotorEx.class, "s1"); + slidesRight = hardwareMap.get(DcMotorEx.class, "s2"); + limitSwitch = hardwareMap.get(DigitalChannel.class, "limitSwitch"); + + //reverse a motor + limitSwitch.setMode(DigitalChannel.Mode.INPUT); + setTarget(targetPos.LOW); + } + + public void update() + { + switch(state) + { + case MOVING: + slidesLeft.setPower(motorPower()); + slidesRight.setPower(motorPower()); + if(Math.abs(((slidesLeft.getCurrentPosition()+slidesRight.getCurrentPosition())/2)- targetTicks())100) return input; } + //120 @Override public Mat processFrame(Mat input) @@ -149,7 +153,9 @@ public Mat processFrame(Mat input) tel.addData("State", state); tel.update(); - return temp; + Mat preview=input.clone(); + Imgproc.rectangle(preview, rect, new Scalar (0, 255, 0)); + return preview; } public int getOutput()