How to use the qi.Session function in qi

To help you get started, we’ve selected a few qi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aldebaran / libqi / codegen / src / genalproxies.py View on Github external
def main(args):
  if len(args) != 3:
    print('Usage: %s URL DIR\n\t create AL specialized proxy for each live AL module, in DIR.' % args[0])
    return
  sd_url = args[1]
  prefix = args[2]
  abver = '.'.join(sys.version.split('.', 2)[0:2])
  me = os.path.dirname(os.path.abspath(__file__))
  lpath = me + '/../lib/python'+ abver + '/site-packages'
  sys.path.append(lpath)
  from qi import Session
  session = Session()
  session.connect(sd_url)
  services = session.services(0)
  names = map(lambda x: x[0], services)
  print(names)
  for s in names:
    if s[0] == '_':
      continue
    fname = s.lower() + 'proxy'
    paths = os.path.join(prefix, "alproxies", fname + '.h') + ',' + os.path.join(prefix, "src", fname + '.cpp')
    cmd = ['idl.py', sd_url + '/' + s, '--output-mode=alproxy', '-o', paths]
    os.system(' '.join(cmd))
github ros-naoqi / naoqi_bridge / naoqi_driver / nodes / naoqi_logger.py View on Github external
def __init__( self ):
        #Initialization
        NaoqiNode.__init__( self, self.NODE_NAME )

        from distutils.version import LooseVersion
        if self.get_version() < LooseVersion('2.0.0'):
            rospy.loginfo('The NAOqi version is inferior to 2.0, hence no log bridge possible')
            exit(0)

        rospy.init_node( self.NODE_NAME )

        # the log manager is only avaiable through a session (NAOqi 2.0)
        import qi
        self.session = qi.Session()
        self.session.connect("tcp://%s:%s" % (self.pip, self.pport))
        self.logManager = self.session.service("LogManager")

        self.listener = self.logManager.getListener()
        self.listener.onLogMessage.connect(onMessageCallback)
        rospy.loginfo('Logger initialized')
github maverickjoy / pepper-robot-programming / remote / remote_terminal.py View on Github external
def main(session):

    remote = Remote(session)
    remote.run()
    return

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="10.9.45.11",
                        help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
    parser.add_argument("--port", type=int, default=9559,
                        help="Naoqi port number")

    args = parser.parse_args()
    session = qi.Session()
    try:
        session.connect("tcp://" + args.ip + ":" + str(args.port))
    except RuntimeError:
        print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
               "Please check your script arguments. Run with -h option for help.")
        sys.exit(1)
    main(session)
github aldebaran / qibuild / python / qipkg / actions / deploy_package.py View on Github external
def _install_package(url, pkg_name, pkg_path):
    """ Install Package """
    # TODO: This will need NAOqi authentication
    try:
        import qi
        session = qi.Session()
        session.connect("tcp://%s:9559" % (url.host))
        package_manager = session.service("PackageManager")
        ui.info(ui.blue, "::", ui.reset, ui.bold, "Removing previous installation of the package")
        try:
            package_manager.removePkg(pkg_name)
        except Exception:
            pass
        ui.info(ui.blue, "::", ui.reset, ui.bold, "Installing package")
        ret = package_manager.install(
            "/home/%s/%s" % (url.user, os.path.basename(pkg_path)))
        ui.info("PackageManager returned:", ret)
    except ImportError:
        ui.error("Unable to install pkg, please install qi from pip and retry.")
github aldebaran / libqi / python / examples / qiclient.py View on Github external
def  main():
    """ Entry point of qiservice
    """
    session = qi.Session()
    f = session.connect("tcp://127.0.0.1:9559", _async=True)
    print("connected?", not f.hasError())

    #3 Get service serviceTest
    fut = session.service("serviceTest", _async=True)
    fut.addCallback(onServiceAvailable)

    obj = fut.value()

    #obj.testEvent.connect(onTestEvent)
    obj.testEventGeneric.connect(onTestEventGeneric)

    print("repl:", obj.call("reply", "plouf"))
    f = obj.reply("plaf", _async=True)
    f.addCallback(onReply)
github aldebaran / libqi / js / qim.py View on Github external
def on_open(self, info):
        global sid
        self.info = info
        self.sid = sid
        sid = sid + 1
        print("[%d] New connection from %s" % (self.sid, self.info.ip))
        self.qim = qi.Session()
        self.qim.connect(URL)
github aldebaran / naoqi_navigation_samples / tools / navigateLoop.py View on Github external
import qi
import sys

if __name__ == "__main__":
    ip = "127.0.0.1"
    if (len(sys.argv))==4:
        ip = sys.argv[1]
        firstID = sys.argv[2]
        secondID = sys.argv[3]
        session = qi.Session()
        session.connect("tcp://" + ip + ":9559")
        nav = session.service("ALNavigation")
        print "IP: " + ip
        print "NavigateToInMap from " + firstID + " point to "+ secondID
        while True:
          path = nav.getExplorationPath()
          try:
              print " NavigateTo " + firstID
              first = path[int(firstID)]
              boo = nav.navigateToInMap(first[0], first[1])

              print " NavigateTo " + secondID
              last = path[int(secondID)]
              boo4 = nav.navigateToInMap(last[0], last[1])

          except Exception, e: