def __init__(self, ip): self.s = Session() self.s.connect(ip) self.a_life = self.s.service('ALAutonomousLife') self.behavior_manager = self.s.service('ALBehaviorManager') self.is_recording_activity = False self.file = None
def __init__(self): self.connected = False self.session = Session() self.movePool1 = [ disco_right_hand, disco_left_hand, two_hand_air_pose, one_hand_air_pose, shaking_head_pose, rolling_hands_right, rolling_hands_left ] self.movePool2 = [ sprinkler_pose, shaking_booty, hands_up_down_pose, one_hand_air_rock_pose, hand_near_eyes_retro, leg_hand_slip_dance_move ] self.movePool3 = [ wave_move, egyptian_twist_move, squats_dance_move, duck_dance_move ] self.movePool4 = [ hand_near_eyes_retro_left, hand_near_eyes_retro_right, hand_near_eyes_retro, leg_twist_move, rolling_hands_left, rolling_hands_right ] self.movePool5 = [ rolling_hands_right, snap_right_move, snap_left_move, clapping_in_the_air, dance_move1, leg_hand_slip_dance_move ] self.movePool6 = [ hand_swinging, stamp_foot_move, two_hand_air_rock_pose, robot_dance_move, ] self.movePool7 = [kisses_pose, introduction_pose]
def __init__(self): self.connected = False self.session = Session() self.movePool1 = [ kisses_pose, introduction_pose, stretch1_pose, stretch2_pose, stretch3_pose, showMuscles1_pose, showMuscles2_pose ] # before starting self.movePool2 = [ sprinkler_pose, shaking_booty, hands_up_down_pose, one_hand_air_rock_pose, hand_near_eyes_retro, leg_hand_slip_dance_move ] self.movePool3 = [ wave_move, egyptian_twist_move, squats_dance_move, duck_dance_move, disco_right_hand, disco_left_hand, rolling_hands_right, rolling_hands_left ] self.movePool4 = [ hand_near_eyes_retro_left, hand_near_eyes_retro_right, hand_near_eyes_retro, leg_twist_move, rolling_hands_left, rolling_hands_right ] self.movePool5 = [ rolling_hands_right, snap_right_move, snap_left_move, clapping_in_the_air, dance_move1, leg_hand_slip_dance_move, shaking_head_pose ] self.movePool6 = [ hand_swinging, stamp_foot_move, two_hand_air_rock_pose, robot_dance_move, two_hand_air_pose, one_hand_air_pose ] self.movePool7 = [ kisses_pose, introduction_pose, winner_pose, winner2_pose, excited_pose, excited2_pose, lookHand_pose, proud_pose, happy_pose ] # for exiting
def fillLinksMap(address): global docURLRoot global naoqiVersion session = Session() session.connect('tcp://' + address + ':9559') system = session.service("ALSystem") naoqiVersion = system.systemVersion() if naoqiVersion[:3] == "2.3": docURLRoot = URL_2_3 elif naoqiVersion[:3] == "2.1": docURLRoot = URL_2_1 else: docURLRoot = URL_OTHER url = docURLRoot + "index.html" print "Parse : " + url html = urlopen(url).read() soup = BeautifulSoup.BeautifulSoup(html) elements = soup.findAll("li") for element in elements: key = element.text.split(' ', 1)[0] links = element.findAll("a") if len(links) > 1: # linksDicApi[key] = links[0]["href"] linksDicOverview[key] = links[1]["href"]
def _iter_services(address): session = Session() session.connect('tcp://' + address + ':9559') for servicesDesc in session.services(): module_name = servicesDesc["name"] if not module_name.startswith('_'): yield module_name, session.service(module_name)
def _iter_services(address): session = Session() session.connect('tcp://' + address + ':9559') print "Number of services : " + str(len(session.services())) for servicesDesc in session.services(): module_name = servicesDesc["name"] if not module_name.startswith( '_') and module_name not in BLACKLIST_MODULES: yield module_name, session.service(module_name)
def __init__(self, ip, root_dir='/tmp/log_watcher', message_start='', message_stop='No way this exists in the logs', message_category=''): self.s = Session() self.s.connect(ip) self.log_manager = self.s.service("LogManager") self.listener = self.log_manager.getListener() self.root_dir = root_dir self.signal_id = None self.file_path = None LogWatch.message_start = message_start LogWatch.message_stop = message_stop LogWatch.category_filter = message_category self.cb = log_callback
def set_robot_version(self): try: s = Session() s.connect(self.ip) system = s.service('ALSystem') version = system.systemVersion() split_version = version.split('.') if len(split_version) < 2: raise Exception( 'Wrong version format returned: {}'.format(version)) if split_version[0] < 2: raise Exception('Unhandled version: {}'.format(version)) if split_version[1] < 4: ### SHOULD test on 2.3 and predecessors raise Exception('Unhandled version: {}'.format(version)) self.version = int(split_version[1]) self.exact_version = version except Exception as e: print 'Version number processing went wrong: ' print e.message print 'Considering we run on 2.4' self.version = 4
def __init__(self, pointcloud=True, laserscan=False): self.pointcloud = pointcloud self.laserscan = laserscan # NaoqiNode.__init__(self, 'pepper_node') self.session = Session() self.session.connect('tcp://localhost:9559') # ROS initialization; self.connectNaoQi() # default sensor rate: 25 Hz (50 is max, stresses Nao's CPU) self.laserRate = rospy.Rate( rospy.get_param(self.PARAM_LASER_RATE, self.PARAM_LASER_RATE_DEFAULT)) self.laserShovelFrame = rospy.get_param( self.PARAM_LASER_SHOVEL_FRAME, self.PARAM_LASER_SHOVEL_FRAME_DEFAULT) self.laserGroundLeftFrame = rospy.get_param( self.PARAM_LASER_GROUND_LEFT_FRAME, self.PARAM_LASER_GROUND_LEFT_FRAME_DEFAULT) self.laserGroundRightFrame = rospy.get_param( self.PARAM_LASER_GROUND_RIGHT_FRAME, self.PARAM_LASER_GROUND_RIGHT_FRAME_DEFAULT) self.laserSRDFrontFrame = rospy.get_param( self.PARAM_LASER_SRD_FRONT_FRAME, self.PARAM_LASER_SRD_FRONT_FRAME_DEFAULT) self.laserSRDLeftFrame = rospy.get_param( self.PARAM_LASER_SRD_LEFT_FRAME, self.PARAM_LASER_SRD_LEFT_FRAME_DEFAULT) self.laserSRDRightFrame = rospy.get_param( self.PARAM_LASER_SRD_RIGHT_FRAME, self.PARAM_LASER_SRD_RIGHT_FRAME_DEFAULT) if self.pointcloud: self.pcShovelPublisher = rospy.Publisher(self.TOPIC_LASER_SHOVEL + 'pointcloud', PointCloud2, queue_size=1) self.pcGroundLeftPublisher = rospy.Publisher( self.TOPIC_LASER_GROUND_LEFT + 'pointcloud', PointCloud2, queue_size=1) self.pcGroundRightPublisher = rospy.Publisher( self.TOPIC_LASER_GROUND_RIGHT + 'pointcloud', PointCloud2, queue_size=1) self.pcSRDFrontPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_FRONT + 'pointcloud', PointCloud2, queue_size=1) self.pcSRDLeftPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_LEFT + 'pointcloud', PointCloud2, queue_size=1) self.pcSRDRightPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_RIGHT + 'pointcloud', PointCloud2, queue_size=1) if self.laserscan: self.laserShovelPublisher = rospy.Publisher( self.TOPIC_LASER_SHOVEL + 'scan', LaserScan, queue_size=1) self.laserGroundLeftPublisher = rospy.Publisher( self.TOPIC_LASER_GROUND_LEFT + 'scan', LaserScan, queue_size=1) self.laserGroundRightPublisher = rospy.Publisher( self.TOPIC_LASER_GROUND_RIGHT + 'scan', LaserScan, queue_size=1) self.laserSRDFrontPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_FRONT, LaserScan, queue_size=1) self.laserSRDLeftPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_LEFT, LaserScan, queue_size=1) self.laserSRDRightPublisher = rospy.Publisher( self.TOPIC_LASER_SRD_RIGHT, LaserScan, queue_size=1) self.laserSRDFrontPublisher_test = rospy.Publisher( "~/pepper_navigation/front", LaserScan, queue_size=1)
#!/usr/bin/env python # -*- coding: utf-8 -*- import cProfile if __name__ == '__main__': import cProfile from qi import Session s = Session() s.connect('localhost') dialog = s.service('ALDialog') cProfile.run('dialog._preloadMain()')
def session(robot_ip, port): """ Connect a session to a NAOqi """ ses = Session() ses.connect("tcp://" + robot_ip + ":" + str(port)) return ses