forward () { rs_send forward 1 /dev/ttyUSB2 } forwardというふうにしたい と言うわけで、
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ ls ALL_DEMO BURP HIGH5 LEFT_ARM_PICKUP LEFT_ARM_THUMP R RIGHT_ARM_STRIKE1 RIGHT_ARM_UP STEP ARMS_IN DANCE L LEFT_ARM_STRIKE1 LEFT_ARM_UP RIGHT RIGHT_ARM_STRIKE2 RIGHT_TURN_STEP TALK_BACK ARMS_OUT DEMO1 LEFT LEFT_ARM_STRIKE2 LEFT_TURN_STEP RIGHT_ARM_DOWN RIGHT_ARM_STRIKE3 ROAR TILT_BODY_LEFT BACKWARD DEMO2 LEFT_ARM_DOWN LEFT_ARM_STRIKE3 LISTEN RIGHT_ARM_IN RIGHT_ARM_SWEEP S TILT_BODY_RIGHT BACK_STEP EXECUTE LEFT_ARM_IN LEFT_ARM_SWEEP OOPS RIGHT_ARM_OUT RIGHT_ARM_THROW SLEEP WAKEUP BULLDOZER FORWARD LEFT_ARM_OUT LEFT_ARM_THROW POWER_OFF RIGHT_ARM_PICKUP RIGHT_ARM_THUMP SONIC WHISTLE yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ ls | wc -l 54 yasunari@debian:/usr/local/lib/kuro-rs/roboactor$54個の関数を作ってライブラリにする。
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ cat makelib.sh #!/bin/sh echo 'RS_SEND=${RS_SEND:-/usr/local/bin/rs_send}' echo 'ROBOACTORDIR=${ROBOACTORDIR:-/usr/local/lib/kuro-rs/roboactor}' echo 'ROBOACTORCHANNEL=${ROBOACTORCHANNEL:-1}' echo 'ROBOACTORPORT=${ROBOACTORPORT:-/dev/ttyUSB0}' echo for FILENAME in [A-Z]* do FUNCNAME="boroactor_"`echo $FILENAME | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` echo $FUNCNAME'() {' echo ' $RS_SEND' '$ROBOACTORDIR'/$FILENAME '$ROBOACTORCHANNEL' '$ROBOACTORPORT' echo '}' echo done yasunari@debian:/usr/local/lib/kuro-rs/roboactor$実行する
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ sh makelib.sh > libroboactor.sh yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ head libroboactor.sh RS_SEND=${RS_SEND:-/usr/local/bin/rs_send} ROBOACTORDIR=${ROBOACTORDIR:-/usr/local/lib/kuro-rs/roboactor} ROBOACTORCHANNEL=${ROBOACTORCHANNEL:-1} ROBOACTORPORT=${ROBOACTORPORT:-/dev/ttyUSB0} boroactor_all_demo() { $RS_SEND $ROBOACTORDIR/ALL_DEMO $ROBOACTORCHANNEL $ROBOACTORPORT } boroactor_arms_in() { yasunari@debian:/usr/local/lib/kuro-rs/roboactor$できた。
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ cat /tmp/roboactor_test.sh #!/bin/sh . /usr/local/lib/kuro-rs/roboactor/libroboactor.sh ROBOACTORPORT=/dev/ttyUSB2 roboactor_forward roboactor_left roboactor_right roboactor_stop yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ sh /tmp/roboactor_test.sh /tmp/roboactor_test.sh: 7: roboactor_forward: not found /tmp/roboactor_test.sh: 8: roboactor_left: not found /tmp/roboactor_test.sh: 9: roboactor_right: not found /tmp/roboactor_test.sh: 10: roboactor_stop: not found yasunari@debian:/usr/local/lib/kuro-rs/roboactor$目を疑うが、、、「ぼろあくたー」ではあかんな。
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ vi makelib.sh yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ sh makelib.sh > libroboactor.sh yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ !head head libroboactor.sh RS_SEND=${RS_SEND:-/usr/local/bin/rs_send} ROBOACTORDIR=${ROBOACTORDIR:-/usr/local/lib/kuro-rs/roboactor} ROBOACTORCHANNEL=${ROBOACTORCHANNEL:-1} ROBOACTORPORT=${ROBOACTORPORT:-/dev/ttyUSB0} roboactor_all_demo() { $RS_SEND $ROBOACTORDIR/ALL_DEMO $ROBOACTORCHANNEL $ROBOACTORPORT } roboactor_arms_in() { yasunari@debian:/usr/local/lib/kuro-rs/roboactor$再度テストプログラムの実行
yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ sh /tmp/roboactor_test.sh /usr/local/lib/kuro-rs/roboactor/FORWARD - 1 - /dev/ttyUSB2 port open err [/dev/ttyUSB2] /usr/local/lib/kuro-rs/roboactor/LEFT - 1 - /dev/ttyUSB2 port open err [/dev/ttyUSB2] /usr/local/lib/kuro-rs/roboactor/RIGHT - 1 - /dev/ttyUSB2 port open err [/dev/ttyUSB2] /tmp/roboactor_test.sh: 11: roboactor_stop: not found yasunari@debian:/usr/local/lib/kuro-rs/roboactor$ su Password: root@debian:/usr/local/lib/kuro-rs/roboactor# sh /tmp/roboactor_test.sh /usr/local/lib/kuro-rs/roboactor/FORWARD - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/FORWARD] /usr/local/lib/kuro-rs/roboactor/LEFT - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/LEFT] /usr/local/lib/kuro-rs/roboactor/RIGHT - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/RIGHT] /tmp/roboactor_test.sh: 11: roboactor_stop: not found root@debian:/usr/local/lib/kuro-rs/roboactor# sh /tmp/roboactor_test.sh /usr/local/lib/kuro-rs/roboactor/FORWARD - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/FORWARD] /usr/local/lib/kuro-rs/roboactor/LEFT - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/LEFT] /usr/local/lib/kuro-rs/roboactor/RIGHT - 1 - /dev/ttyUSB2 Send File : [/usr/local/lib/kuro-rs/roboactor/RIGHT] /tmp/roboactor_test.sh: 11: roboactor_stop: not found root@debian:/usr/local/lib/kuro-rs/roboactor#root でないと /dev/ttyUSB2 にアクセスできないとか、
まだ楽しめそうである。
|
|
←(前のページ) ロボアクターのリモコンの学習(2) |
当月のハックの記録 SheevaPlug/玄柴(KURO-SHEEVA)をハックしよう トップ |
(次のページ)→ バッファローダイレクトにまさかの再入荷 |