capellaresumo 6 years ago
parent
commit
6eb5835a61

+ 2 - 1
.gitignore

@@ -1,2 +1,3 @@
 __pycache__
-__pycache__/
+__pycache__/
+player-potential.py

+ 4 - 2
cmarkers.py

@@ -105,8 +105,8 @@ def getCMarkers (img):
 
                     number = getNumber(code, 160)
                     if number == False:
-                        # cv2.imshow("m2", code)
                         continue
+                    # cv2.imshow("m2", code)
 
 
                     uu = np.array([0, 1])
@@ -130,7 +130,9 @@ def getNumber(img, threshold):
             m.append(np.mean(hs))
         mean.append(m)
     # print(np.array(mean).astype(np.uint8))
-    #####print(mean)
+    # print((mean[0][0]+mean[3][3])/2.0)
+    threshold = (mean[0][0]+mean[3][3])/2.0*0.85
+    print(threshold)
     mean = np.array(mean) >= threshold
     valid = mean[0, 0] == False
     valid = valid and mean[0, 3] == False

BIN
enunciado/3.png


+ 15 - 0
enunciado/enunciado.aux

@@ -0,0 +1,15 @@
+\relax 
+\catcode `"\active 
+\select@language{portuguese}
+\@writefile{toc}{\select@language{portuguese}}
+\@writefile{lof}{\select@language{portuguese}}
+\@writefile{lot}{\select@language{portuguese}}
+\@writefile{toc}{\contentsline {section}{\numberline {1}Objetivo}{1}}
+\@writefile{toc}{\contentsline {section}{\numberline {2}Regras}{1}}
+\@writefile{toc}{\contentsline {section}{\numberline {3}Funcionamento}{1}}
+\@writefile{toc}{\contentsline {section}{\numberline {4}Penalidades}{1}}
+\@writefile{toc}{\contentsline {section}{\numberline {5}Complica\IeC {\c c}\IeC {\~o}es}{2}}
+\@writefile{toc}{\contentsline {section}{\numberline {6}Utilizando o servidor}{2}}
+\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Note que a posi\IeC {\c c}\IeC {\~a}o do marcador determina a orienta\IeC {\c c}\IeC {\~a}o do rob\IeC {\^o}. No marcador acima o rob\IeC {\^o} est\IeC {\'a} orientado para cima.}}{3}}
+\@writefile{toc}{\contentsline {section}{\numberline {7}Simula\IeC {\c c}\IeC {\~a}o}{3}}
+\@writefile{toc}{\contentsline {section}{\numberline {8}Tarefas}{4}}

+ 536 - 0
enunciado/enunciado.log

@@ -0,0 +1,536 @@
+This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex 2015.11.12)  13 JUN 2018 10:54
+entering extended mode
+ restricted \write18 enabled.
+ %&-line parsing enabled.
+**enunciado.tex
+(./enunciado.tex
+LaTeX2e <2015/01/01>
+Babel <3.9l> and hyphenation patterns for 79 languages loaded.
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrartcl.cls
+Document Class: scrartcl 2015/05/06 v3.17a KOMA-Script document class (article)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrkbase.sty
+Package: scrkbase 2015/05/06 v3.17a KOMA-Script package (KOMA-Script-dependent 
+basics and keyval usage)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrbase.sty
+Package: scrbase 2015/05/06 v3.17a KOMA-Script package (KOMA-Script-independent
+ basics and keyval usage)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty
+Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
+\KV@toks@=\toks14
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrlfile.sty
+Package: scrlfile 2015/05/06 v3.17a KOMA-Script package (loading files)
+
+Package scrlfile, 2015/05/06 v3.17a KOMA-Script package (loading files)
+                  Copyright (C) Markus Kohm
+
+))) (/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/tocbasic.sty
+Package: tocbasic 2015/05/06 v3.17a KOMA-Script package (handling toc-files)
+)
+Package tocbasic Info: omitting babel extension for `toc'
+(tocbasic)             because of feature `nobabel' available
+(tocbasic)             for `toc' on input line 122.
+Package tocbasic Info: omitting babel extension for `lof'
+(tocbasic)             because of feature `nobabel' available
+(tocbasic)             for `lof' on input line 123.
+Package tocbasic Info: omitting babel extension for `lot'
+(tocbasic)             because of feature `nobabel' available
+(tocbasic)             for `lot' on input line 124.
+Package scrartcl Info: You've used standard option `11pt'.
+(scrartcl)             This is correct!
+(scrartcl)             Internally I'm using `fontsize=11pt'.
+(scrartcl)             If you'd like to set the option with \KOMAoptions,
+(scrartcl)             you'd have to use `fontsize=11pt' there
+(scrartcl)             instead of `11pt', too.
+Class scrartcl Info: File `scrsize11pt.clo' used to setup font sizes on input l
+ine 1942.
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrsize11pt.clo
+File: scrsize11pt.clo 2015/05/06 v3.17a KOMA-Script font size class option (11p
+t)
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/typearea.sty
+Package: typearea 2015/05/06 v3.17a KOMA-Script package (type area)
+
+Package typearea, 2015/05/06 v3.17a KOMA-Script package (type area)
+                  Copyright (C) Frank Neukam, 1992-1994
+                  Copyright (C) Markus Kohm, 1994-
+
+\ta@bcor=\skip41
+\ta@div=\count79
+Package typearea Info: You've used standard option `a4paper'.
+(typearea)             This is correct!
+(typearea)             Internally I'm using `paper=a4'.
+(typearea)             If you'd like to set the option with \KOMAoptions,
+(typearea)             you'd have to use `paper=a4' there
+(typearea)             instead of `a4paper', too.
+\ta@hblk=\skip42
+\ta@vblk=\skip43
+\ta@temp=\skip44
+\footheight=\skip45
+Package typearea Info: These are the values describing the layout:
+(typearea)             DIV  = 10
+(typearea)             BCOR = 0.0pt
+(typearea)             \paperwidth      = 597.50793pt
+(typearea)              \textwidth      = 418.25555pt
+(typearea)              DIV departure   = -6%
+(typearea)              \evensidemargin = 17.3562pt
+(typearea)              \oddsidemargin  = 17.3562pt
+(typearea)             \paperheight     = 845.04694pt
+(typearea)              \textheight     = 595.80026pt
+(typearea)              \topmargin      = -25.16531pt
+(typearea)              \headheight     = 17.0pt
+(typearea)              \headsep        = 20.40001pt
+(typearea)              \topskip        = 11.0pt
+(typearea)              \footskip       = 47.6pt
+(typearea)              \baselineskip   = 13.6pt
+(typearea)              on input line 1485.
+)
+\c@part=\count80
+\c@section=\count81
+\c@subsection=\count82
+\c@subsubsection=\count83
+\c@paragraph=\count84
+\c@subparagraph=\count85
+LaTeX Info: Redefining \textsubscript on input line 3718.
+\abovecaptionskip=\skip46
+\belowcaptionskip=\skip47
+\c@pti@nb@sid@b@x=\box26
+\c@figure=\count86
+\c@table=\count87
+\bibindent=\dimen102
+) (/usr/local/texlive/2015/texmf-dist/tex/latex/tools/tabularx.sty
+Package: tabularx 2014/10/28 v2.10 `tabularx' package (DPC)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/array.sty
+Package: array 2014/10/28 v2.4c Tabular extension package (FMi)
+\col@sep=\dimen103
+\extrarowheight=\dimen104
+\NC@list=\toks15
+\extratabsurround=\skip48
+\backup@length=\skip49
+)
+\TX@col@width=\dimen105
+\TX@old@table=\dimen106
+\TX@old@col=\dimen107
+\TX@target=\dimen108
+\TX@delta=\dimen109
+\TX@cols=\count88
+\TX@ftn=\toks16
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty
+Package: inputenc 2015/03/17 v1.2c Input encoding file
+\inpenc@prehook=\toks17
+\inpenc@posthook=\toks18
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def
+File: utf8.def 2014/09/29 v1.1m UTF-8 support for inputenc
+Now handling font encoding OML ...
+... no UTF-8 mapping file for font encoding OML
+Now handling font encoding T1 ...
+... processing UTF-8 mapping file for font encoding T1
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu
+File: t1enc.dfu 2014/09/29 v1.1m UTF-8 support for inputenc
+   defining Unicode char U+00A1 (decimal 161)
+   defining Unicode char U+00A3 (decimal 163)
+   defining Unicode char U+00AB (decimal 171)
+   defining Unicode char U+00BB (decimal 187)
+   defining Unicode char U+00BF (decimal 191)
+   defining Unicode char U+00C0 (decimal 192)
+   defining Unicode char U+00C1 (decimal 193)
+   defining Unicode char U+00C2 (decimal 194)
+   defining Unicode char U+00C3 (decimal 195)
+   defining Unicode char U+00C4 (decimal 196)
+   defining Unicode char U+00C5 (decimal 197)
+   defining Unicode char U+00C6 (decimal 198)
+   defining Unicode char U+00C7 (decimal 199)
+   defining Unicode char U+00C8 (decimal 200)
+   defining Unicode char U+00C9 (decimal 201)
+   defining Unicode char U+00CA (decimal 202)
+   defining Unicode char U+00CB (decimal 203)
+   defining Unicode char U+00CC (decimal 204)
+   defining Unicode char U+00CD (decimal 205)
+   defining Unicode char U+00CE (decimal 206)
+   defining Unicode char U+00CF (decimal 207)
+   defining Unicode char U+00D0 (decimal 208)
+   defining Unicode char U+00D1 (decimal 209)
+   defining Unicode char U+00D2 (decimal 210)
+   defining Unicode char U+00D3 (decimal 211)
+   defining Unicode char U+00D4 (decimal 212)
+   defining Unicode char U+00D5 (decimal 213)
+   defining Unicode char U+00D6 (decimal 214)
+   defining Unicode char U+00D8 (decimal 216)
+   defining Unicode char U+00D9 (decimal 217)
+   defining Unicode char U+00DA (decimal 218)
+   defining Unicode char U+00DB (decimal 219)
+   defining Unicode char U+00DC (decimal 220)
+   defining Unicode char U+00DD (decimal 221)
+   defining Unicode char U+00DE (decimal 222)
+   defining Unicode char U+00DF (decimal 223)
+   defining Unicode char U+00E0 (decimal 224)
+   defining Unicode char U+00E1 (decimal 225)
+   defining Unicode char U+00E2 (decimal 226)
+   defining Unicode char U+00E3 (decimal 227)
+   defining Unicode char U+00E4 (decimal 228)
+   defining Unicode char U+00E5 (decimal 229)
+   defining Unicode char U+00E6 (decimal 230)
+   defining Unicode char U+00E7 (decimal 231)
+   defining Unicode char U+00E8 (decimal 232)
+   defining Unicode char U+00E9 (decimal 233)
+   defining Unicode char U+00EA (decimal 234)
+   defining Unicode char U+00EB (decimal 235)
+   defining Unicode char U+00EC (decimal 236)
+   defining Unicode char U+00ED (decimal 237)
+   defining Unicode char U+00EE (decimal 238)
+   defining Unicode char U+00EF (decimal 239)
+   defining Unicode char U+00F0 (decimal 240)
+   defining Unicode char U+00F1 (decimal 241)
+   defining Unicode char U+00F2 (decimal 242)
+   defining Unicode char U+00F3 (decimal 243)
+   defining Unicode char U+00F4 (decimal 244)
+   defining Unicode char U+00F5 (decimal 245)
+   defining Unicode char U+00F6 (decimal 246)
+   defining Unicode char U+00F8 (decimal 248)
+   defining Unicode char U+00F9 (decimal 249)
+   defining Unicode char U+00FA (decimal 250)
+   defining Unicode char U+00FB (decimal 251)
+   defining Unicode char U+00FC (decimal 252)
+   defining Unicode char U+00FD (decimal 253)
+   defining Unicode char U+00FE (decimal 254)
+   defining Unicode char U+00FF (decimal 255)
+   defining Unicode char U+0102 (decimal 258)
+   defining Unicode char U+0103 (decimal 259)
+   defining Unicode char U+0104 (decimal 260)
+   defining Unicode char U+0105 (decimal 261)
+   defining Unicode char U+0106 (decimal 262)
+   defining Unicode char U+0107 (decimal 263)
+   defining Unicode char U+010C (decimal 268)
+   defining Unicode char U+010D (decimal 269)
+   defining Unicode char U+010E (decimal 270)
+   defining Unicode char U+010F (decimal 271)
+   defining Unicode char U+0110 (decimal 272)
+   defining Unicode char U+0111 (decimal 273)
+   defining Unicode char U+0118 (decimal 280)
+   defining Unicode char U+0119 (decimal 281)
+   defining Unicode char U+011A (decimal 282)
+   defining Unicode char U+011B (decimal 283)
+   defining Unicode char U+011E (decimal 286)
+   defining Unicode char U+011F (decimal 287)
+   defining Unicode char U+0130 (decimal 304)
+   defining Unicode char U+0131 (decimal 305)
+   defining Unicode char U+0132 (decimal 306)
+   defining Unicode char U+0133 (decimal 307)
+   defining Unicode char U+0139 (decimal 313)
+   defining Unicode char U+013A (decimal 314)
+   defining Unicode char U+013D (decimal 317)
+   defining Unicode char U+013E (decimal 318)
+   defining Unicode char U+0141 (decimal 321)
+   defining Unicode char U+0142 (decimal 322)
+   defining Unicode char U+0143 (decimal 323)
+   defining Unicode char U+0144 (decimal 324)
+   defining Unicode char U+0147 (decimal 327)
+   defining Unicode char U+0148 (decimal 328)
+   defining Unicode char U+014A (decimal 330)
+   defining Unicode char U+014B (decimal 331)
+   defining Unicode char U+0150 (decimal 336)
+   defining Unicode char U+0151 (decimal 337)
+   defining Unicode char U+0152 (decimal 338)
+   defining Unicode char U+0153 (decimal 339)
+   defining Unicode char U+0154 (decimal 340)
+   defining Unicode char U+0155 (decimal 341)
+   defining Unicode char U+0158 (decimal 344)
+   defining Unicode char U+0159 (decimal 345)
+   defining Unicode char U+015A (decimal 346)
+   defining Unicode char U+015B (decimal 347)
+   defining Unicode char U+015E (decimal 350)
+   defining Unicode char U+015F (decimal 351)
+   defining Unicode char U+0160 (decimal 352)
+   defining Unicode char U+0161 (decimal 353)
+   defining Unicode char U+0162 (decimal 354)
+   defining Unicode char U+0163 (decimal 355)
+   defining Unicode char U+0164 (decimal 356)
+   defining Unicode char U+0165 (decimal 357)
+   defining Unicode char U+016E (decimal 366)
+   defining Unicode char U+016F (decimal 367)
+   defining Unicode char U+0170 (decimal 368)
+   defining Unicode char U+0171 (decimal 369)
+   defining Unicode char U+0178 (decimal 376)
+   defining Unicode char U+0179 (decimal 377)
+   defining Unicode char U+017A (decimal 378)
+   defining Unicode char U+017B (decimal 379)
+   defining Unicode char U+017C (decimal 380)
+   defining Unicode char U+017D (decimal 381)
+   defining Unicode char U+017E (decimal 382)
+   defining Unicode char U+200C (decimal 8204)
+   defining Unicode char U+2013 (decimal 8211)
+   defining Unicode char U+2014 (decimal 8212)
+   defining Unicode char U+2018 (decimal 8216)
+   defining Unicode char U+2019 (decimal 8217)
+   defining Unicode char U+201A (decimal 8218)
+   defining Unicode char U+201C (decimal 8220)
+   defining Unicode char U+201D (decimal 8221)
+   defining Unicode char U+201E (decimal 8222)
+   defining Unicode char U+2030 (decimal 8240)
+   defining Unicode char U+2031 (decimal 8241)
+   defining Unicode char U+2039 (decimal 8249)
+   defining Unicode char U+203A (decimal 8250)
+   defining Unicode char U+2423 (decimal 9251)
+)
+Now handling font encoding OT1 ...
+... processing UTF-8 mapping file for font encoding OT1
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu
+File: ot1enc.dfu 2014/09/29 v1.1m UTF-8 support for inputenc
+   defining Unicode char U+00A1 (decimal 161)
+   defining Unicode char U+00A3 (decimal 163)
+   defining Unicode char U+00B8 (decimal 184)
+   defining Unicode char U+00BF (decimal 191)
+   defining Unicode char U+00C5 (decimal 197)
+   defining Unicode char U+00C6 (decimal 198)
+   defining Unicode char U+00D8 (decimal 216)
+   defining Unicode char U+00DF (decimal 223)
+   defining Unicode char U+00E6 (decimal 230)
+   defining Unicode char U+00EC (decimal 236)
+   defining Unicode char U+00ED (decimal 237)
+   defining Unicode char U+00EE (decimal 238)
+   defining Unicode char U+00EF (decimal 239)
+   defining Unicode char U+00F8 (decimal 248)
+   defining Unicode char U+0131 (decimal 305)
+   defining Unicode char U+0141 (decimal 321)
+   defining Unicode char U+0142 (decimal 322)
+   defining Unicode char U+0152 (decimal 338)
+   defining Unicode char U+0153 (decimal 339)
+   defining Unicode char U+2013 (decimal 8211)
+   defining Unicode char U+2014 (decimal 8212)
+   defining Unicode char U+2018 (decimal 8216)
+   defining Unicode char U+2019 (decimal 8217)
+   defining Unicode char U+201C (decimal 8220)
+   defining Unicode char U+201D (decimal 8221)
+)
+Now handling font encoding OMS ...
+... processing UTF-8 mapping file for font encoding OMS
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu
+File: omsenc.dfu 2014/09/29 v1.1m UTF-8 support for inputenc
+   defining Unicode char U+00A7 (decimal 167)
+   defining Unicode char U+00B6 (decimal 182)
+   defining Unicode char U+00B7 (decimal 183)
+   defining Unicode char U+2020 (decimal 8224)
+   defining Unicode char U+2021 (decimal 8225)
+   defining Unicode char U+2022 (decimal 8226)
+)
+Now handling font encoding OMX ...
+... no UTF-8 mapping file for font encoding OMX
+Now handling font encoding U ...
+... no UTF-8 mapping file for font encoding U
+   defining Unicode char U+00A9 (decimal 169)
+   defining Unicode char U+00AA (decimal 170)
+   defining Unicode char U+00AE (decimal 174)
+   defining Unicode char U+00BA (decimal 186)
+   defining Unicode char U+02C6 (decimal 710)
+   defining Unicode char U+02DC (decimal 732)
+   defining Unicode char U+200C (decimal 8204)
+   defining Unicode char U+2026 (decimal 8230)
+   defining Unicode char U+2122 (decimal 8482)
+   defining Unicode char U+2423 (decimal 9251)
+))
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty
+Package: fontenc 2005/09/27 v1.99g Standard LaTeX package
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def
+File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
+LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
+))
+(/usr/local/texlive/2015/texmf-dist/tex/generic/babel/babel.sty
+Package: babel 2014/09/25 3.9l The Babel package
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/babel-portuges/portuges.ldf
+Language: portuges 2008/03/18 v1.2q Portuguese support from the babel system
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/babel/babel.def
+File: babel.def 2014/09/25 3.9l Babel common definitions
+\babel@savecnt=\count89
+\U@D=\dimen110
+)
+Package babel Info: Making " an active character on input line 145.
+))
+(/usr/local/texlive/2015/texmf-dist/tex/latex/hyphenat/hyphenat.sty
+Package: hyphenat 2009/09/02 v2.3c hyphenation utilities
+\langwohyphens=\language80
+LaTeX Info: Redefining \_ on input line 43.
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
+Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
+Package: graphics 2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty
+Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg
+File: graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
+)
+Package graphics Info: Driver file: pdftex.def on input line 94.
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def
+File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty
+Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO)
+)
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
+Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
+)
+\Gread@gobject=\count90
+))
+\Gin@req@height=\dimen111
+\Gin@req@width=\dimen112
+)
+(./enunciado.aux)
+\openout1 = `enunciado.aux'.
+
+LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 31.
+LaTeX Font Info:    ... okay on input line 31.
+
+(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
+[Loading MPS to PDF converter (version 2006.09.02).]
+\scratchcounter=\count91
+\scratchdimen=\dimen113
+\scratchbox=\box27
+\nofMPsegments=\count92
+\nofMParguments=\count93
+\everyMPshowfont=\toks19
+\MPscratchCnt=\count94
+\MPscratchDim=\dimen114
+\MPnumerator=\count95
+\makeMPintoPDFobject=\count96
+\everyMPtoPDFconversion=\toks20
+) (/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
+Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO
+)
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifluatex.sty
+Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO)
+Package ifluatex Info: LuaTeX not detected.
+)
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifpdf.sty
+Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO)
+Package ifpdf Info: pdfTeX in PDF mode is detected.
+)
+Package pdftexcmds Info: LuaTeX not detected.
+Package pdftexcmds Info: \pdf@primitive is available.
+Package pdftexcmds Info: \pdf@ifprimitive is available.
+Package pdftexcmds Info: \pdfdraftmode found.
+)
+(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
+Package: epstopdf-base 2010/02/09 v2.5 Base part for package epstopdf
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grfext.sty
+Package: grfext 2010/08/19 v1.1 Manage graphics extensions (HO)
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
+Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO)
+))
+(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty
+Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO)
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
+Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO)
+
+(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/etexcmds.sty
+Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
+Package etexcmds Info: Could not find \expanded.
+(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
+(etexcmds)             that some package has redefined \expanded.
+(etexcmds)             In the latter case, load this package earlier.
+)))
+Package grfext Info: Graphics extension search list:
+(grfext)             [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE
+G,.JBIG2,.JB2,.eps]
+(grfext)             \AppendGraphicsExtensions on input line 452.
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
+File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
+e
+))
+Underfull \vbox (badness 10000) has occurred while \output is active []
+
+LaTeX Font Info:    Try loading font information for T1+cmss on input line 38.
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1cmss.fd
+File: t1cmss.fd 2014/09/29 v2.5h Standard LaTeX font definitions
+)
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <14.4> on input line 38.
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <7> on input line 38.
+LaTeX Font Info:    Try loading font information for T1+cmtt on input line 64.
+
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1cmtt.fd
+File: t1cmtt.fd 2014/09/29 v2.5h Standard LaTeX font definitions
+) [1
+
+
+{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
+Overfull \hbox (9.03943pt too wide) in paragraph at lines 93--94
+[]\T1/cmr/m/n/10.95 Para se co-nec-tar ao ser-vi-dor você deve uti-li-zar []\T1
+/cmtt/m/n/10.95 client.info(id, xs, ys, xtag, ytag)\T1/cmr/m/n/10.95 .
+ []
+
+LaTeX Font Info:    Try loading font information for OMS+cmr on input line 95.
+(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omscmr.fd
+File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
+)
+LaTeX Font Info:    Font shape `OMS/cmr/m/n' in size <10.95> not available
+(Font)              Font shape `OMS/cmsy/m/n' tried instead on input line 95.
+
+<marker.png, id=11, 301.125pt x 301.125pt>
+File: marker.png Graphic file (type png)
+ <use marker.png>
+Package pdftex.def Info: marker.png used on input line 104.
+(pdftex.def)             Requested size: 125.47916pt x 125.47794pt.
+ [2]
+<ini.png, id=16, 1080.035pt x 928.46875pt>
+File: ini.png Graphic file (type png)
+ <use ini.png>
+Package pdftex.def Info: ini.png used on input line 125.
+(pdftex.def)             Requested size: 243.26106pt x 209.12778pt.
+ [3 <./marker.png (PNG copy)>] [4 <./ini.png>] (./enunciado.aux) ) 
+Here is how much of TeX's memory you used:
+ 4027 strings out of 493089
+ 60949 string characters out of 6134841
+ 186616 words of memory out of 5000000
+ 7447 multiletter control sequences out of 15000+600000
+ 12237 words of font info for 33 fonts, out of 8000000 for 9000
+ 1141 hyphenation exceptions out of 8191
+ 46i,9n,50p,538b,302s stack positions out of 5000i,500n,10000p,200000b,80000s
+{/usr/local/t
+exlive/2015/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc}</usr/local/tex
+live/2015/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/local/texl
+ive/2015/texmf-dist/fonts/type1/public/cm-super/sfrm1095.pfb></usr/local/texliv
+e/2015/texmf-dist/fonts/type1/public/cm-super/sfrm1440.pfb></usr/local/texlive/
+2015/texmf-dist/fonts/type1/public/cm-super/sfsx1440.pfb></usr/local/texlive/20
+15/texmf-dist/fonts/type1/public/cm-super/sfsx2074.pfb></usr/local/texlive/2015
+/texmf-dist/fonts/type1/public/cm-super/sftt1095.pfb>
+Output written on enunciado.pdf (4 pages, 149392 bytes).
+PDF statistics:
+ 46 PDF objects out of 1000 (max. 8388607)
+ 30 compressed objects within 1 object stream
+ 0 named destinations out of 1000 (max. 500000)
+ 11 words of extra memory for PDF output out of 10000 (max. 10000000)
+

BIN
enunciado/enunciado.pdf


BIN
enunciado/enunciado.synctex.gz


+ 146 - 0
enunciado/enunciado.tex

@@ -0,0 +1,146 @@
+% --------------------------------------------------------------
+% This is all preamble stuff that you don't have to worry about.
+% Head down to where it says "Start here"
+% --------------------------------------------------------------
+
+\documentclass[11pt, a4paper]{scrartcl}
+
+\usepackage{tabularx}
+
+%encoding
+%--------------------------------------
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+%--------------------------------------
+
+%Portuguese-specific commands
+%--------------------------------------
+\usepackage[portuguese]{babel}
+%--------------------------------------
+
+%Hyphenation rules
+%--------------------------------------
+\usepackage{hyphenat}
+\usepackage{graphicx}
+%--------------------------------------
+
+
+
+%\newcommand*{\ENTREGA{}}
+ 
+\begin{document}
+
+	
+	\title{RASCUNHO Projeto 6}%replace X with the appropriate number
+	\author{MAC0318 Introdução à Programação de Robôs Móveis}
+	 
+	\vspace*{-3cm}
+	{\let\newpage\relax\maketitle}
+
+	
+	\section{Objetivo}
+	
+	Nesse exercício de programação vocês deverão montar um robô que brinque de pega-pega.
+	
+	O objetivo é que o seu robô seja o menos pego, ou seja, que o número total de vezes que ele
+	foi pego seja o menor entre todos.
+	
+	\section{Regras}
+	
+	Haverá um campo com diversos robôs (no mínimo dois). Em qualquer  momento de jogo haverá apenas um pegador.
+	
+	Ao iniciar o seu programa você será informado das dimensões do campo e das linhas que descrevem seus obstáculos. Você não deve invadir essas linhas e nem sair fora do campo. Caso uma dessas linhas senha ultrapassada, você deve ficar parado 5 segundos como penalidade.
+	
+	Sempre que alguém for pego, deve ficar parado 5 segundos (tempo existentes para que os outros fujam). Se o seu robô esperar esses 5 segundos, você será penalizado.
+	
+	No campo de pega-pega não haverá paredes. Cabe a você manter o seu robô dentro do mesmo.
+	
+	\section{Funcionamento}
+	
+	Todos robôs terão um identificador visual que contêm um id único. Esse marcador deve estar posicionado de modo que ele fique paralelo ao chão. Não pode estar amassado ou dobrado.
+	
+	Haverá uma câmera conectada a um computador. Esse computador irá coordenar o jogo. Ele observará se todas as regras estão sendo obedecidas e informará aos participantes a posição de todos os robôs presentes no campo.
+	
+	Cada participante deve se conectar a esse servidor e controlar o seu robô. Vocês podem utilizar um computador convencional e controlar o robô via bluetooth ou podem utilizar uma Raspberry Pi conectada diretamente ao robô. No diretório \verb|player-lejos| você poderá ver um exemplo completo de como utilizar o bluetooth com o Lejos.
+	
+	\section{Penalidades}
+	
+	As penalidades acumuladas durante o jogo serão a seguintes, quem acumular menos ganha a competição:
+	\begin{center}
+		\begin{table}[h]
+		\begin{tabularx}{\textwidth}{|c|X|}
+			\hline
+			Penalidade & Descrição \\ \hline
+			2 & Sair do campo seu robô será recolocado manualmente por uma pessoa na posição mais perto da que ele saiu dentro do campo. \\ \hline
+			1 & Ser pego \\\hline
+			5 & Não esperar os 5 segundos depois de ser pego \\\hline
+			5 & Não esperar os 5 segundos depois de passar por cima de um obstáculo. Após passar por cima de um obstáculo e esperar 5 segundos, ele terá 2 segundos para sair do mesmo. \\
+			\hline
+		\end{tabularx}
+	\end{table}
+	\end{center}
+	
+	\section{Complicações}
+	
+	Felizmente, o a recepção dos dados da câmera e a identificação dos marcadores demandam um pouco de tempo. Esse atraso pode ser percebido executando o exemplo do \verb|player-camera|. Você deve encontrar uma solução para mitigar esse atraso.
+	
+	Você pode, por exemplo, diminuir a velocidade de reação dos do seu robô, assim a posição real dele estará mais próxima da informada pela câmera. Você também pode tentar prever o próximo estado que seu robô estrá depois de uma ordem de movimento. 
+	
+	\section{Utilizando o servidor}
+	
+	Para se conectar ao servidor você deve instanciar um objeto do tipo \verb|TagClient|. Para isso, deve fornecer o endereço IP da máquina que o servidor está sendo executado e a porta da aplicação.
+	
+	Para se conectar ao servidor você deve utilizar \verb|client.info(id, xs, ys, xtag, ytag)|. Onde:
+	\begin{itemize}
+		\item \verb|id|, o número do marcador do seu robô. Se for um robô virtual, pode ser qualquer número inteiro.
+		\item  \verb|xs, ys|, as dimensões do robô.
+		\item  \verb|xtag, ytag|, posição do centro do marcador referente ao canto de trás esquerdo do robô. Veja a classe \verb|Robot|.
+	\end{itemize}
+
+	Esses valores são necessários para descrever o retângulo que está em torno do robô. Esse retângulo deve ser proporcional ao tamanho real do robô. Na figura 1  abaixo temos um exemplo de marcador. A direção do marcador é definida pelos três quadrados pretos em suas bordas.
+	
+	\begin{figure}
+		\begin{center}
+			\includegraphics[height=0.3\linewidth]{marker}
+		\end{center}
+		\caption{Note que a posição do marcador determina a orientação do robô. No marcador acima o robô está orientado para cima.}
+	\end{figure}
+
+	Você estará conectado no servidor em quanto a constante do objeto \verb|quit| estar no estado \verb|False|.
+	Durante essa condição você pode perguntar sobre informações do campo, \verb|getFieldInfo()|. Perguntar se o jogo está pausado ou não \verb|getStatus()|. Pegar a informação de quem é o pegador atual, \verb|getTagInfo| (esse método retorna apenas o id dele e o tempo de fuga restante). Ou receber um vetor com as últimas posições informadas pelo servidor (\verb|getPosition()|). Nesse vetor haverá o id do robô, a sua posição e os valores \verb|xs|,\verb|ys|,  \verb|xtag| e \verb|ytag|.
+	
+	Para ver um exemplo funcional do código veja o arquivo \verb|player-virtual|. Esse arquivo simula um jogador, no entanto o próprio código informa a posição do jogado. Você não deve fazer isso. Use como esqueleto do seu projeto o arquivo \verb|player-camera| ou o \verb|player-lejos|.
+	
+	Para iniciar o servidor vocês devem executar o código \verb|main.py|. Vocês podem rodar com a flag \verb|-n| para que não haja a necessidade de câmera. Essa função serve para vocês testarem. Note que quando não há câmera, não há o atraso do processamento.
+	
+	\section{Simulação}
+	
+	Para executar o simulador você primeiramente deve iniciar o servidor sem câmera. Para isso execute o seguinte comando:
+	\begin{verbatim}
+	python3 main.py  -n
+	\end{verbatim}
+	
+	Feito isso, o servidor vai ser iniciado e uma tela como a seguinte será mostrada:
+	\begin{center}
+		\includegraphics[height=0.5\linewidth]{ini}
+	\end{center}
+
+	Depois disso você deve conectar o se robô ao servidor. Já temos um exemplo de robô pronto em \verb|player-virtual|. Assim que o robô for conectado ele aparecerá na tela. Você pode conectar múltiplos robôs reais ou virtuais ao servidor, no entanto eles devem ter \verb|id|s diferentes. 
+	
+	Para iniciar o jogo é necessário no servidor apertar a tecla \verb|s|. Para pausar \verb|p| e para sair  \verb|q|. Assim que o jogo iniciar, o pegador ficará marcado de vermelho.
+	
+
+	\section{Tarefas}
+	
+	Para concluir esse EP você deve montar um robô que consiga jogar.
+	 Você pode implementar qualquer estratégia.
+	
+	
+	
+	
+	
+	
+	
+
+	
+\end{document}

BIN
enunciado/ini.png


BIN
enunciado/marker.png


BIN
enunciado/robo.png


+ 23 - 2
main.py

@@ -75,6 +75,8 @@ def get_transform_matrix(dev, board_size, dpi, calib_file = None):
     img = get_frame(dev)
  
     # Displace image to user
+    text = "[TOP_LEFT, BOTTOM_LEFT, TOP_RIGHT, BOTTOM_RIGHT]"
+    cv2.putText(img, text, (0,30), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255))
     cv2.imshow("Calibrate", img)
  
     # Register the mouse callback on this window. When 
@@ -140,6 +142,17 @@ if __name__ == "__main__":
     # The size of the board in inches, measured between the two
     # robot boundaries:
     board_size = [185, 215]
+    maplines = [
+        [40, 40, 40, 80],
+        [40, 80, 60, 80],
+        [60, 80, 60, 40],
+        [60, 40, 40, 40],
+
+        [40+70, 40+30, 40+70, 80+30],
+        [40+70, 80+30, 60+70, 80+30],
+        [60+70, 80+30, 60+70, 40+30],
+        [60+70, 40+30, 40+70, 40+30]
+    ]
     point = []
     if camera:
         board_size = [board_size[1], board_size[0]]
@@ -157,13 +170,16 @@ if __name__ == "__main__":
         # transform = get_transform_matrix(dev, board_size, dpi)
         transform = get_transform_matrix_points([(340, 10), (78, 1066), (1502, 6), (1806, 1045)], board_size, dpi)
 
-    server = tag.TagServer(10318, board_size)
+    server = tag.TagServer(10318, board_size, maplines)
 
     while True:
-        img_orig = np.zeros([transform_size[0], transform_size[1], 3])
+        img_orig = None
         if camera:
+            # pega uma imagem da camera
             img_orig = get_frame(dev)
         else:
+            # cria uma imagem preta
+            img_orig = np.zeros([transform_size[0], transform_size[1], 3])
             time.sleep(0.1)
 
         start = time.time()
@@ -185,6 +201,10 @@ if __name__ == "__main__":
                     cv2.circle(img, p, 30, (0,255,0))
                     cv2.putText(img, str(idd), p, cv2.FONT_HERSHEY_SIMPLEX, 1.0, (255, 0, 255))
 
+            for line in maplines:
+                color = (255, 255, 255)
+                line = np.array(line)*dpi
+                cv2.line(img, (line[0], line[1]), (line[2], line[3]), color)
             for robot in server.robots():
                 for line in robot.lines():
                     p1 = (line[0]*dpi).astype(int)
@@ -193,6 +213,7 @@ if __name__ == "__main__":
                     if robot == server.tag:
                         color = (0, 0, 255)
                     cv2.line(img, (p1[0], p1[1]), (p2[0], p2[1]), color)
+
             if server.paused:
                 cv2.putText(img, "PAUSE", (0,30), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255))
             # res = cv2.resize(img,None,fx=.5, fy=.5)

+ 2 - 2
player-camera.py

@@ -28,10 +28,10 @@ while not client.quit:
     time.sleep(0.1)
 
     # nao recebeu informacoes do campo
-    if client.getBoard() is None:
+    if client.getFieldInfo() is None:
         continue
     elif px is None:
-        board = client.getBoard()
+        board = client.getFieldInfo()
         px, py = board[0]*random(), board[1]*random()
         course = math.pi*2.0*random()
 

+ 0 - 0
lejos/ConsoleTest.class → player-lejos/ConsoleTest.class


+ 0 - 0
lejos/ConsoleTest.java → player-lejos/ConsoleTest.java


+ 2 - 2
player-lejos.py → player-lejos/player-lejos.py

@@ -43,10 +43,10 @@ while not client.quit:
     time.sleep(0.4)
 
     # nao recebeu informacoes do campo
-    if client.getBoard() is None:
+    if client.getFieldInfo() is None:
         continue
     elif px is None:
-        board = client.getBoard()
+        board = client.getFieldInfo()
         px, py = board[0]*random(), board[1]*random()
         course = math.pi*2.0*random()
 

+ 8 - 4
player-virtual.py

@@ -27,22 +27,26 @@ signal.signal(signal.SIGINT, signal_handler)
 players = {}
 
 while not client.quit:
-    time.sleep(0.1)
 
     # nao recebeu informacoes do campo
-    if client.getBoard() is None:
+    if client.getFieldInfo() is None:
         continue
     elif px is None:
-        board = client.getBoard()
+        board = client.getFieldInfo()
         px, py = board[0]*random(), board[1]*random()
         course = math.pi*2.0*random()
         client.setPosition(px, py, course)
 
-    # jogo esta pausado
+    # jogo esta parado
     if client.getStatus() is False:
         players = {}
         continue
 
+    # jogo esta parado
+    if client.isPause() is True:
+        time.sleep(5)
+        client.setPause()
+
     # nao recebeu informacoes do pegador
     if client.getTagInfo() is None:
         continue

+ 9 - 1
robot.py

@@ -51,7 +51,7 @@ class Robot():
         return self.ccw(A,C,D) != self.ccw(B,C,D) and self.ccw(A,B,C) != self.ccw(A,B,D)
 
     # get robot and see if this intersect te other
-    def intersect(self, robot):
+    def intersectRobot(self, robot):
         thislines = self.lines()
         other = robot.lines()
         for i in thislines:
@@ -59,3 +59,11 @@ class Robot():
                 if self.line_intersect(i[0], i[1], j[0], j[1]):
                     return True
         return False
+
+        # get robot and see if this intersect te other
+    def intersectLine(self, line):
+        thislines = self.lines()
+        for i in thislines:
+            if self.line_intersect(i[0], i[1], (line[0], line[1]), (line[2], line[3])):
+                    return True
+        return False

+ 41 - 11
tag.py

@@ -9,7 +9,7 @@ import time
 run_time = 5
 
 class TagServer(threading.Thread):
-    def __init__(self, port, board_size):
+    def __init__(self, port, board_size, maplines):
         threading.Thread.__init__(self)
 
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -24,6 +24,7 @@ class TagServer(threading.Thread):
 
         self.tag = None
         self.board_size = board_size
+        self.map = maplines
 
         self.paused = True
         self.runV = True
@@ -56,18 +57,27 @@ class TagServer(threading.Thread):
         # check for collision
         self.mutex2.acquire()
         for i in self.robots():
-            if i != self.tag:
+            for line in self.map:
+                if i.intersectLine(line):
+                    print(i.idd, " PAUSE")
+                    self.send("PAUSE\n")
+                    break
+
+            # se nao eh o pegador continua
+            if i == self.tag:
                 continue
+            # verifica se colidiu
             for j in self.robots():
                 if i == j:
                     continue
-                if i.intersect(j):
+                if i.intersectRobot(j):
                     if self.last + run_time <= time.time():
                         print(i.idd, " pegou ", j.idd)
                         self.tag = j
                         self.brodcast("RUN "+str(self.tag.idd)+","+str(run_time))
                         self.last = time.time()
                         break
+
         self.mutex2.release()
 
     def stopGame (self):
@@ -136,6 +146,7 @@ class TagThread(threading.Thread):
 
         self.robot = None
         self.bz = server.board_size
+        self.map = server.map
         self.server = server
 
         socket.settimeout(1)
@@ -153,13 +164,15 @@ class TagThread(threading.Thread):
             except SocketError as e:
                 self.robot = None
                 break
+            data = data.split("\n")[0]
             data = data.split(" ")
             try:
                 # print (data)
                 if data[0] == "SUB":
                     idd, xsize, ysize, xtag, ytag = data[1].split(",")
                     self.robot = Robot(int(idd), float(xsize), float(ysize), float(xtag), float(ytag))
-                    self.send("OK "+str(self.bz[0])+","+str(self.bz[1])+"\n")
+                    m = str(self.map).replace(", ", ":")
+                    self.send("OK "+str(self.bz[0])+","+str(self.bz[1])+","+m+"\n")
                 if data[0] == "P":
                     posx, posy, curse = data[1].split(",")
                     posx, posy, curse = float(posx), float(posy), float(curse)
@@ -192,6 +205,7 @@ class TagClient(threading.Thread):
         self.startf = None
         self.runf = None
         self.position = None
+        self.pause = False
 
         # info
         self.runing = False
@@ -224,19 +238,26 @@ class TagClient(threading.Thread):
             if "\n" not in data:
                 continue
 
-            tmp = data.split("\n")
-            if tmp[-1] != '':
-                data = tmp[-1]
-                tmp = tmp[0:-1]
+            splitdata = data.split("\n")
+            if splitdata[-1] != '':
+                data = splitdata[-1]
+                splitdata = splitdata[0:-1]
             else:
                 data = ""
 
-            for d in tmp:
+            for d in splitdata:
                 d = d.split(" ")
                 if d[0] == "OK":
-                    x, y = d[1].split(",")
+                    x, y, lines = d[1].split(",")
                     x, y = float(x), float(y)
                     self.board = (x, y)
+                    self.maplines = []
+                    lines = lines.replace("[[", "")
+                    lines = lines.replace("]]", "")
+                    lines = lines.split("]:[")
+                    for line in lines:
+                        points = [float(p) for p in line.split(":")]
+                        self.maplines.append(line)
 
                 elif d[0] == "P":
                     posx, posy, course, idd, xsize, ysize, xtag, ytag = d[1].split(",")
@@ -268,13 +289,22 @@ class TagClient(threading.Thread):
                 elif d[0] == "QUIT":
                     print(d)
                     self.stop()
+                elif d[0] == "PAUSE":
+                    print(d)
+                    self.pause = True
         self.sock.close()
         self.quit = True
 
     def getStatus(self):
         return self.runing
 
-    def getBoard(self):
+    def isPause(self):
+        return self.pause
+
+    def setPause(self):
+        self.pause = False
+
+    def getFieldInfo(self):
         return self.board
 
     def getPosition(self):

+ 0 - 35
test.py

@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-
-#Lists various information from all bricks it can connect to.
-
-import sys, traceback
-import nxt.locator
-import nxt.brick
-
-
-b = None
-try:
-    print('Find brick...')
-    b = nxt.locator.find_one_brick()
-    name, host, signal_strength, user_flash = b.get_device_info()
-    print('NXT brick name: %s' % name)
-    print('Host address: %s' % host)
-    print('Bluetooth signal strength: %s' % signal_strength)
-    print('Free user flash: %s' % user_flash)
-    prot_version, fw_version = b.get_firmware_version()
-    print('Protocol version %s.%s' % prot_version)
-    print('Firmware version %s.%s' % fw_version)
-    millivolts = b.get_battery_level()
-    print('Battery level %s mV' % millivolts)
-    b.play_tone_and_wait(300, 50)
-    b.play_tone_and_wait(400, 50)
-    b.play_tone_and_wait(500, 50)
-    b.play_tone_and_wait(600, 50)
-    print('done')
-    b.sock.close()
-except:
-    print("Error while running test:")
-    traceback.print_tb(sys.exc_info()[2])
-    print(str(sys.exc_info()[1]))
-    if b in locals():
-        b.sock.close