【问题标题】:Pepper robot: How to use tablet to send text input for further processing in Choregraphe?Pepper 机器人:如何使用平板电脑发送文本输入以在 Choregraphe 中进行进一步处理?
【发布时间】:2018-08-07 09:21:51
【问题描述】:

我需要通过集成平板电脑向机器人发送用户文本输入,并以某种方式捕获它,以便在 Choregraphe 中进行进一步处理。

在阅读 Aldebaran 关于 ALTabletService API 的文档后,我发现很少有方法可以解决所有这些问题。这些方法是 ALTabletService::showInputTextDialog 和 ALTabletService::onInputText,但不知何故我无法让它们工作:当我通过平板电脑输入一些文本时,它们完全没有返回任何内容。

我需要访问用户输入一段文本时创建的字符串。有什么建议吗?

【问题讨论】:

  • 考虑在您的问题中添加更多信息

标签: pepper choregraphe


【解决方案1】:

您可以为平板电脑创建一个网页并将其打包到您的应用程序中 - 请参阅documentation here;然后在该网页上,您可以创建一个文本输入字段(请注意屏幕的底部在选中字段时将被键盘隐藏),然后使用the javascript SDK(例如)培训输入的文本值,然后您可以从 Choregraphe 获取。

【讨论】:

  • 我知道你可以创建一个网页并使用 HTML/JavaScript 来创建一个对话框并获取输入值。如果我们没有获取输入文本值的方法,我无法理解ALTabletService::showInputTextDialog 的目的。你知道这是否可以做到吗?
  • 我刚刚看到可以用qi::Signal<int, std::string> ALTabletService::onInputText完成,但我还没有尝试过
【解决方案2】:

我在没有ALTabletService 方法showInputTextDialogonInputText 的情况下意识到了这一点

我的方法: 我制作了一个带有输入字段和发送输入的按钮的 html 页面。 在按下按钮时,我通过 QiMessaging Javascript 库使用来自 ALDialog docforceInput 方法。 doc

我现在无法对其进行测试,但这应该会有所帮助

function forceInput(input) {
    QiSession(function(session) {
        session.service('ALDialog').then(function(ALDialog) {
            ALDialog.forceInput(input);
        });
    }
}

现在您可以将输入发送到主题。 这可能类似于“imput_from_tablet blablabla”。 在 Dialog 中你会看到

u:(imput_from_tablet _*) $1

$1 应该是 blablabla。

希望有所帮助 最好的问候

【讨论】:

    【解决方案3】:

    我遇到了完全相同的问题,我在signal list 中找到了这个ALTabletService::onInputText 方法。您可以在同一页面上找到如何使用信号的示例。基于这些示例,我创建了以下脚本,该脚本可以从输入字段中获取值:

    import qi
    import sys
    
    def main(app):
        try:
            session = app.session
            tabletService = session.service("ALTabletService")
            tabletService.showInputTextDialog("Example dialog", "OK", "Cancel")
            signal_id = 0
    
            def callback(button_id, input_text):
                if button_id == 1:
                    print "'OK' button is pressed."
                    print "Input text: " + input_text
                if button_id == 0:
                    print "'Cancel' button is pressed"
    
                tabletService.onInputText.disconnect(signal_id)
                app.stop()
    
            # attach the callback function to onJSEvent signal
            signal_id = tabletService.onInputText.connect(callback)
            print "Signal ID: {}".format(signal_id)
    
            app.run()
        except Exception, e:
            print "Error was: ", e
    
    
    if __name__ == "__main__":
        ip = "10.0.10.254" # the IP of the robot
        port = 9559
    
        try:
            connection_url = "tcp://{}:{}".format(ip, port)
            app = qi.Application(url=connection_url)
            app.start()
        except RuntimeError:
            print("Can't connect to Naoqi.")
            sys.exit(1)
        main(app)
    

    【讨论】:

    • 如何修改按“确定”按钮后对话框仍会打开的代码?
    猜你喜欢
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多