Skip to content

Instantly share code, notes, and snippets.

@WestsideRobotics
Created June 14, 2023 22:43
Show Gist options
  • Select an option

  • Save WestsideRobotics/41c004c097ecbf8f96c4e722b8336bd6 to your computer and use it in GitHub Desktop.

Select an option

Save WestsideRobotics/41c004c097ecbf8f96c4e722b8336bd6 to your computer and use it in GitHub Desktop.
6-14-23 FTC Blocks OpMode to demonstrate Exposure Control
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</variable>
<variable id="OlJB[R?bruF2C6T]y:j,">myTfodRecognitions</variable>
<variable id=";4p[WSAfI5s@@3gK1|$R">exposureSetModeReturn</variable>
<variable id="|`#{+60SL-9`I$UFs;dG">exposureValue</variable>
<variable type="TfodProcessor.Builder" id="nN$Hc]Yea=/(:3{Flx89">myTfodProcessorBuilder</variable>
<variable id="Xk!_{IPng0#/P|7dx?3N">myVisionPortal</variable>
<variable id="_+s(|?n0/6QSbjXh*V}P">exposureValueMin</variable>
<variable id="mcIIY]f9gD8kNPOydZ@6">setExposureReturn</variable>
<variable id="2(2G$#dr!gUmh_~QL5ZA">myTfodProcessor</variable>
<variable id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</variable>
<variable id="Z-p[R6(8}7,`}*oU/[#w">exposureValueMax</variable>
<variable type="VisionPortal.Builder" id="wx@xgbnS_]b0DQL.08Qg">myVisionPortalBuilder</variable>
<variable id="h_4q]^+cuMwY?7E#7$Pc">x</variable>
<variable id="R{3+3{j6;,uRMizwTeH6">y</variable>
</variables>
<block type="procedures_defnoreturn" id="WtpyD@tEu+EoY=P9iY,D" deletable="false" x="-159" y="-468">
<field name="NAME">runOpMode</field>
<comment pinned="false" h="236" w="594">This OpMode demonstrates Camera Controls in FTC Blocks, new for summer 2023.
These control webcams only, not built-in phone cameras. Webcams can be used with RC phones, with a USB Hub.
To see the effect of these controls, use DS Camera Stream (in INIT only) or the RC preview (on RC phone screen or using "scrcpy" for Control Hub).
TensorFlow Object Detection is the example processor here, since its recognitions may benefit (from Camera Controls) more than AprilTag Detection.</comment>
<statement name="STACK">
<block type="comment" id="{FTP~#hq.B:)xE7{!GQO">
<field name="COMMENT">Demonstrate Camera Controls in FTC Blocks.</field>
<next>
<block type="procedures_callnoreturn" id="f5VC4xOrYYZrGzpFY}@G">
<mutation name="initialize TFOD"/>
<comment pinned="false" h="43" w="264">Initialize TFOD before waitForStart.</comment>
<next>
<block type="controls_whileUntil" id="|)X/[B*PK(P}Q=9iY]3_">
<field name="MODE">WHILE</field>
<value name="BOOL">
<block type="logic_operation" id="?VkFe9T/2EeLKs==mVjY" inline="false">
<field name="OP">AND</field>
<value name="A">
<block type="logic_compare" id="mwx`#dW5+U.0h^|{Roq)">
<field name="OP">NEQ</field>
<value name="A">
<block type="visionPortal_getCameraState" id="Z}MiLy#YM.mJ04?@WwA#">
<comment pinned="false" h="150" w="325">Return the state of the camera.</comment>
<value name="VISION_PORTAL">
<block type="variables_get" id="VM}X:(|wnEV)_(eJFWhn">
<field name="VAR" id="Xk!_{IPng0#/P|7dx?3N">myVisionPortal</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="visionPortal_typedEnum_cameraState" id=":~bYM]4?Revt~ER`xt+[">
<field name="CAMERA_STATE">STREAMING</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="linearOpMode_opModeInInit" id="L,y8@~=sgR).1?(m$-OL"/>
</value>
</block>
</value>
<statement name="DO">
<block type="comment" id="fwZ:jp^SY9TrO,2WqwXL">
<field name="COMMENT">Wait for Streaming to begin, before using Camera Controls.</field>
<next>
<block type="linearOpMode_sleep_Number" id="7!N^flV~|,s9z;IUUTU3">
<value name="MILLISECONDS">
<shadow type="math_number" id="FlhI2Rpo.?_GCVR2]7M{">
<field name="NUM">20</field>
</shadow>
</value>
</block>
</next>
</block>
</statement>
<next>
<block type="procedures_callnoreturn" id="Y!4l-Td~ywLbZbtxzA`[">
<mutation name="intialize Exposure Control"/>
<next>
<block type="controls_whileUntil" id="zIP.;WMD}xO7)/)YXgx*">
<field name="MODE">WHILE</field>
<value name="BOOL">
<block type="logic_operation" id="7RSxoqRjR-Vrhr$sC0AR" inline="false">
<field name="OP">AND</field>
<value name="A">
<block type="logic_negate" id=":3WQ?@ip11E=3(Yzen.?">
<value name="BOOL">
<block type="gamepad_getProperty_Boolean" id="0q0gYWWQu3pLA0{o!juM">
<field name="IDENTIFIER">gamepad1</field>
<field name="PROP">Back</field>
<data>{"IDENTIFIER":"gamepad1"}</data>
</block>
</value>
</block>
</value>
<value name="B">
<block type="linearOpMode_opModeInInit" id="nA4~jI_40rN]O9Y=}{~f"/>
</value>
</block>
</value>
<statement name="DO">
<block type="comment" id="v8Qb8-Jxm4`%vRfd@*jN">
<field name="COMMENT">Control and display camera settings, with DS or RC preview.</field>
<next>
<block type="procedures_callnoreturn" id="x!-|A?AbjH{Cp@E1OQ.8">
<mutation name="standard INIT telemetry"/>
<next>
<block type="procedures_callnoreturn" id="%]_]-n:v~sk*GEgUBnm:">
<mutation name="control Exposure"/>
<next>
<block type="procedures_callnoreturn" id="zc;m5h{(K7ey95t3w=co">
<mutation name="camera settings telemetry"/>
<next>
<block type="telemetry_update" id="w[UR2G}Co^=bAr9rq6ew"/>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
<next>
<block type="procedures_callnoreturn" id="E@Px,5-jrK)-)t]=sU$l">
<mutation name="standard INIT telemetry"/>
<next>
<block type="telemetry_update" id=",aO02JT)W(_12b(q8Nc.">
<next>
<block type="comment" id="/TX8,^RvHuP6X%R,Py^^">
<field name="COMMENT">Wait for the DS Start button to be touched.</field>
<next>
<block type="linearOpMode_waitForStart" id=":`$wN_ci`O;o6P0~.(+g">
<next>
<block type="controls_if" id="}Q?5mbxSO8Di;i!__6[y">
<value name="IF0">
<block type="linearOpMode_opModeIsActive" id=")o%YFX/#9kvv^sgXr4~5"/>
</value>
<statement name="DO0">
<block type="controls_whileUntil" id="^0Kagy/e+Ea{rbZPv2G6">
<field name="MODE">WHILE</field>
<value name="BOOL">
<block type="linearOpMode_opModeIsActive" id="e)cr{!2VIET83s,JWC.="/>
</value>
<statement name="DO">
<block type="procedures_callnoreturn" id="1gvMm%Z3sFW-i|1[op?W">
<mutation name="telemetry of TFOD recognitions"/>
<next>
<block type="telemetry_update" id="exvivmft-pX$n!1,8Ea$">
<comment pinned="false" h="58" w="141">Push telemetry to the Driver Station.</comment>
<next>
<block type="linearOpMode_sleep_Number" id="jjoCwI:;J87CrtGs%}K7">
<comment pinned="false" h="43" w="134">Share the CPU.</comment>
<value name="MILLISECONDS">
<shadow type="math_number" id="w~.7$M*lJeh#@I/xsbHy">
<field name="NUM">20</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="E?G|4SztDu6,pY%7m|Mp" x="872" y="-427">
<field name="NAME">intialize Exposure Control</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="variables_set" id="=DK9$.^iFw5.^(+m@u+5">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
<comment pinned="false" h="150" w="325">Get the ExposureControl object, to allow adjusting the camera's exposure.</comment>
<value name="VALUE">
<block type="visionPortal_getExposureControl" id="rMo3*Sshd+D@M850piw{">
<value name="VISION_PORTAL">
<block type="variables_get" id=")gy#Q@/]woQ7ny/LyEz2">
<field name="VAR" id="Xk!_{IPng0#/P|7dx?3N">myVisionPortal</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="[tMFBS;BQKA*bX(CPl,q">
<field name="VAR" id=";4p[WSAfI5s@@3gK1|$R">exposureSetModeReturn</field>
<value name="VALUE">
<block type="exposureControl_setMode" id="MJ+mN%w=4g|Ebe|8;XUu">
<comment pinned="false" h="150" w="325">Set the exposure mode value.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="T!AfB`_vB44$r::GhGsU">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="MODE">
<shadow type="exposureControl_typedEnum_mode" id="PUJkN_U){EqUe?~Y1zG}">
<field name="MODE">Manual</field>
</shadow>
<block type="exposureControl_typedEnum_mode" id="3#QJpB|$fel`i@Zl,@45">
<field name="MODE">Manual</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="Fa;j(j{A-iYssuw)if|h">
<field name="VAR" id="_+s(|?n0/6QSbjXh*V}P">exposureValueMin</field>
<value name="VALUE">
<block type="exposureControl_getExposure" id=":^*s0J2OaxyGz*?c%bww">
<field name="FUNC">getMinExposure</field>
<comment pinned="false" h="150" w="325">Return the current (or minimum or maximum) exposure.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id=")e]+O_)Y`664$r*a[=S5">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="TIME_UNIT">
<shadow type="misc_typedEnum_TimeUnit" id="IAof,0K{3)ytcy}ZUvop">
<field name="TIME_UNIT">MILLISECONDS</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="Z}z6ahuN~NG]%S#jwD*[">
<field name="VAR" id="Z-p[R6(8}7,`}*oU/[#w">exposureValueMax</field>
<value name="VALUE">
<block type="exposureControl_getExposure" id=";R,3GeY6JN*D=-D#n$nM">
<field name="FUNC">getMaxExposure</field>
<comment pinned="false" h="150" w="325">Return the current (or minimum or maximum) exposure.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="]*J`$m-)/~Qu9J?!]j;9">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="TIME_UNIT">
<shadow type="misc_typedEnum_TimeUnit" id="JUJEs)K)Q?OF#5SA.l8P">
<field name="TIME_UNIT">MILLISECONDS</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="Zd3x]CtNbLl].ePrlt[r">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
<value name="VALUE">
<block type="exposureControl_getExposure" id="+YBp]RqPbVCj*=-PmmU@">
<field name="FUNC">getExposure</field>
<comment pinned="false" h="150" w="325">Return the current (or minimum or maximum) exposure.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="yr}vt{G+hp}?}78$%k={">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="TIME_UNIT">
<shadow type="misc_typedEnum_TimeUnit" id="fv;GDZm,Y34xB]^HXxo/">
<field name="TIME_UNIT">MILLISECONDS</field>
</shadow>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="01E#QZp{vCf`Y7EFZ)N$" x="1862" y="-408">
<field name="NAME">camera settings telemetry</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="comment" id="cJB6;t%)oLQi_lS+L^Z=">
<field name="COMMENT">Show camera settings</field>
<next>
<block type="telemetry_addTextData_All" id="LGBc77ozsa1J7R|Wk+$J">
<value name="KEY">
<shadow type="text" id="W|rIH+UD%2E`$B?2LOmQ">
<field name="TEXT">LEFT BUMPER/TRIGGER for Exposure (ms)</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="OpwOr7[gM7!ga5^)oJ8R">
<field name="TEXT">text</field>
</shadow>
<block type="misc_formatNumber" id="6YGu/xTR6n]L5_ss:`Ps">
<value name="NUMBER">
<shadow type="math_number" id="(hu*T_][!J4cKjqU45w#">
<field name="NUM">3.14159265</field>
</shadow>
<block type="variables_get" id="JkL~GJ2T7WCu@-w-~P?,">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="~a|UmU]o+%YJ):nyuWOx">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="telemetry_addTextData_All" id="qB1pSfd_gfHGpBz!EUIT">
<value name="KEY">
<shadow type="text" id="s0,#X%|_KtnF)3Z,r/t(">
<field name="TEXT">Actual Exposure, from webcam</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id=";grDLI@DC:nM{yI7m{S!">
<field name="TEXT">text</field>
</shadow>
<block type="exposureControl_getExposure" id="9_~$,lN@Oy}mV7L@h$U,">
<field name="FUNC">getExposure</field>
<comment pinned="false" h="150" w="325">Return the current (or minimum or maximum) exposure.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="hm]}oAGsIY|$!7lCra.,">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="TIME_UNIT">
<shadow type="misc_typedEnum_TimeUnit" id="T9(B5)/Lfvx~}5%{w#H5">
<field name="TIME_UNIT">MILLISECONDS</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="telemetry_addTextData_All" id="[$f~Y~L4Z*?V:7Jbjd},">
<value name="KEY">
<shadow type="text" id="]KB/Sw$C6iLSu#g=:Ay0">
<field name="TEXT">Exposure Mode, from webcam</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="RTO0`C;tlCeKI`Z`:/Y_">
<field name="TEXT">text</field>
</shadow>
<block type="exposureControl_getMode" id="[,/#J*^1qUiT=H9r)uR{">
<comment pinned="false" h="150" w="325">Return the current exposure mode value.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="GH[XrN2o+4/mPbbtgoiR">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
</block>
</value>
<next>
<block type="telemetry_addLine" id="4G~l!{KLE$he0kn:~U|,">
<value name="TEXT">
<shadow type="text" id="lND/}v}2TrEn]{V/S,k+">
<field name="TEXT"/>
</shadow>
</value>
<next>
<block type="comment" id="3UhIHOZh3YgP//`Ur?a3" disabled="true">
<field name="COMMENT">For testing only: show Booleans returned from setters</field>
<next>
<block type="telemetry_addTextData_All" id="=w86)WeZ)j`huk8,)`D#" disabled="true">
<value name="KEY">
<shadow type="text" id="$WXH,FI7%#hzLt1h!Gv?">
<field name="TEXT">Output from initial ExposureControl.setMode</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="E=d!Fkt{(|Ob*:0!Z/Pz">
<field name="TEXT">text</field>
</shadow>
<block type="variables_get" id="KWm170?0SPrsOR.=y].=">
<field name="VAR" id=";4p[WSAfI5s@@3gK1|$R">exposureSetModeReturn</field>
</block>
</value>
<next>
<block type="telemetry_addTextData_All" id="g6h`O{I;2BWBY)Uw!NsH" disabled="true">
<value name="KEY">
<shadow type="text" id="61-{pW:F%jsyS:yg|g-q">
<field name="TEXT">Output from ExposureControl.setExposure</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="6Saew+3cu(7tCd28rbKs">
<field name="TEXT">text</field>
</shadow>
<block type="variables_get" id=":}E6TQTAd!4n)XFapid}">
<field name="VAR" id="mcIIY]f9gD8kNPOydZ@6">setExposureReturn</field>
</block>
</value>
<next>
<block type="telemetry_addLine" id="k*GO^dMqUK-A2^$^C2{I" disabled="true">
<value name="TEXT">
<shadow type="text" id="F0SqZl@)HaRdLiTXQ,^u">
<field name="TEXT"/>
</shadow>
</value>
<next>
<block type="telemetry_addLine" id="6}FAbW_wW[K%uKTx03y]">
<value name="TEXT">
<shadow type="text" id="y2Lox@.t!%Qyl}TW=vpX">
<field name="TEXT">Press BACK or SHARE button when done setting Camera Controls.</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="q4^QXa[j%IWY6b6$Z`J0" x="876" y="34">
<field name="NAME">control Exposure</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="controls_if" id="*.5#,HV$^r%%Md0r$CZC">
<mutation elseif="1"/>
<value name="IF0">
<block type="gamepad_getProperty_Boolean" id="z.ux]*zXUTDE.YkT;@rC">
<field name="IDENTIFIER">gamepad1</field>
<field name="PROP">LeftBumper</field>
<data>{"IDENTIFIER":"gamepad1"}</data>
</block>
</value>
<statement name="DO0">
<block type="math_change" id="DI%i7!|!lW9Q[jdX$e*E">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
<value name="DELTA">
<shadow type="math_number" id="^,Yll7t!y.-?8h(gB6n}">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</statement>
<value name="IF1">
<block type="logic_compare" id="$L2GhT0Dc:h5hgx6.h~1">
<field name="OP">GT</field>
<value name="A">
<block type="gamepad_getProperty_Number" id="H%12.A$-T5?Q3Or2-jQp">
<field name="IDENTIFIER">gamepad1</field>
<field name="PROP">LeftTrigger</field>
<data>{"IDENTIFIER":"gamepad1"}</data>
</block>
</value>
<value name="B">
<block type="math_number" id="UFIe*{6zV0y_E9X~SptO">
<field name="NUM">0.2</field>
</block>
</value>
</block>
</value>
<statement name="DO1">
<block type="math_change" id="BS:?Fpjyh~d]#_gEWc2N">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
<value name="DELTA">
<shadow type="math_number" id="pcl7j[|L7QUcmo?)q]Ag">
<field name="NUM">-1</field>
</shadow>
</value>
</block>
</statement>
<next>
<block type="variables_set" id="=GDU-1}9,5SuV{ck$KZe">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
<value name="VALUE">
<block type="math_constrain" id="[R8H}?xwckd@xClQKCh%">
<value name="VALUE">
<shadow type="math_number" id="aemt0lUla,oxLLi)f`_O">
<field name="NUM">50</field>
</shadow>
<block type="variables_get" id="xKn-]8RdzDzS!EqHhd,C">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
</block>
</value>
<value name="LOW">
<shadow type="math_number" id="x3|+5$LRqK6/^BM/tWvM">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="4:YkYX^GtL!~O@AY1Ew~">
<field name="VAR" id="_+s(|?n0/6QSbjXh*V}P">exposureValueMin</field>
</block>
</value>
<value name="HIGH">
<shadow type="math_number" id=".*)}ly@9t/;$3j8iB)S^">
<field name="NUM">100</field>
</shadow>
<block type="variables_get" id=",#48uE_g-MqbIg_/`BVX">
<field name="VAR" id="Z-p[R6(8}7,`}*oU/[#w">exposureValueMax</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="3?iSib-sMzzMnd^r9{nd">
<field name="VAR" id="mcIIY]f9gD8kNPOydZ@6">setExposureReturn</field>
<value name="VALUE">
<block type="exposureControl_setExposure" id="32_HJ8l{0O-j#2*:]V9^">
<comment pinned="false" h="150" w="325">Set the exposure.</comment>
<value name="EXPOSURE_CONTROL">
<block type="variables_get" id="V6Y@g%2D1?3x-sl#5)%3">
<field name="VAR" id="dQp60~)Jk~U;%|U@V?iu">myExposureControl</field>
</block>
</value>
<value name="DURATION">
<shadow type="math_number" id="!ermjL#]vPJ!8sR%8~Nz">
<field name="NUM">30</field>
</shadow>
<block type="variables_get" id="53$s*751HJPuDsJ~nFg%">
<field name="VAR" id="|`#{+60SL-9`I$UFs;dG">exposureValue</field>
</block>
</value>
<value name="TIME_UNIT">
<shadow type="misc_typedEnum_TimeUnit" id="zn(}a#5T,Md#_rt%alOH">
<field name="TIME_UNIT">MILLISECONDS</field>
</shadow>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id=":Un!nS!LS%^tq]:g4^?Z" collapsed="true" x="-158" y="400">
<field name="NAME">initialize TFOD</field>
<comment pinned="false" h="80" w="160">Initialize TensorFlow Object Detection.</comment>
<statement name="STACK">
<block type="comment" id="Z#tr,B$;l$RV0)j4q0n.">
<field name="COMMENT">First, create a TfodProcessor.Builder.</field>
<next>
<block type="tfodProcessorBuilder_create_assign" id="OP55K=7Mnj%#1mm%VP3[">
<field name="TFOD_PROCESSOR_BUILDER" id="nN$Hc]Yea=/(:3{Flx89" variabletype="TfodProcessor.Builder">myTfodProcessorBuilder</field>
<next>
<block type="comment" id="548kw:o%J6n~KZ`p~%]1">
<field name="COMMENT">Create a TfodProcessor by calling build.</field>
<next>
<block type="variables_set" id="*k]OTXL@EV{9sDiFVu)u">
<field name="VAR" id="2(2G$#dr!gUmh_~QL5ZA">myTfodProcessor</field>
<value name="VALUE">
<block type="tfodProcessorBuilder_build" id="kI8I`TUYX%.qVtsEsTt0">
<field name="TFOD_PROCESSOR_BUILDER" id="nN$Hc]Yea=/(:3{Flx89" variabletype="TfodProcessor.Builder">myTfodProcessorBuilder</field>
</block>
</value>
<next>
<block type="comment" id="w{nzs#L5ZbP.GKW2S`x_">
<field name="COMMENT">Next, create a VisionPortal.Builder and set attributes related to the camera.</field>
<next>
<block type="visionPortalBuilder_create_assign" id="s1^/ZS*LG[dC%CsYcl=%">
<field name="VISION_PORTAL_BUILDER" id="wx@xgbnS_]b0DQL.08Qg" variabletype="VisionPortal.Builder">myVisionPortalBuilder</field>
<next>
<block type="visionPortalBuilder_setCamera" id="h;`Yd}]R=F.Fw89p`1N/">
<field name="VISION_PORTAL_BUILDER" id="wx@xgbnS_]b0DQL.08Qg" variabletype="VisionPortal.Builder">myVisionPortalBuilder</field>
<comment pinned="false" h="81" w="183">Camera Controls operate on webcams only, not built-in phone cameras.</comment>
<value name="CAMERA">
<shadow type="navigation_webcamName" id="b`AjugjMrzm855@U*q;W">
<field name="WEBCAM_NAME">Webcam 1</field>
</shadow>
</value>
<next>
<block type="comment" id="-QJd~|I/HUP84GR.F=0N">
<field name="COMMENT">Add myTfodProcessor to the VisionPortal.Builder.</field>
<next>
<block type="visionPortalBuilder_addProcessor" id="`A$k?7nl@kd=7y*v@/+-">
<field name="VISION_PORTAL_BUILDER" id="wx@xgbnS_]b0DQL.08Qg" variabletype="VisionPortal.Builder">myVisionPortalBuilder</field>
<value name="VISION_PROCESSOR">
<block type="variables_get" id="KuIL0Tw$FCF,+=+Lq3gD">
<field name="VAR" id="2(2G$#dr!gUmh_~QL5ZA">myTfodProcessor</field>
</block>
</value>
<next>
<block type="comment" id="6Q2EYFS^A(u/rVLX*nI}">
<field name="COMMENT">Create a VisionPortal by calling build.</field>
<next>
<block type="variables_set" id="UggZXj@UuhBf97)(oA;m">
<field name="VAR" id="Xk!_{IPng0#/P|7dx?3N">myVisionPortal</field>
<value name="VALUE">
<block type="visionPortalBuilder_build" id="OBOV:tKH!^AaYsI{A$~x">
<field name="VISION_PORTAL_BUILDER" id="wx@xgbnS_]b0DQL.08Qg" variabletype="VisionPortal.Builder">myVisionPortalBuilder</field>
</block>
</value>
<next>
<block type="comment" id="MTa-%NW,-{@SQswp2:P?">
<field name="COMMENT">Enable the TFOD Processor.</field>
<next>
<block type="visionPortal_setProcessorEnabled" id="et(Tc@QyMzLxEYv_)7)=">
<comment pinned="false" h="78" w="260">Enable TFOD here so the detections are visible in the Camera Stream preview window on the Driver Station.</comment>
<value name="VISION_PORTAL">
<block type="variables_get" id="xM^-`i)T%uJPS=gBdS)v">
<field name="VAR" id="Xk!_{IPng0#/P|7dx?3N">myVisionPortal</field>
</block>
</value>
<value name="VISION_PROCESSOR">
<block type="variables_get" id="]D4a%r?4m9m2Gu`of#)W">
<field name="VAR" id="2(2G$#dr!gUmh_~QL5ZA">myTfodProcessor</field>
</block>
</value>
<value name="ENABLED">
<shadow type="logic_boolean" id="z/4{h}NhJ]3y*9uRDjKR">
<field name="BOOL">TRUE</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id=",asICY)bA_$8,1Q^?acl" collapsed="true" x="473" y="403">
<field name="NAME">standard INIT telemetry</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="telemetry_addTextData_All" id="Y/b(p3p_Ls7l_.)bQt%8">
<value name="KEY">
<shadow type="text" id="]K/@Q[7z:EBSoy.ggFCo">
<field name="TEXT">DS preview on/off</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="eV-62@bA|1V9{)n7lim2">
<field name="TEXT">3 dots, Camera Stream</field>
</shadow>
</value>
<next>
<block type="telemetry_addTextData_All" id="/Zm[n8^)(`(S}Ab9j!;|">
<value name="KEY">
<shadow type="text" id="E)4aB(Zb2,Da/0v0AiN=">
<field name="TEXT">&gt;</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="^u5_oh+s(.Vs1Kk;$yw9">
<field name="TEXT">Touch Play to start OpMode</field>
</shadow>
</value>
<next>
<block type="telemetry_addLine" id="#AykF1-A]^*FDZyD$Y1{">
<value name="TEXT">
<shadow type="text" id=",+`(!H=uXDF0.F.])AP9">
<field name="TEXT"/>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="/s7LjfD#rDF}9WK/VZch" collapsed="true" x="979" y="403">
<field name="NAME">telemetry of TFOD recognitions</field>
<comment pinned="false" h="80" w="160">Display info (using telemetry) for a detected object</comment>
<statement name="STACK">
<block type="variables_set" id="c8~R@@~J_)0dhTTP,GP@">
<field name="VAR" id="OlJB[R?bruF2C6T]y:j,">myTfodRecognitions</field>
<comment pinned="false" h="80" w="160">Get a list of recognitions from TFOD.</comment>
<value name="VALUE">
<block type="tfodProcessor_getLatestRecognitions" id="m%oMSElt[4!Yf)zPY(G=">
<value name="TFOD_PROCESSOR">
<block type="variables_get" id="9wqUsyPBEDPL!nRF+kLN">
<field name="VAR" id="2(2G$#dr!gUmh_~QL5ZA">myTfodProcessor</field>
</block>
</value>
</block>
</value>
<next>
<block type="telemetry_addTextData_All" id="3m5}jTks8BeMJ]|.h*Kp">
<value name="KEY">
<shadow type="text" id="MNA3Pe{~9.uc1dSMmO=j">
<field name="TEXT"># Objects Detected</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="DRWu-r*O-0eJ4pG2n$_l">
<field name="TEXT"/>
</shadow>
<block type="lists_length" id="q{bEB[P*p2XiVOMj*ku#">
<value name="VALUE">
<block type="variables_get" id="/5v#48C2W5M+l:4)g!zX">
<field name="VAR" id="OlJB[R?bruF2C6T]y:j,">myTfodRecognitions</field>
</block>
</value>
</block>
</value>
<next>
<block type="controls_forEach" id="|@Y$y8D~],V(MRQ+Cyv{">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
<comment pinned="false" h="81" w="199">Iterate through list and call a function to display info for each recognized object.</comment>
<value name="LIST">
<block type="variables_get" id="W,d1s!eFWeDT0X}~eq,n">
<field name="VAR" id="OlJB[R?bruF2C6T]y:j,">myTfodRecognitions</field>
</block>
</value>
<statement name="DO">
<block type="comment" id="U@Dkpel-LMa.00jJsqA-">
<field name="COMMENT">Display info about the recognition.</field>
<next>
<block type="telemetry_addLine" id="`7iZg86yqzf}E:v}Jh@D">
<value name="TEXT">
<shadow type="text" id="5IsZU#RzJNY)o5$1[7Wn">
<field name="TEXT"/>
</shadow>
</value>
<next>
<block type="comment" id="tlc0F80BdB`b([Xp;XEc">
<field name="COMMENT">Display label and confidence.</field>
<next>
<block type="telemetry_addTextData_All" id=";6SFb8haRI5qo45n}iJ8">
<comment pinned="false" h="80" w="160">Display the label and confidence for the recognition.</comment>
<value name="KEY">
<shadow type="text" id="_dKJensTqN?qDeXC6vm|">
<field name="TEXT">Image</field>
</shadow>
</value>
<value name="TEXT">
<shadow type="text" id="#+^2[kj(=_-pPWHzSDN^">
<field name="TEXT">text</field>
</shadow>
<block type="text_join" id="%Z8N#7U!NO[^?MZd~8tp">
<mutation items="4"/>
<value name="ADD0">
<block type="tfodRecognition_getProperty_String" id="d7@$bcm+3wluc1@Wtq|u">
<field name="PROP">Label</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="}u)$1QfMPe1)p,Qs5Ku;">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="ADD1">
<block type="text" id="hA{TP4y0BeN~b}s?-COU">
<field name="TEXT"> (</field>
</block>
</value>
<value name="ADD2">
<block type="misc_formatNumber" id="W.:=!sbgnUq29]l%U@X,">
<value name="NUMBER">
<shadow type="math_number" id="s0SW(u(_U_AiC]RDGAM}">
<field name="NUM">3.14159265</field>
</shadow>
<block type="math_arithmetic" id="QPn7xN.bb^5UFF3{wc:=">
<field name="OP">MULTIPLY</field>
<value name="A">
<shadow type="math_number" id="3x=;@]B}?wD~GAG,D^Jt">
<field name="NUM">1</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="Ap}Xk?:^Np+gC01Vh61Z">
<field name="PROP">Confidence</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="CYsYZ30]JD*A%GRzMCMp">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id="n#$#(wn9a]/ut+7OX@dg">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="hKOX#ZdO}0q$?o;9]0^v">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
<value name="ADD3">
<block type="text" id="oCx~}ujI~f;Jo|sBkHDT">
<field name="TEXT"> % Conf.)</field>
</block>
</value>
</block>
</value>
<next>
<block type="comment" id="_98!oDhsOCBdhLYUP4uf">
<field name="COMMENT">Display position.</field>
<next>
<block type="variables_set" id="tkoR8MqhJB|mii==HBXx">
<field name="VAR" id="h_4q]^+cuMwY?7E#7$Pc">x</field>
<value name="VALUE">
<block type="math_arithmetic" id="9tcFbr^OD)(ieS^R(%{)" inline="false">
<field name="OP">DIVIDE</field>
<value name="A">
<shadow type="math_number" id="Qem;o3zyOo/TB?UYgNr.">
<field name="NUM">1</field>
</shadow>
<block type="math_arithmetic" id="!sK0EY,5R7e}ONTT$AG5">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="5k:P$((E2+D=.O4{A00w">
<field name="NUM">1</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="VeL$%e^~N33.uZUiGhUK">
<field name="PROP">Left</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="89kTVFyI498d3Mlqk$Do">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id="/peuJ)ZNE[JkyOvs4LA4">
<field name="NUM">1</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="ZD([Z9OSab:l*|ZfMWZA">
<field name="PROP">Right</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="#H/|b#/i9aq2n(;9[6$i">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id="HUmc2^ax~%i~|SZfD!Kr">
<field name="NUM">2</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="qcXVM!KstPoMrw:q18Fp">
<field name="VAR" id="R{3+3{j6;,uRMizwTeH6">y</field>
<value name="VALUE">
<block type="math_arithmetic" id="usxV`d|lwAAg(rR`hoJJ" inline="false">
<field name="OP">DIVIDE</field>
<value name="A">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="math_arithmetic" id="y)1NUwKRmeSRDnPx31tA">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="{Y!B`riuVrgTI~B@*v~-">
<field name="PROP">Top</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="!pM%(0tvuGmPt8On73HP">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="gME}{7MPcASBr3H2sFD%">
<field name="PROP">Bottom</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="Ll+R_yoUkk*u]q8|9]1d">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id="${Ys[4)NtlVmlf,Z.;}[">
<field name="NUM">2</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="telemetry_addTextData_All" id="8nKd8v-zW;`u5BOb+C%9">
<comment pinned="false" h="100" w="200">Display the position of the center of the detection boundary for the recognition</comment>
<value name="KEY">
<shadow type="text" id="_dKJensTqN?qDeXC6vm|">
<field name="TEXT">key</field>
</shadow>
<block type="text" id="}g`_FiJaZ]3s$^FeZvgx">
<field name="TEXT">- Position</field>
</block>
</value>
<value name="TEXT">
<shadow type="text" id="#+^2[kj(=_-pPWHzSDN^">
<field name="TEXT">text</field>
</shadow>
<block type="text_join" id="DT/!lFr4vq[1YesUPQ_T">
<mutation items="3"/>
<value name="ADD0">
<block type="misc_formatNumber" id="[3@]m1vvw_m4v9{ed!@E">
<value name="NUMBER">
<shadow type="math_number" id="JDE#f3wD%{i_3HX0)mD:">
<field name="NUM">3.14159265</field>
</shadow>
<block type="variables_get" id="PWU+5f]nI6MV`20z_SD:">
<field name="VAR" id="h_4q]^+cuMwY?7E#7$Pc">x</field>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id=",)w^tP$rbhT?BIWQ:E_2">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
<value name="ADD1">
<block type="text" id="ZhFl#/Fk+I)t}s)TnQ_?">
<field name="TEXT">, </field>
</block>
</value>
<value name="ADD2">
<block type="misc_formatNumber" id="C,GVWvk]6xkx||Jt|!#t">
<value name="NUMBER">
<shadow type="math_number" id="`-4k?jGvmE}lx5(o6{9Q">
<field name="NUM">3.14159265</field>
</shadow>
<block type="variables_get" id="FK.8rCC8#Zwx]$t50PtJ">
<field name="VAR" id="R{3+3{j6;,uRMizwTeH6">y</field>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="eL+n:x65[BH]goM$ioOf">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="comment" id="~bRVN`9q9$vf6w0BSW@}">
<field name="COMMENT">Display size</field>
<next>
<block type="telemetry_addTextData_All" id="Q+UdE@m8P2B.yiwA.w%$">
<comment pinned="false" h="100" w="200">Display the size of detection boundary for the recognition</comment>
<value name="KEY">
<shadow type="text" id="_dKJensTqN?qDeXC6vm|">
<field name="TEXT">key</field>
</shadow>
<block type="text" id="c7F~1],4bXjo0h].?:7C">
<field name="TEXT">- Size</field>
</block>
</value>
<value name="TEXT">
<shadow type="text" id="#+^2[kj(=_-pPWHzSDN^">
<field name="TEXT">text</field>
</shadow>
<block type="text_join" id="o8Gtc?kcbG~`#vx!7ck^">
<mutation items="3"/>
<value name="ADD0">
<block type="misc_formatNumber" id="5AXz%qG~uB4rRHJy-?d!">
<value name="NUMBER">
<shadow type="math_number" id="#4u/hnTWMps|sDKAC9G1">
<field name="NUM">3.14159265</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="F%|Lo.;yf5Od/%EqOuf)">
<field name="PROP">Width</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="TA34*WE*L([F@%Yk_x*4">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id=".)=2[zYgs$ngVPyIh)EY">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
<value name="ADD1">
<block type="text" id="okN|sYW[pdiqWcyAv-66">
<field name="TEXT"> x </field>
</block>
</value>
<value name="ADD2">
<block type="misc_formatNumber" id="ERN(+zfvvG=u03A%,{g6">
<value name="NUMBER">
<shadow type="math_number" id="l^$CWPamTtu$iSgKXrc!">
<field name="NUM">3.14159265</field>
</shadow>
<block type="tfodRecognition_getProperty_Number" id="B-6W%AK(jO!ur3t$S!h@">
<field name="PROP">Height</field>
<value name="TFOD_RECOGNITION">
<block type="variables_get" id="I%pBUv`--i6Yr0iXNPT4">
<field name="VAR" id="vP~n9zf$lW%hYD/C.j_-">myTfodRecognition</field>
</block>
</value>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="/p,#N0JOWsst^5Z!{+.)">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<Extra>
<OpModeMeta flavor="TELEOP" group="" autoTransition="" />
<Enabled value="true" />
</Extra>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment