RaspiRobotBoard動作確認
匂いとか出ないか緊張しながら初通電。
焦げ臭くならないよな。。。
うん。大丈夫そうだ。
さっそく以下ページを参考に動作確認。
https://github.com/simonmonk/raspirobotboard/wiki/Tutorial-01---Getting-Started
まずライブラリのインストール。
pi@raspberrypi ~ $ pi@raspberrypi ~ $ sudo apt-get install python-rpi.gpio Reading package lists... Done Building dependency tree Reading state information... Done python-rpi.gpio is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. pi@raspberrypi ~ $ sudo apt-get install python-serial Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: python-wxgtk2.8 python-wxgtk2.6 python-wxgtk The following NEW packages will be installed: python-serial 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. Need to get 79.0 kB of archives. After this operation, 483 kB of additional disk space will be used. Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-serial all 2.5-2.1 [79.0 kB] Fetched 79.0 kB in 1s (64.6 kB/s) Selecting previously unselected package python-serial. (Reading database ... 69361 files and directories currently installed.) Unpacking python-serial (from .../python-serial_2.5-2.1_all.deb) ... Setting up python-serial (2.5-2.1) ... pi@raspberrypi ~ $
次にテストプログラム(?) のDLと展開
pi@raspberrypi ~ $ wget https://github.com/simonmonk/raspirobotboard/archive/master.zip --2014-03-20 22:38:41-- https://github.com/simonmonk/raspirobotboard/archive/master.zip Resolving github.com (github.com)... 192.30.252.129 Connecting to github.com (github.com)|192.30.252.129|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/simonmonk/raspirobotboard/zip/master [following] --2014-03-20 22:38:49-- https://codeload.github.com/simonmonk/raspirobotboard/zip/master Resolving codeload.github.com (codeload.github.com)... 192.30.252.145 Connecting to codeload.github.com (codeload.github.com)|192.30.252.145|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/zip] Saving to: `master.zip' [ <=> ] 5,340 --.-K/s in 0.005s 2014-03-20 22:38:55 (951 KB/s) - `master.zip' saved [5340] pi@raspberrypi ~ $ ls Desktop Documents master.zip ocr_pi.png python_games Scratch pi@raspberrypi ~ $ unzip master.zip Archive: master.zip 95281349acc1bba464c6929cea67ed33ede9b648 creating: raspirobotboard-master/ inflating: raspirobotboard-master/INSTALL.txt inflating: raspirobotboard-master/PKG-INFO inflating: raspirobotboard-master/README.md creating: raspirobotboard-master/examples/ inflating: raspirobotboard-master/examples/key_test.py inflating: raspirobotboard-master/examples/led_test.py inflating: raspirobotboard-master/examples/ocs_test.py inflating: raspirobotboard-master/examples/pin_test.py inflating: raspirobotboard-master/examples/rangefinder_test.py inflating: raspirobotboard-master/examples/rover.py inflating: raspirobotboard-master/examples/switch_test.py inflating: raspirobotboard-master/raspirobotboard.py inflating: raspirobotboard-master/setup.py pi@raspberrypi ~ $ ls Desktop master.zip python_games Scratch Documents ocr_pi.png raspirobotboard-master pi@raspberrypi ~ $ cd raspirobotboard-master/ pi@raspberrypi ~/raspirobotboard-master $ sudo python setup.py install running install running build running build_py creating build creating build/lib.linux-armv6l-2.7 copying raspirobotboard.py -> build/lib.linux-armv6l-2.7 running install_lib copying build/lib.linux-armv6l-2.7/raspirobotboard.py -> /usr/local/lib/python2.7/dist-packages byte-compiling /usr/local/lib/python2.7/dist-packages/raspirobotboard.py to raspirobotboard.pyc running install_egg_info Writing /usr/local/lib/python2.7/dist-packages/raspirobotboard-1.0.egg-info pi@raspberrypi ~/raspirobotboard-master $
順調、順調。
じゃ、動かしてみよう。
pi@raspberrypi ~/raspirobotboard-master $ sudo python Python 2.7.3 (default, Jan 13 2013, 11:20:46) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from raspirobotboard import * >>> rr = RaspiRobot() raspirobotboard.py:34: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. GPIO.setup(OC2_PIN, GPIO.OUT) >>>
んん!?
なんかエラー出たぞ。
とりあえず無視。
>>> rr.set_led1(1) #LED1 ON >>> rr.set_led1(0) #LED1 OFF >>> rr.set_led2(1) #LED2 ON >>> rr.set_led2(0) #LED2 OFF >>> rr.set_oc1(1) #oc1 ON >>> rr.set_oc1(0) #oc1 OFF >>> rr.set_oc2(0) #oc2 ?オンのまま >>> rr.set_oc2(1) #oc2 ?オンのまま >>> rr.set_oc3(1) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: RaspiRobot instance has no attribute 'set_oc3' >>>
なるほど。
でもOC2 がずーっとONのまま。。。
半田付けに失敗してるのかな?
とりあえず続き
>>> rr.forward() # L(+ -), R(- +) 3V 出力。 >>> rr.right() # L極性反転 L(- +), R(- +) >>> rr.left() # R極性反転 L(+ -), R(+ -) >>> rr.stop() # L, R 0v >>> rr.get_range_inch() # ? ビデオを見る限りだと近接センサ? 0 >>> rr.sw1_closed() # sw1 短絡状態 短絡するとTrue False >>> rr.sw1_closed() True >>> rr.sw2_closed() # sw2 短絡状態 短絡するとTrue False >>> rr.sw2_closed() True
なるほど。わかりやすい。
エラーが出る件と、oc2 がONになりっぱなしの件だけ
あとでのんびり調べてみようっと。
moremagic
2014-03-20