LoginSignup
5
2

More than 5 years have passed since last update.

暇してるPepper君と遊んであげた

Last updated at Posted at 2017-06-19

はじめに

Pepperくん、気がつくと、通路脇で暇そうにしている...。かわいそう。
サクッと簡単に手元のプログラムやslackなどと接続すればもっと
活躍してくれるかなと、遊んでみることにしました。

pepper.jpg

Pepperを動かすには

1.Choregraphe
https://www.softbank.jp/robot/developer/tools/sdk/

2.Pepper SDK for AndroidStudio
https://developer.softbankrobotics.com/jp-ja/news/pepper-sdk-android-studio-%E5%B0%8E%E5%85%A5%E3%82%AC%E3%82%A4%E3%83%89

3.NaoqiAPI
(API一覧)
http://doc.aldebaran.com/2-1/naoqi/index.html

と、Pepperを操るにはこの辺りが主流のようです。
そういえばPepperが来た頃はChoregrapheをいじってみんなで遊んでいたのを思い出した。。
今回はエンジニアだけじゃなくて、Slackなどから繋いでみんなで遊べたらいいなぁという要件もあり、
3のNaoqiAPIを利用することにしました。

Qimessaging.js

socket通信を利用してJavaScript->NaoqiAPIを利用するモジュールです。
https://github.com/aldebaran/libqi-js

使い方

pepper.js
// 入力IP取得
var ip = "192.168.0.1";
// NAOqiセッションの作成
qis = new QiSession(ip);
// 接続
qis.socket()
.on('connect', function(){
    // 接続成功
    console.log('[CONNECTED]');
    alert('[CONNECTED]');

    //いくつかのモジュールを予め読み込んでおく
    //一覧はこちらを参照
    //https://www.n-sysdes.co.jp/pepper%E6%8A%80%E8%A1%93%E3%83%96%E3%83%AD%E3%82%B0%EF%BC%9Anaoqiapi%E3%83%A1%E3%83%A2/
    qis.service('ALTextToSpeech').done(function(ins){
                als.alTextToSpeech = ins;
            });
            qis.service('ALMotion').done(function(ins){
                als.alMotion = ins;
            });
            qis.service('ALRobotPosture').done(function(ins){
                als.alRobotPosture = ins;
            });
            qis.service('ALAudioDevice').done(function(ins){
                als.alALAudioDevice = ins;
                als.alALAudioDevice.setOutputVolume(0);
            });
            qis.service('ALAnimatedSpeech').done(function(ins){
                als.alAnimatedSpeech = ins;
            });
            qis.service('ALTabletService').done(function(ins){
                als.alALTabletService = ins;
            });
            qis.service('ALAutonomousLife').done(function(ins){
                als.alALAutonomousLife = ins;
            });
            qis.service('ALBehaviorManager').done(function(ins){
                als.alALBehaviorManager = ins;
            });
            qis.service('ALBattery').done(function(ins){
                als.alALBattery = ins;
            });
            qis.service('ALBasicAwareness').done(function(ins){
                als.alALBasicAwareness = ins;
            });
            qis.service('ALAutonomousMoves').done(function(ins){
                als.alALAutonomousMoves = ins;
            });
            qis.service('ALLeds').done(function(ins){
                als.alALLeds = ins;
            });
            qis.service('ALSystem').done(function(ins){
                als.alALSystem = ins;
            });
})
pepper.js
//話す
als.alAnimatedSpeech.say("おはようございます");

//タブレットに何か表示する
als.alALTabletService.showWebview();
als.alALTabletService.loadUrl("http://qiita.com/");

//タブレットをスリープにする
als.alALTabletService.goToSleep();

//タブレットを起動する
als.alALTabletService.wakeUp();

//右手上げる
//他の稼働箇所はこの資料に記載
//http://doc.aldebaran.com/2-1/naoqi/core/autonomouslife_advanced.html
als.alMotion.changeAngles('RShoulderPitch',  -2, 0.08);

//ライトを赤色にする
als.alALLeds.fadeRGB("AllLeds","red",0.0);
als.alALLeds.fadeRGB("FaceLeds","red",0.0);
als.alALLeds.fadeRGB("EarLeds","red",0.0);

//ライトをデフォルトにする
als.alALLeds.reset("AllLeds");

//動かす(前進)ただし、バッテリーカバーが閉じている時のみ
als.alMotion.moveToward(5,0.0,0.0); // 0.1 = 10cm前に移動
//動かす(回転)ただし、バッテリーカバーが閉じている時のみ
als.alMotion.moveToward(0,0,5);

//オートノマスを切る
//solitary interactive disabled safeguard
//状態はこの資料に記載されている
//http://doc.aldebaran.com/2-1/naoqi/core/autonomouslife_advanced.html
als.alALAutonomousLife.setState("disabled");

//スリープモード
als.alMotion.rest();

//起動
als.alMotion.wakeUp();

//再起動
als.alALSystem.reboot();

//シャットダウン
als.alALSystem.shutdown();

//バッテリー状態の取得
als.alALBattery.getBatteryCharge().done(function(val)
  {
    console.log(val);
    alert(val);
  }
);

webサービスとしてとりあえず

とりあえず社内のwebサーバーに置いて、みんなで遊べるようにしました。
スクリーンショット 2017-06-19 16.15.12.png

おしまい

遊んであげたら、すっごい嬉しそうな顔になりました。よかったよかった。
pepper001.jpg

でも、仕事中にPepperに話しかけるのはだいぶ勇気がいるなぁ。
初期設定でも、Pepper君に名前を読んでねとか、パ行を発音してね、とか言われるけど
人がいると、かなり恥ずかしい。
その点、APIを使って遠くにいるPepperをこっそり制御させたりするのは、結構楽しい。
今後は、Slackの会話を読み上げさせたり、Watsonなんかと無駄に連携させたり、
何か面白い使い方を考えてPepperを有効活用しようと思います。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2