-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathW_Telemetry_myBlocks_v02.blk
410 lines (407 loc) · 13.2 KB
/
W_Telemetry_myBlocks_v02.blk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="4MpF+DyAlYQ`$}qStL},">telemetryInterval</variable>
<variable id="y@zkYnO1.Q8K3%EPG:xb">loopTimeLimit</variable>
<variable id="teDKfqc:fx*l=hl4:,!9">myLoopTimer</variable>
<variable id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</variable>
<variable id="i|@FSnc^kOFgrwvc9ukY">numberOfCycles</variable>
<variable id="Q;,4B$yNq-mRouOV_5%#">msPerCycle</variable>
</variables>
<block type="procedures_defnoreturn" id="WtpyD@tEu+EoY=P9iY,D" deletable="false" editable="false" x="-169" y="-5">
<field name="NAME">runOpMode</field>
<comment pinned="false" h="32" w="532">This function is executed when this Op Mode is selected from the Driver Station.</comment>
<statement name="STACK">
<block type="comment" id="Lc#BFtj*NTB48YL;eBl.">
<field name="COMMENT"><<=== CICK THE QUESTION MARK FOR INFO.</field>
<comment pinned="false" h="318" w="316">This OpMode verifies if the "setTelemetryRate" myBlock actually works.
The default FTC refresh rate is 4 cycles per second, or 250 ms time interval. Try 500 ms, then other values. For each value, run the OpMode a few times.
The testing loop contains a myBlock called telemetryAction that returns the number 1 only if the current Telemetry interval has elapsed. Otherwise it returns 0.
No gamepad or special configuration are needed.</comment>
<next>
<block type="variables_set" id="$9%9yvl:-{h(8CUQO*E3">
<field name="VAR" id="4MpF+DyAlYQ`$}qStL},">telemetryInterval</field>
<value name="VALUE">
<block type="math_number" id="wOu!O{St:8fM$vIv(`J|">
<field name="NUM">500</field>
</block>
</value>
<next>
<block type="variables_set" id="YuPyuhEqFBc;M1JKt$DB">
<field name="VAR" id="teDKfqc:fx*l=hl4:,!9">myLoopTimer</field>
<value name="VALUE">
<block type="elapsedTime2_create" id="{h-sC{3:`=Wd[|,5Byt5"/>
</value>
<next>
<block type="variables_set" id="e1ob^--wVVJ*[]W!*8_`">
<field name="VAR" id="y@zkYnO1.Q8K3%EPG:xb">loopTimeLimit</field>
<value name="VALUE">
<block type="math_number" id="$/o~)U4zs~l%=CW,0oDD">
<field name="NUM">5</field>
</block>
</value>
<next>
<block type="variables_set" id="7f{/f8qxTSeeQK7-1083">
<field name="VAR" id="i|@FSnc^kOFgrwvc9ukY">numberOfCycles</field>
<value name="VALUE">
<block type="math_number" id="`$M=,`(bT*]XdVHWH@_I">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="comment" id="{Ui1FH4b|x2;gx4tzp%W">
<field name="COMMENT">Does the following myBlock actually work?</field>
<next>
<block type="misc_callJava_noReturn" id="%@{[d$g3PsYk$s(0RrFp">
<mutation methodLookupString="org.firstinspires.ftc.teamcode.W_myBlocks_Telemetry_v02 setTelemetryRate(int) void" parameterCount="1" returnType="void" comment="Sets Telemetry refresh rate or interval, which resets to default 250 ms every time OpMode runs. Optional: add pause in Blocks to view confirming message." tooltip="Set Telemetry refresh interval" accessMethod="callJava" convertReturnValue="" argLabel0="Refresh interval (milliseconds)" argType0="int" argAuto0=""/>
<field name="CLASS_NAME">W_myBlocks_Telemetry_v02</field>
<field name="METHOD_NAME">setTelemetryRate</field>
<comment pinned="false" h="141" w="261">Sets Telemetry refresh rate or interval, which resets to default 250 ms every time OpMode runs. Optional: add pause in Blocks to view confirming message.</comment>
<value name="ARG0">
<shadow type="math_number" id="F})F*pY*$I(]SHm566m%">
<field name="NUM">0</field>
</shadow>
<block type="variables_get" id="(qQ/PHIy$KC)0ng`ZB9I">
<field name="VAR" id="4MpF+DyAlYQ`$}qStL},">telemetryInterval</field>
</block>
</value>
<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="comment" id="^8*VGYbry?uc|lQ,P6G%">
<field name="COMMENT">Start a new Telemetry cycle with .update</field>
<next>
<block type="telemetry_update" id=";Pmg_J2XG97K;^c,]?a!">
<next>
<block type="comment" id="iwIuGS=![RUR;7HkmEbn">
<field name="COMMENT">Reset the loop timer and its variable.</field>
<next>
<block type="variables_set" id="L;n`)YP]91!P^)t0RRwq">
<field name="VAR" id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</field>
<value name="VALUE">
<block type="math_number" id="S4G0sM_8HY^nA]}I/g$U">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="elapsedTime2_reset" id="^H[,63BkeHbMEoZwoBIa">
<value name="ELAPSED_TIME">
<block type="variables_get" id="x+RYf^.$%Vv0]z:}Gx~A">
<field name="VAR" id="teDKfqc:fx*l=hl4:,!9">myLoopTimer</field>
</block>
</value>
<next>
<block type="comment" id="Apt5XQ/}cz?+wZZWEfWU">
<field name="COMMENT">Loop for the specified time duration.</field>
<next>
<block type="comment" id="eFeQENle]fX8n{,O04JO">
<field name="COMMENT">This loop tries to update Telemetry very fast,</field>
<next>
<block type="comment" id="ba;g~/gv#q{HqB(!$E9_">
<field name="COMMENT">but is limited by the maximum refresh rate.</field>
<next>
<block type="controls_whileUntil" id="*7QCM~Of@sx-uJb%ho=5">
<field name="MODE">WHILE</field>
<value name="BOOL">
<block type="logic_operation" id="3MANc#E|j#S%f^9VFkHR" inline="false">
<field name="OP">AND</field>
<value name="A">
<block type="logic_compare" id="3-%SoV:~t9FG-`M0.1Zn">
<field name="OP">LTE</field>
<value name="A">
<block type="variables_get" id="Rq5p}#n8r=^/cf:jVIlB">
<field name="VAR" id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="uKu5Vun3_8bg1i.9RdVC">
<field name="VAR" id="y@zkYnO1.Q8K3%EPG:xb">loopTimeLimit</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="linearOpMode_opModeIsActive" id="~khAbGc.WtLV:!r*I!ts"/>
</value>
</block>
</value>
<statement name="DO">
<block type="comment" id="YwUChAMsWLE:u|2J]rF@">
<field name="COMMENT">This myBlock returns 1, only if Telemetry interval</field>
<next>
<block type="comment" id="+*i;ml[#E=g6TA{Tg*bw">
<field name="COMMENT">has elapsed. If so, increment the cycles counter.</field>
<next>
<block type="math_change" id="K?MX/vX)W!?{i:/i}6,]">
<field name="VAR" id="i|@FSnc^kOFgrwvc9ukY">numberOfCycles</field>
<value name="DELTA">
<shadow type="math_number" id="^RbPy,;Q(f79B}TfWGNp">
<field name="NUM">1</field>
</shadow>
<block type="misc_callJava_return" id="9^FqT2mM|.+iZA]I*3tD">
<mutation methodLookupString="org.firstinspires.ftc.teamcode.W_myBlocks_Telemetry_v02 telemetryAction() int" parameterCount="0" returnType="int" comment="At each scheduled Telemetry update, return value 1 to increment counter. Otherwise return 0." tooltip="Action before Telemetry update" accessMethod="callJava_String" convertReturnValue="Number"/>
<field name="CLASS_NAME">W_myBlocks_Telemetry_v02</field>
<field name="METHOD_NAME">telemetryAction</field>
<comment pinned="false" h="129.33334350585938" w="155.9998779296875">At each scheduled Telemetry update, return value 1 to increment counter. Otherwise return 0.</comment>
</block>
</value>
<next>
<block type="variables_set" id="=tYr-.%OO.$$uSii9qs8">
<field name="VAR" id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</field>
<value name="VALUE">
<block type="elapsedTime2_getProperty_Number" id="NY-mHOsbFFahi[wJ@$Qa">
<field name="PROP">Time</field>
<value name="ELAPSED_TIME">
<block type="variables_get" id="VF+Fx46%h%8;Br+!i[=w">
<field name="VAR" id="teDKfqc:fx*l=hl4:,!9">myLoopTimer</field>
</block>
</value>
</block>
</value>
<next>
<block type="procedures_callnoreturn" id="o~b7!^`?=`bO[x7yVwx}">
<mutation name="BuildStatusMessage"/>
<next>
<block type="telemetry_update" id="E+862$gp~P[)|a2@F[BH"/>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
<next>
<block type="procedures_callnoreturn" id="x)JS}!E]Q=Q,Xpxe=Mm@">
<mutation name="BuildStatusMessage"/>
<next>
<block type="comment" id=",p+@EA~*grVP35s(M`D{">
<field name="COMMENT">Calculate average time (ms) per Telemetry cycle.</field>
<next>
<block type="variables_set" id="p](i0iZ2vHSU~vt#CG3_">
<field name="VAR" id="Q;,4B$yNq-mRouOV_5%#">msPerCycle</field>
<value name="VALUE">
<block type="math_arithmetic" id="HdnZ]n2=BoJ!Lz+.FAK)">
<field name="OP">MULTIPLY</field>
<value name="A">
<shadow type="math_number" id="e*DRiFW$J=hnv%3j/66{">
<field name="NUM">1</field>
</shadow>
<block type="math_arithmetic" id="vn[}DvW1ISdjyNl]7FXG">
<field name="OP">DIVIDE</field>
<value name="A">
<shadow type="math_number" id="+)Nk|)o(HYO`=1VA4r1#">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="A4w#M1yv]Scu@ky{Sbg`">
<field name="VAR" id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="Q5`YF6og]y%v3nvZ`[BN">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="jNuKijj4!ug_;P*RfY9_">
<field name="VAR" id="i|@FSnc^kOFgrwvc9ukY">numberOfCycles</field>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id="~TSi6r%O4@U0Ft!hh|q4">
<field name="NUM">1000</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="comment" id="Y~K,!j@YoJnSNnZkPIf9">
<field name="COMMENT">Add result to the final status message.</field>
<next>
<block type="telemetry_addNumericData_Number" id="[[gOfAE)_hY:.5WMip@_">
<value name="KEY">
<shadow type="text" id="MI~Tq}zH8GEi@YPhZRN}">
<field name="TEXT">Refresh interval, calculated (ms)</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number" id="=#UtLg4sMg{tyYD6|LI5">
<field name="NUM">123</field>
</shadow>
<block type="misc_roundDecimal" id="Q))_|sWsUc]b;qO/ka6C">
<value name="NUMBER">
<shadow type="math_number" id="uvQ+t*Wuh0|*^e]ohGfK">
<field name="NUM">3.14159265</field>
</shadow>
<block type="variables_get" id="Ko-nK9nZVdu/j(Ix;V19">
<field name="VAR" id="Q;,4B$yNq-mRouOV_5%#">msPerCycle</field>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="M:dr9{@gxM98oWToz{hw">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="telemetry_update" id="FJegbvq.Xgr124{#fND_">
<next>
<block type="controls_whileUntil" id="nDch@{/MvA+;*/h;N.=e">
<field name="MODE">WHILE</field>
<value name="BOOL">
<block type="linearOpMode_opModeIsActive" id="~li?uAI1ZffZtx)jL7i#"/>
</value>
<statement name="DO">
<block type="comment" id="bpA/kZ/w^(u~4W5qaYBe">
<field name="COMMENT">"Empty loop" to study the final status message.</field>
</block>
</statement>
</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>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="l8@BKf,s3#}^%OUF9t2h" x="619" y="247">
<field name="NAME">BuildStatusMessage</field>
<comment pinned="false" h="80" w="160">Build a message with status of Telemetry testing.</comment>
<statement name="STACK">
<block type="telemetry_addNumericData_Number" id="E7h!5x1ZRz=_k[|CV5Sk">
<value name="KEY">
<shadow type="text" id="tt]{P)UlW_O[tJNA~y`.">
<field name="TEXT">Loop time limit</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">123</field>
</shadow>
<block type="variables_get" id="KC![({zNl(r]}IL1{fIg">
<field name="VAR" id="y@zkYnO1.Q8K3%EPG:xb">loopTimeLimit</field>
</block>
</value>
<next>
<block type="telemetry_addNumericData_Number" id="#VC5;@+`Rv,cT5,i{h`l">
<value name="KEY">
<shadow type="text" id="B7UejLX=O!DnW$?8AVN*">
<field name="TEXT">Elapsed time in loop</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number">
<field name="NUM">123</field>
</shadow>
<block type="misc_roundDecimal" id="1a07`;i)g].ADTQQgdM%">
<value name="NUMBER">
<shadow type="math_number" id=".-uQ;o_mR37?L|!:$];X">
<field name="NUM">3.14159265</field>
</shadow>
<block type="variables_get" id="GI*4,UkB{Q!WR1,HA`g@">
<field name="VAR" id=":Z:_07x4([m8RpGOH(Ty">elapsedLoopTime</field>
</block>
</value>
<value name="PRECISION">
<shadow type="math_number" id="!D1B6*zIGg0$rPw=WV9Z">
<field name="NUM">2</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="telemetry_addNumericData_Number" id="-0k5t3fPn8ngDvZC)i;X">
<value name="KEY">
<shadow type="text" id=")A6U_U,*BwA|0$8E@;ep">
<field name="TEXT">Refresh interval, programmed (ms)</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number" id="BuHF4;z]($r3fy$?G:6(">
<field name="NUM">123</field>
</shadow>
<block type="variables_get" id="axP^?sTsK;U736O=n+x@">
<field name="VAR" id="4MpF+DyAlYQ`$}qStL},">telemetryInterval</field>
</block>
</value>
<next>
<block type="telemetry_addNumericData_Number" id="gedZ3/?JPNc]nz1BM^M@">
<value name="KEY">
<shadow type="text" id=":CWTk?N$hhlz#*w[wTT5">
<field name="TEXT">Number of cycles</field>
</shadow>
</value>
<value name="NUMBER">
<shadow type="math_number" id="G.lzlDBzD]V(501F2ACP">
<field name="NUM">123</field>
</shadow>
<block type="variables_get" id="K6T;H7kwTh#b^m:+g?+g">
<field name="VAR" id="i|@FSnc^kOFgrwvc9ukY">numberOfCycles</field>
</block>
</value>
</block>
</next>
</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>