Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- encoding: UTF-8 -*-
  3.  
  4. """Example: Use showWebview Method"""
  5.  
  6. import qi
  7. import argparse
  8. import sys
  9. import time
  10.  
  11.  
  12. def main(session):
  13.     """
  14.    This example uses the showWebview method.
  15.    To Test ALTabletService, you need to run the script ON the robot.
  16.    """
  17.     # Get the service ALTabletService.
  18.  
  19.     try:
  20.         tabletService = session.service("ALTabletService")
  21.  
  22.         # Ensure that the tablet wifi is enable
  23.         tabletService.enableWifi()
  24.         # Ensure that the tablet wifi can connect to your network
  25.         tabletService.configureWifi("wpa2","pepper01","peppermat")
  26.         time.sleep(3)
  27.         # "your network name"
  28.         tabletService.connectWifi("pepper01")
  29.  
  30.         time.sleep(3)
  31.  
  32.         # Display a web page on the tablet "webpage"
  33.         tabletService.showWebview("https://bitbucket.org/hioarobotics/pepper-docs")
  34.  
  35.         time.sleep(50)
  36.  
  37.         # Display a local web page located in boot-config/html folder
  38.         # The ip of the robot from the tablet is 198.18.0.1
  39.         tabletService.showWebview("http://198.18.0.1/apps/boot-config/preloading_dialog.html")
  40.  
  41.         time.sleep(5)
  42.  
  43.         # Hide the web view
  44.         tabletService.hideWebview()
  45.     except Exception, e:
  46.         print "Error was: ", e
  47.  
  48.  
  49. if __name__ == "__main__":
  50.     parser = argparse.ArgumentParser()
  51.     parser.add_argument("--ip", type=str, default="192.168.43.163",
  52.                         help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
  53.     parser.add_argument("--port", type=int, default=9559,
  54.                         help="Naoqi port number")
  55.  
  56.     args = parser.parse_args()
  57.     session = qi.Session()
  58.     try:
  59.         session.connect("tcp://" + args.ip + ":" + str(args.port))
  60.     except RuntimeError:
  61.         print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
  62.                "Please check your script arguments. Run with -h option for help.")
  63.         sys.exit(1)
  64.     main(session)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement