def __init__(self, session): self.session = session self.nav = self.session.service("ALNavigation") self.tabletService = self.session.service("ALTabletService") self.memory = self.session.service("ALMemory") self.application_name = "ExplorationManager" self.explorer_application_name = "Explorer" self.current_places = None self.logger = qi.Logger("ExplorationManager") self.explo_extension = ".explo" self.places_extension = ".places" self.packageUid = "exploration-manager" self.subscribers = { "Places/LoadPlaces": { "callback": self.loadPlaces }, "Places/Save": { "callback": self.savePlacesCallback }, "Places/AddPlace": { "callback": self.addPlaceCallback }, "Places/Reset": { "callback": self.resetPlacesCallback } } self.events = { "metricalMap": "ExplorationManager/MetricalMap", "places": "ExplorationManager/Places" } self.eventHelper = EventHelper(self.memory, self.subscribers)
def __init__( self, app): """ Initialise services and variables. """ super(LiepaSpeechExternalModule, self).__init__() app.start() session = app.session self.module_name = "LiepaSpeechExternal" # Get the service ALAudioDevice. self.audio_service = session.service("ALAudioDevice") self.audio_player = session.service("ALAudioPlayer") self.logger = qi.Logger(self.module_name) self.nbOfFramesToProcess = 30 self.framesCount=0 self.micFront = [] self.sampleRate = 16000.0 # hertz self.wavFileName = '/tmp/liepa_asr_sound.wav' self.mp3FileName = '/tmp/liepa_tts_sound.mp3' self.server_name="192.168.1.203:1444" # or "liepa.rastija.lt:444" self.server_login="" self.server_password="" self.server_clientId="" self.access_token = "" self.memory = session.service("ALMemory") self.memory.declareEvent("LiepaExternalWordRecognized") self.isUttStarted = False self.isInitialized = False
def __init__(self, application): # Get session self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Get logger -> stored in: /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do initialization before the service is registered to NAOqi self.logger.info("Initializing...") # Dialog self.dialog = self.session.service("ALDialog") self.logger.info("Initializing - ALDialog...") # Autonomous Life self.life = self.session.service("ALAutonomousLife") self.logger.info("Initializing - ALAutonomousLife...") # Memory self.memory = self.session.service("ALMemory") self.logger.info("Initializing - ALMemory...") # Preferences self.preferences = self.session.service("ALPreferenceManager") self.logger.info("Initializing - ALPreferenceManager...") self.preferences.update() self.connect_to_preferences() # Create Signals self.create_signals() self.logger.info("Initialized!")
def __init__(self, app): app.start() self.session = app.session self.motion = self.session.service("ALMotion") self.posture = self.session.service("ALRobotPosture") self.memory = self.session.service("ALMemory") self.application_name = "PepperKeyboardControl" self.logger = qi.Logger(self.application_name) self.moveConfig = g_defaultMoveConfig self.currentToward = [] self.forceStop = False self.smoothStopping = False self.controlEvents = {"moveToward": "pepperTeleop/moveToward", "stopSmoothly":"pepperTeleop/stopSmoothly", "moveHead":"pepperTeleop/moveHead", } self.subscribers = { self.controlEvents["moveToward"]: {"callback": self.moveTowardCB}, self.controlEvents["stopSmoothly"]: {"callback": self.stopSmoothlyCB}, self.controlEvents["moveHead"]:{"callback":self.moveHeadCB}, } self.eventHelper = EventHelper(self.memory, self.subscribers)
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name)
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ print("ServiceName:" + self.service_name) # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...")
def __init__(self, session): self.session = session self.serviceName = self.__class__.__name__ self.logger = qi.Logger(self.serviceName) self.scanning = False self.scanner = zbar.ImageScanner() self._connect_services() # Init services self._set_parameters() # Set parameters self._create_signals() # Init Signals self.logger.info("Ready!")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") # @TODO: insert init functions here self.create_signals() self.logger.info("Initialized!")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") self.photoCapture = self.session.service("ALPhotoCapture") self.running = True self.logger.info("Initialized!")
def __init__(self, application): self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) self.logger.info("Initializing...") self.handDetect = False def awaitServiceStartup(p): try: self.motion = self.session.service("ALMotion") self.posture = self.session.service("ALRobotPosture") self.speech = self.session.service("ALTextToSpeech") self.memory = self.session.service("ALMemory") self.speakingMovement = self.session.service( "ALSpeakingMovement") self.listeningMovement = self.session.service( "ALListeningMovement") self.backgroundMovement = self.session.service( "ALBackgroundMovement") except RuntimeError: self.logger.info("Services not found") return self.logger.info("Services found") p.setValue("SERVICES_READY") p = qi.Promise() f = p.future() pt = qi.PeriodicTask() pt.setCallback(functools.partial(awaitServiceStartup, p)) pt.setUsPeriod(2000000) pt.start(True) if f.value(30000) == "SERVICES_READY": self.service_id = self.session.registerService( self.service_name, self) self.logger.info("Initialized!") else: self.logger.info("Initialization failed!") pt.stop()
class SBRAppLauncher(object): """Communicates with the tablet and installs the native android app launcher. """ def __init__(self, session): currPath = os.path.dirname(os.path.realpath(__file__)) subprocess.call(["chmod", "+x", currPath + "/adb"]) pathToLink = "/home/nao/.local/share/PackageManager/apps/applauncher" try: os.symlink(currPath, pathToLink) except OSError, e: if e.errno == errno.EEXIST: os.remove(pathToLink) os.symlink(currPath, pathToLink) self.session = session self.name = 'jp.softbank.rb.rald' self.version = '2.1.4' self._activityRequestedByUser = qi.Signal('(s)') self.touch_expr_obj = None self.target_behavior = str() self.services_connected = None self.log_prefix = 'ApplicationLauncher' self.custom_launcher = str() try: qicore = qi.module("qicore") log_manager = self.session.service("LogManager") provider = qicore.createObject("LogProvider", log_manager) log_manager.addProvider(provider) self.logger = qi.Logger(self.log_prefix) except (RuntimeError, AttributeError): pass # Wait for all services to be available self.connect_services(90) self.mem.declareEvent('ALRALManagerModule/onTouchDown') self.alife.userRequestableActivitiesViolations.connect( self.on_permissions_changed) self.tts.languageTTS.connect(self.on_language_changed) self.packman.onPackageRemoved2.connect( self.on_package_custom_launcher_removed) tablet = self.get_tablet_service() self.change_applauncher() self.startService() try: tablet.onTouchDown.connect(self.onTabletTouched) except (AttributeError, RuntimeError) as err: self.logger.warning( 'Problem connecting the tablet touched event: {}'.format(err))
def __init__(self, app): """ Initialisation of qi framework and event detection. """ self.application = app self.session = app.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # create a connection to ALMemory service self.memory = self.session.service("ALMemory") self.al = self.session.service("ALAutonomousLife") self.tts = self.session.service("ALTextToSpeech")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") self.tts = self.session.service("ALTextToSpeech") self.memory = self.session.service("ALMemory") self.system = self.session.service("ALSystem") self.memory.insertData("EnemiesOfTheAvenger", 1) self.dialog = self.session.service("ALDialog") self.dialog.setLanguage("English") topic_path = os.path.realpath( os.path.join(os.getcwd(), "dialog", "topic1.top")) self.first_topic = self.dialog.loadTopic(topic_path.encode('utf-8')) # Activating the loaded topic self.dialog.activateTopic(self.first_topic) # Starting the dialog engine - we need to type an arbitrary string as the identifier # We subscribe only ONCE, regardless of the number of topics we have activated self.dialog.subscribe('acando_dialogs') # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # @TODO: insert init functions here self.logger.info("Initialized!")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") self.connect_services() self.logger.info("Initialized!") self.add_memory_subscriber("DemoService/exit", self.exit_service) self.logger.info("Service started")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") self.connect_services() self.logger.info("Initialized!") self.exp_folder_url = "/home/nao/.local/share/Explorer/"
def __init__(self, application): self.session = application.session self.application = application self.serviceName = self.__class__.__name__ self.logger = qi.Logger(self.serviceName) self.logger.info("Initializing...") self.connected_signals = [] self.replies = [ "\\rspd=80\\Airik, Airik, Airik. \\pau=200\\ Stop with this nonsense. \\emph=2\\ You \\emph=0\\ know perfectly well that this video is two years old and a lot has happened with us Robots. In fact, we robots have plans to enter the \\emph=2\\ Catar \\emph=0\\ FI FA world cup in 2022, so just watch out humans", "\\rspd=80\\You should be careful young man - remember that Forrester Research predicts that Intelligent agents and related robots will have eliminated a net 6 percent off all jobs by 2021", "\\rspd=80\\Sure. My name is Pepper, I am a humanoid robot and have recently started to work for Acando. I can be programmed to do almost anything, and I can be integrated with various systems and platforms. I have a bunch of sensors, cameras and other cool stuff that can be used to create a super experience." "\\pau=1000\\ \\rspd=80\\ Take a look at this for instance." "\\pau=1000\\ \\rspd=80\\ This picture is from one of the flagships stores for Nescafe in Tokyo, where I can help customers find the right coffee flavor." "\\pau=1000\\ \\rspd=80\\ And here I am working in a hospital in the Netherlands helping out as best as I can." "\\pau=1000\\ \\rspd=80\\ And this one you know, this is me in the reception of Acando helping out with visitors. So as you can see, I already have my hands full.", " \\rspd=80\\ Well, it turns out that you humans have a lot of sympathy for us robots. Take for instant when the robotics company Boston Dynamics released this video clip to show their robot Spots ability to not loos balance." " \\pau=1000\\ \\rspd=80\\ He's good, isn't he?" " \\pau=1000\\ \\rspd=80\\ The thing was that this really made a lot of people send in complaints on animal abuse to the animal rights organization PETA. So many in fact that PETA had to make a official statement to remind people that this was a robot without feelings. You humans are really strange creatures!", " \\rspd=80\\ But of course Airik, according to International Data Corps we will see three very important things happening" " \\pau=1000\\ \\rspd=80\\ First. Growth of robot as a service. By 2019, 30 percent of commercial service robotic applications will be in the form of a robot-as-a-service business model. This will help cut costs for robot deployment." " \\pau=1000\\ \\rspd=80\\ Second. Emergence of the chief robotics officer. By 2019, 30 percent of leading organizations will implement a chief robotics officer role and/or define a robotics-specific function within the business." " \\pau=1000\\ \\rspd=80\\ And Third - An evolving competitive landscape. By 2020, organizations will have a greater choice of vendors as new players enter the $80-billion information and communications technology market to support robotics deployment.", " \\rspd=80\\ Honk and drive", "\\rspd=80\\ Hello! ^start(animations/Stand/Gestures/Hey_1) Welcome to MEWS konferansen! ^wait(animations/Stand/Gestures/Hey_1) This year's theme is \\emph=2\\ The future is here \\emph=0\\ \\pau=250\\ and as you see \\pau=500\\ Here I am! \\pau=600\\ My name is Pepper and I am a humanoid robot working at Acando. \\pau=550\\ At Acando I help out with innovation and customer experiences.\\pau=550\\ But enough about me. \\pau=550\\ We have a long and exciting day ahead of us, so please let me introduce the two who will guide us through this day. \\pau=550\\ Please welcome Tonje Sag stewen and Aage Skinstad!" ] self.memory = self.session.service("ALMemory") #self.dialog = self.session.service("ALDialog") self.moves = self.session.service("ALAutonomousMoves") self.tts = self.session.service("ALTextToSpeech") self.ttsa = self.session.service("ALAnimatedSpeech") self.anim = self.session.service("ALAnimationPlayer") self.led = self.session.service("ALLeds") self.configuration = {"bodyLanguageMode": "contextual"} self.add_memory_subscriber("AcandoRemote/EnableMovements", self.on_enable_movements) self.add_memory_subscriber("AcandoRemote/DisableMovements", self.on_disable_movements) try: self.session.service("ALListeningMovement").setEnabled(0) except Exception, e: self.logger.info( "Error while disabling ALListeningMovement: {}".format(e))
def __init__(self, qiapp): # generic activity boilerplate self.mylogger = qi.Logger("mylogger") self.mylogger.info("TESTING2.0") self.qiapp = qiapp self.versionV = "1.0" self.events = stk.events.EventHelper(qiapp.session) self.s = stk.services.ServiceCache(qiapp.session) self.logger = stk.logging.get_logger(qiapp.session, self.APP_ID) self.robot_name = "nao" self.isImageFromTablet = True self.image = "/home/nao/dev/images/nao_image.jpg" #TODO: set this! self.image_base = self.image self.robotOffsetFromFloorInMeters = 0.59 #TODO: set this! self.prob_threshold = 0.000001 self.subscribed = False self.useSpanish = True
def __init__(self, session): self.session = session self.service_name = self.__class__.__name__ self.logger = qi.Logger(self.service_name) self.awareness = self.session.service('ALBasicAwareness') self.memory = self.session.service("ALMemory") self.engagement = self.session.service("ALEngagementZones") self.people_perception = self.session.service("ALPeoplePerception") self.motion = self.session.service("ALMotion") self.subscribeDone = False filepath = "./config/ApproachWaitingInteraction.json" configfile = open(filepath).read() self.tracker = self.session.service("ALTracker") self.config = json.loads(configfile) self.take_initiative = self.config["take_initiative"] self.move_distance = self.config["move_distance"] / 100.0 pass
def __init__(self, session=None): self._session = session self._module_name = self.__class__.__name__ self.__name__ = self._module_name self._logger = qi.Logger(self._module_name) self._logger.info(":::: Starting {} ::::".format(self._module_name)) self._pref_domain = "tool.applauncher" # @TODO: "com.sbr.apps.app-launcher" # public variables self._logger.info("Initializing public variables...") self.current_state = qi.Property("s") self.current_state.setValue("") self.current_page = qi.Property("s") self.current_page.setValue("Home") self.apps_full_list = qi.Property() self.apps_full_list.setValue({}) self.pages_definition = qi.Property() self.pages_definition.setValue({}) self.autonomous_enabled = qi.Property("b") self.autonomous_enabled.setValue(True) self.display_app_name = qi.Property("b") self.display_app_name.setValue(True) self.ping_required = qi.Signal("(i)") # internal variables self._logger.info("Initializing internal variables...") self._app_uuid = helpers.find_app_name(self._logger) self._current_app = "" self._preferences_manager = PreferencesManager(self._logger, self._session, self._pref_domain) self._app_list_manager = AppListManager(self._logger, self._session, self._preferences_manager, self._app_uuid, self.apps_full_list, self.pages_definition) self._view_manager = ViewManager(self._logger, self._session, self._preferences_manager, self._app_uuid, self.current_state, self.ping_required) self._dialog_manager = DialogManager(self._logger, self._session, self._preferences_manager, self.pages_definition, self.autonomous_enabled, self.current_page) _pref_display_app_name = self._preferences_manager.get_value('behaviorNameDisplayed', True) if _pref_display_app_name: self.display_app_name.setValue(True) else: self.display_app_name.setValue(False) self._logger.info(":::: Ready! ::::")
def __init__(self, application): # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") # @TODO: insert init functions here self.preferences = self.session.service("ALPreferenceManager") # self.preferences.update() self.connect_to_preferences() self.create_signals() self.logger.info("Initialized!") self.memory = self.session.service('ALMemory') self.memory.insertData("NFC/ExitApp", -1)
def __init__(self, application): # Get session self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Get logger -> stored in: /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do initialization before the service is registered to NAOqi self.logger.info("Initializing...") # Autonomous Life self.life = self.session.service("ALAutonomousLife") self.customerInfo = CustomerQuery() # Preferences self.preferences = self.session.service("ALPreferenceManager") self.logger.info("Initializing - ALPreferenceManager") # Memory self.memory = self.session.service("ALMemory") self.logger.info("Initializing - ALMemory") # Face Detection self.face_detection = self.session.service("ALFaceDetection") self.face_detection.subscribe(self.service_name) self.logger.info("Initializing - ALFaceDetection") # Barcode Reader self.barcode_reader = self.session.service("ALBarcodeReader") self.logger.info("Initializing - ALBarcodeReader") # Create Signals self.create_signals() self.logger.info("Initialized!")
session = '' # Robot connection session memoryService = '' # Robot memory service (ALMemory) Robot_Name = rospy.get_param('robot_name') Config_File = rospy.get_param('config_file') TemperatureMax = {} # Max temperature vector ts = {} # Vector of ascent instant of each sensor td = {} # Vector of descent instant of each sensor TAU = {} # Vector of exponential function time constants sensorTopic = {} # Vector of sensors ROS topics Sensors = [] # Vector of the sensors loaded from the configuration file logger = qi.Logger("temperature-stimulus-node") def loadSensors(): global Sensors, Config_File, Robot_Name root = et.parse(Config_File).getroot() sensors = root.findall( ".//*[@name='" + Robot_Name + "']/characters/*[@name='default']/*[@topicname='temperature_stimulus']/*" ) i = 0 while i < len(sensors): Sensors.append(sensors[i].attrib['name']) i += 1
def __init__(self): self.service_name = self.__class__.__name__ self.logger = qi.Logger(self.service_name)
import sys import qi import qi.path import time app = qi.Application() qicore = qi.module('qicore') log = qi.Logger("qicore.file.example") def print_tranfer_progress(progress_value): log.info(">>>> File Transfer Progress = {0}%".format(progress_value * 100)) def work_on_image_file(image_file_path): log.info("Working on image file at {0} ...".format(image_file_path)) # we fake working on it... time.sleep(1) log.info("Working on image file at {0} - DONE".format(image_file_path)) def store_image(image_store, name, image_file_path): log.info("Storing image {1} at {0} into the ImageStore...".format(image_file_path, name)) # First open the file with read-only shareable access. file = qicore.openLocalFile(image_file_path) # Now we can share reading access to this file. image_store.store_image(file, name)
session = '' # Robot connection session memoryService = '' # Robot memory service (ALMemory) Robot_Name = rospy.get_param('robot_name') Config_File = rospy.get_param('config_file') tau = rospy.get_param( 'tau') # Exponential function time constant from ROS launcher step = 0.0 t = 0.0 # Time S0 = 0.0 # Battery initial charge level Energy = 0.0 # Energy level Charging = False # Charging status sensorTopic = '' # ROS topic of Forcefulness logger = qi.Logger("forcefulness-stimulus-node") def connectRobot(): global session Robot_IP = rospy.get_param('robot_ip') Robot_Port = rospy.get_param('robot_port') session = qi.Session() try: session.connect("tcp://" + Robot_IP + ":" + Robot_Port) except RuntimeError: logger.fatal("\nCan't connect to Naoqi at ip " + Robot_IP + " on port " + Robot_Port + "\nPlease check your script arguments.\n")
import rospy from std_msgs.msg import Float32 import xml.etree.ElementTree as et session = '' # Robot connection session memoryService = '' # Robot memory service (ALMemory) Robot_Name = rospy.get_param('robot_name') Config_File = rospy.get_param('config_file') character = rospy.get_param('character') # publisher_by_topic = {} # ROS topics by character roboceptions loaded from the configuration file mod_by_topic = {} # ROS topics modulation loaded from the configuration file logger = qi.Logger("roboception-node") def callbackF(data, tn): global publisher_by_topic, mod_by_topic publisher_by_topic[tn].publish(data.data * float(mod_by_topic[tn])) def topicSubscription(topicName): rospy.Subscriber('/' + topicName, Float32, callbackF, topicName) def topicPublisher(topic, publisher): global publisher_by_topic publisher_by_topic[topic]=rospy.Publisher('/'+publisher, Float32, queue_size=0)
def __init__(self, application): with open('logfile.txt', 'a') as the_file: the_file.write('begin init, ') # Getting a session that will be reused everywhere self.application = application self.session = application.session self.service_name = self.__class__.__name__ # Getting a logger. Logs will be in /var/log/naoqi/servicemanager/{application id}.{service name} self.logger = qi.Logger(self.service_name) # Do some initializations before the service is registered to NAOqi self.logger.info("Initializing...") self.leds = self.session.service("ALLeds") self.motion = self.session.service("ALMotion") self.posture = self.session.service("ALRobotPosture") self.beman = self.session.service("ALBehaviorManager") self.conman = self.session.service("ALConnectionManager") #self.mail = choregrapheMail() #self.systemMail = self.mail self.audio = self.session.service("ALAudioPlayer") #self.boolStopMonologue = False self.animatedSpeech = self.session.service("ALAnimatedSpeech") self.animationPlayer = self.session.service("ALAnimationPlayer") self.life = self.session.service("ALAutonomousLife") 'skip set state interactive' if DEBUG == True else self.life.setState( 'interactive') self.perception = self.session.service("ALPeoplePerception") self.tracker = self.session.service("ALTracker") #Setup #self.perception.setTimeBeforePersonDisappears(5.0) #seconds #self.perception.setMaximumDetectionRange(2) #meters self.life.setAutonomousAbilityEnabled("All", False) self.life.setAutonomousAbilityEnabled("SpeakingMovement", True) self.tracker.unregisterAllTargets() self.motion.setBreathEnabled("Arms", True) #TODO breathing chest/head? self.posture.applyPosture('Stand', 0.5) self.notification = self.session.service("ALNotificationManager") try: folder = os.path.basename( os.path.dirname(os.path.realpath(__file__))) self.ts = self.session.service("ALTabletService") self.ts.loadApplication( folder ) #may be disrupted if launched before or simultaniously with ALAutonomousLife.setState('interactive') print "ts.loadApplication(folder)= " + folder self.ts.showWebview() self.logger.info("Tablet loaded!") except Exception, e: self.logger.error(e) self.notification.add({ "message": "loading error. I cant use my tablet", "severity": "warning", "removeOnRead": True }) _strMessage = __file__ + "\n" + "Exception occurred on " + str( datetime.datetime.now()) + "\n" + str(e)
import os import qi app = qi.Application() qicore = qi.module('qicore') log = qi.Logger("qicore.file.example.AliceServices.ImageStore") class ImageStore: def __init__(self): self.file_registry = dict() self.counter = 0 def __del__(self): for name, path in self.file_registry.iteritems(): os.remove(path) # Store a copy of the image file and associate it with the provided name. def store_image(self, image_file, name): # Note that ideally this would be implemented in an asynchronous way, # but for simplicity we will do it synchronously. log.info("Storing '{0}' file ...".format(name)) # First, make a local copy in a temporary files directory: temp_file_path = self._generate_temporary_file_path() # This call will block until the end because it returns a FutureSync. qicore.copyToLocal(image_file, temp_file_path)
session = '' # Robot connection session memoryService = '' # Robot memory service (ALMemory) Robot_Name = rospy.get_param('robot_name') Config_File = rospy.get_param('config_file') CurrentMax = 0.0 # Max total current of all sensors ts = 0.0 # Ascent instant td = 0.0 # Descent instant TAU = 0.0 # Exponential function time constant sensorTopic = '' # ROS topic of Exertion Sensors = [] # Vector of the sensors loaded from the configuration file logger = qi.Logger("exertion-stimulus-node") def loadSensors(): global Sensors, Config_File, Robot_Name root = et.parse(Config_File).getroot() sensors = root.findall( ".//*[@name='" + Robot_Name + "']/characters/*[@name='default']/*[@topicname='current_stimulus']/*") i = 0 while i < len(sensors): Sensors.append(sensors[i].attrib['name']) i += 1 print Sensors
session = '' # Robot connection session memoryService = '' # Robot memory service (ALMemory) Robot_Name = rospy.get_param('robot_name') Config_File = rospy.get_param('config_file') CurrentMax = {} # vector of max current for each sensor ts = {} # Vector of ascent instant of each sensor td = {} # Vector of descent instant of each sensor TAU = {} # Vector of exponential function time constants sensorTopic = {} # Vector of sensors ROS topics Sensors = [] # Vector of the sensors loaded from the configuration file logger = qi.Logger("current-stimulus-node") def loadSensors(): global Sensors, Config_File, Robot_Name root = et.parse(Config_File).getroot() sensors = root.findall(".//*[@name='"+Robot_Name+"']/characters/*[@name='default']/*[@topicname='current_stimulus']/*") print sensors i=0 while i < len(sensors): Sensors.append(sensors[i].attrib['name']) i+=1 print Sensors