2

I have a problem when using the ALDialog module on Python IDE and to load on Nao. I tried in different ways to load a dialogue but I always fall back on the same error.Runtimeerror LoadTopic::ALDialogIncorrect file myDialog.topIn the first case I write directly the text that I save in a. top file but at the time of LoadTopic () I have an error.In the second case I want to load the. top file by giving it the path. I come back to the same mistake again.Do you have a solution to my problem?Thank you very much.

import qi 
import argparse 
import os 
import sys 
from naoqi import ALProxy

def main(robot_ip, robot_port):

  dialog = """
  topic: ~myTopic() \n
  language: enu \n
  u:(test) hello \n """

  file = open("myDialog.top","w")
  file.write(dialog)
  file.close()
  # load topic
  proxy = ALProxy("ALDialog",robot_ip,robot_port)
  proxy.setLanguage("English")
  self.topic = proxy.loadTopic("myDialog.top")
  # start dialog
  proxy.subscribe("myModule")
  # activate dialog
  proxy.activateTopic(self.topic)

if name == "main": 

  parser = argparse.ArgumentParser()
  parser.add_argument("--ip", type=str, 
  default="169.254.245.164",help="Robot's IP address : '169.254.245.164'")
  parser.add_argument("--port", type=int, default=9559,help="port number, the default value is OK in most cases")                 
  args = parser.parse_args()
  main(args.ip, args.port)

1 Answers1

1

ALDialog.loadTopic expects an absolute filepath on the robot - it doesn't know anything about the context from which you're calling it (it could be from another computer, in which case of course it can't open that file). You need to be sure that your .top is indeed on the robot, and pass it's absolute path to ALDialog.

Once installed on the robot this path will be something like /home/nao/.local/share/PackageManager/apps/your-package-id/your-dialog-name/your-dialog-name_enu.top

Emile
  • 2,946
  • 2
  • 19
  • 22
  • Thank you, how can I find this absolute path? – Mathieu Perrotte Jan 24 '18 at 13:46
  • Something like home/nao/.local/share/PackageManager/apps/your-package-id/your-dialog-name/your-dialog-name_enu.top (I edited the answer) – Emile Jan 25 '18 at 14:55
  • All right, I understood the absolute path, but I still have the same mistake. How can I be sure that my top file is loaded into Nao? And the same for the absolute path? How can I be sure it's the right one? Thank you in advance – Mathieu Perrotte Jan 29 '18 at 10:20