【问题标题】:Pepper: how to activate output of the box by Html/Javascript webpagePepper:如何通过 Html/Javascript 网页激活框的输出
【发布时间】:2018-10-01 12:02:01
【问题描述】:

我正在为 Aldebaran's Pepper 机器人编写应用程序。我正在使用 Choregraphe,并制作了一个用于在机器人平板电脑中显示的 html 页面。 我只想通过按下机器人平板电脑上显示的 Html 页面中的按钮来激活输出(我必须在“SHOW APP”框中添加)。 如何做到这一点?

【问题讨论】:

    标签: nao-robot pepper choregraphe


    【解决方案1】:

    您可以使用Javascript SDK 引发 ALMemory 事件,并订阅 Choregraphe 中的事件。

    类似这样的东西(左红框):

    【讨论】:

    • 谢谢!你能给我一个带有javascript代码的html页面的例子吗?
    【解决方案2】:

    index.html

    <head>
        <script src="/libs/qi/2/qi.js"></script>
        <script src="js/script.js"></script>
    </head>
    <body>
        <div class="flex">
            <button class="button" onclick="launchEvent1()">First event</button>
            <button class="button" onclick="launchEvent2()">Second event</button>
            <button class="button" onclick="launchEvent3()">Third event</button>
            <button class="home" onclick="launchEventHome()">Home button</button>
        </div>
    </body>
    

    script.js

    session = null
    QiSession(connected, disconnected, location.host);
    
    function connected(s) {
        console.log("Session connected");
        session = s;
        //If you want to subscribe so some events (to send info pepper->tablet) call the function here
    }
    
    function disconnected(error) {
        console.log("Session disconnected");
    }
    
    function launchEventHome(){
        session.service("ALMemory").then(function (memory) {
                memory.raiseEvent("homeEvent", "paramHome");
            });
    
       }
    function launchEvent1(){
        session.service("ALMemory").then(function (memory) {
                memory.raiseEvent("event1", "param1");
            });
    
       }
    function launchEvent2(){
        session.service("ALMemory").then(function (memory) {
                memory.raiseEvent("event2", "param2");
            });
    
       }
    function launchEvent3(){
        session.service("ALMemory").then(function (memory) {
                memory.raiseEvent("event3", "param3");
            });
    
       }
    

    在 choregraphe 上,单击“从 ALMemory 添加事件”(左侧的加号图标)并选择“添加新键”。给它你在 .js 文件中给它的名字(在我的例子中,event1、event2、event3 和 homeEvent)。

    这样,每当用户点击平板电脑上的按钮时,它都会触发事件,并将参数作为动态类型发送(参数 1、2 等,取决于用户按下的按钮)

    【讨论】:

      猜你喜欢
      • 2013-03-28
      • 2010-11-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 2019-08-02
      • 2018-05-21
      • 2012-06-05
      • 1970-01-01
      相关资源
      最近更新 更多