def configure(self, rf):
        """Configure the module according to the configuration file

		Args: 
			rf (string): name of the configuration file of the module. 
				This file must be include in the folder pointing to the yarp
				contexts. By default: rf = 'default.ini'
		"""

        self.handlerPort.open("/ErgonomicAssessmentModule")
        self.attach(self.handlerPort)

        self.in_port_posture = yarp.BufferedPortBottle()
        self.in_port_posture.open('/ergo_pred/posture:i')

        path_config_posture = rf.find('posture_config').toString()
        self._posture = HumanPosture(path_config_posture)

        path_config_ergo = rf.find('ergo_config').toString()
        self._ergo_assessment = ErgoAssessment(path_config_ergo)

        self.list_out_port_ergo = dict()

        for ergo_score in self._ergo_assessment.get_list_score():
            self.list_out_port_ergo[ergo_score] = yarp.BufferedPortBottle()
            self.list_out_port_ergo[ergo_score].open("/ergo_pred/" +
                                                     ergo_score.lower() + ':o')

        return True
Exemple #2
0
    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self)
        # we update the probability at 100 Hz
        self.__timer = QTimer()
        self.__timer.timeout.connect(self.update_probabilities)
        self.__timer.start(10)  # every 10 ms

        # Port for initialization of center of mass position
        self.InitButton.clicked.connect(self.initialize_com)
        self.port_init = yarp.BufferedPortBottle()
        self.port_init.open('/reco_gui/init_com:o')
        self.activity = yarp.Network.connect('/reco_gui/init_com:o',
                                             '/processing/init_com:i')

        # Prepare yarp ports
        self.activity_input = '/activity_recognition/probabilities:o'
        self.port_activity = yarp.BufferedPortBottle()
        self.port_activity.open('/gui/probabilities')

        yarp.Network.connect(self.activity_input, self.port_activity.getName())

        self.contact_input = '/DetectionContact'
        self.port_contact = yarp.BufferedPortBottle()
        self.port_contact.open('/gui/contact')
        self.cback = CallbackData(1)
        self.port_contact.useCallback(self.cback)

        self.contact = yarp.Network.connect(self.contact_input,
                                            self.port_contact.getName())

        self.flag_init = 0
Exemple #3
0
    def configure(self, rf):
        """Configure the module according to the configuration file

		Args: 
			rf (string): name of the configuration file of the module. 
				This file must be include in the folder pointing to the yarp
				contexts. By default: rf = 'default.ini'
		"""

        self.handlerPort.open("/AE_Module")
        self.attach(self.handlerPort)

        self.in_port_posture = yarp.BufferedPortBottle()
        self.in_port_posture.open('/AE/posture:i')

        path_AE = rf.find('path_AE').toString()

        with open(path_AE, 'rb') as input:
            self._autoencoder = pickle.load(input)

        self.out_port_reconstruct = yarp.BufferedPortBottle()
        self.out_port_reconstruct.open("/AE/reconstruct:o")

        self.out_port_latent = yarp.BufferedPortBottle()
        self.out_port_latent.open("/AE/latent:o")

        return True
Exemple #4
0
def port_setup(robot_name):
    """ Open the input and output ports."""
    global local_in_port
    global local_out_port

    global local_in_port_name
    global local_out_port_name

    global ors_in_port_name
    global ors_out_port_name

    # Define the names for all the ports
    port_prefix = "/ors/robots/" + robot_name + "/"
    local_port_prefix = "/pa10_client/" + robot_name + "/"

    ors_in_port_name = port_prefix + "OBPA-10/in"
    ors_out_port_name = port_prefix + "out"

    local_in_port_name = local_port_prefix + "in/"
    local_out_port_name = local_port_prefix + "out/"

    # Start the yarp network connection
    yarp.Network.init()

    # Open the client ports
    local_in_port = yarp.BufferedPortBottle()
    local_in_port.open(local_in_port_name)
    local_out_port = yarp.BufferedPortBottle()
    local_out_port.open(local_out_port_name)

    # Connect the client ports to the simulator ports
    yarp.Network.connect(local_out_port_name, ors_in_port_name)
    yarp.Network.connect(ors_out_port_name, local_in_port_name)
    def __init__(self):
        yarp.RFModule.__init__(self)
        self.xtionResolution = (640, 480)
        # Define port variable to recive an image from Teo's camera
        self.xtionImagePort = yarp.BufferedPortImageRgb()
        # Create numpy array to receive the image
        self.xtionImageArray = np.zeros(
            (self.xtionResolution[1], self.xtionResolution[0], 3),
            dtype=np.uint8)

        self.xtionObjectDetectionsPort = yarp.BufferedPortBottle()

        self.glassesImagePort = yarp.BufferedPortImageRgb()
        self.glassesResolution = (1080, 1080)
        self.glassesImageArray = np.zeros(
            (self.glassesResolution[1], self.glassesResolution[0], 3),
            dtype=np.uint8)
        self.minConfidenceDetection = 0.9
        self.triggerProb = 0.7
        self.cropsResolution = (120, 120)

        self.glassesDataPort = yarp.BufferedPortBottle()

        self.tripletModel = None
        self.embeddingModel = None

        # Output Ports
        self.fixationObjectPort = yarp.Port()
        self.fixationObjectImagePort = yarp.BufferedPortImageRgb()
        self.glassesCropImagePort = yarp.BufferedPortImageRgb()
        self.detections = yarp.Bottle()
        self.bottleData = yarp.Bottle()
        self.count_not_detections = 0
        self.max_count_not_detections = 10
        self.rightObject = False

        if robot == '/teo':
            self.xtionImagePortName = "/xtion/rgbImage"
        elif robot == '/teoSim':
            self.xtionImagePortName = "/teoSim/camera/rgbImage"

        self.xtionObjectDetectionPortName = "/rgbdObjectDetection/state"
        self.glassesImagePortName = "/glassesServer/images"
        self.glassesDataPortName = "/glassesServer/data"

        self.fixationObjectPortName = "/object"
        self.fixationObjectImagePortName = "/rgbImage"
        self.glassesCropImagePortName = "/Glassescrop"

        # Categories
        self.categories = None
        self.previous_category = 0
        self.glassesCropImages = []
        self.allDetectionsInWindowFrames = []
        self.allDetectionsLabelsInWindowFrames = []

        self.period = 0.01
        self.timeToGrop = 0
        self.numberOfFramesJustOneObject = 0
Exemple #6
0
	def configure(self, rf):
		self.handlerPort.open("/ActivityRecognitionModule")
		self.attach(self.handlerPort)

		self.list_port = []
		self.cback = []

		path_model = rf.find('path_model').toString()
		name_model = rf.find('name_model').toString()
		self.statePort = yarp.BufferedPortBottle()
		self.statePort.open('/activity_recognition/state:o')
		self.probPort = yarp.BufferedPortBottle()
		self.probPort.open('/activity_recognition/probabilities:o')
		self.model = ModelHMM()
		self.model.load_model(path_model + '/' + name_model)
		self.list_states = self.model.get_list_states()
		self.buffer_model = [[]]

		size_buffer = int(rf.find('size_buffer').toString())

		signals = rf.findGroup("Signals").tail().toString().replace(')', '').replace('(', '').split(' ')
		nb_port = int(len(signals))
		nb_active_port = 0

		for signal in signals:
			info_signal = rf.findGroup(signal)
			is_enabled = int(info_signal.find('enable').toString())

			if(is_enabled):
				list_items = info_signal.findGroup('list').tail().toString().split(' ')
				input_port_name = info_signal.find('output_port').toString()

				if(input_port_name == ''):
					input_port_name = info_signal.find('input_port').toString()

				if((list_items[0] == 'all') or (list_items[0] == '')):
					self.list_port.append(yarp.BufferedPortBottle())
					self.list_port[nb_active_port].open("/activity_recognition" + input_port_name + ':i')
					self.cback.append(CallbackData(size_buffer))
					self.list_port[nb_active_port].useCallback(self.cback[nb_active_port])
					yarp.Network.connect("/processing" + input_port_name + ':o', self.list_port[nb_active_port].getName())
					nb_active_port += 1
					self.buffer_model.append([])

				else:
					for item in list_items:
						self.list_port.append(yarp.BufferedPortBottle())
						self.list_port[nb_active_port].open("/activity_recognition" + input_port_name + '/' + item + ':i')
						self.cback.append(CallbackData(size_buffer))
						self.list_port[nb_active_port].useCallback(self.cback[nb_active_port])
						self.buffer_model.append([])
						yarp.Network.connect("/processing" + input_port_name + '/' + item  + ':o', self.list_port[nb_active_port].getName())
						nb_active_port += 1


		self.flag_model = np.zeros(nb_active_port)
		self.obs = []

		return True
 def test_open_and_connect(self):
     p = yarp.BufferedPortBottle()
     p2 = yarp.BufferedPortBottle()
     self.assertTrue(p.open("/python/out"))
     self.assertTrue(p2.open("/python/in"))
     self.assertTrue(yarp.Network.connect(p.getName(), p2.getName()))
     p.close()
     p2.close()
def port_setup():
	global local_in_port
	global local_out_port

	yarp.Network.init()

	local_in_port = yarp.BufferedPortBottle()
	local_in_port.open(local_in_port_name)
	local_out_port = yarp.BufferedPortBottle()
	local_out_port.open(local_out_port_name)

	yarp.Network.connect (local_out_port_name, ors_in_port_name)
	yarp.Network.connect (ors_out_port_name, local_in_port_name)
    def __init__(self, list_port):
        self.input_port = []
        self.port = []

        plt.ion()

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111, projection='3d')

        data = np.zeros((2, 66))

        color = ['b', 'r']
        self.lines = []
        self.skeleton = []

        self.skeleton = Skeleton('dhm66_ISB_Xsens.urdf')

        for i, name_port in enumerate(list_port):
            self.input_port.append(name_port)
            self.port.append(yarp.BufferedPortBottle())
            self.port[i].open('/plot_skeleton' + name_port)

            yarp.Network.connect(name_port, self.port[i].getName())

        self.lines = self.skeleton.visualise_from_joints(data,
                                                         color_list=color,
                                                         lines=[])
def receiver(AV_port_name, HW_port_name, queue):
    """
    This function implements the communication with the microphone through YARP
    framework, appending all the message received to a queue.
    :param AV_port_name: name of the receiver port
    :param HW_port_name: name of the sender port
    :param queue: process shared queue
    """

    # Create and connect the port
    AV_port = yarp.BufferedPortBottle()
    AV_port.open(AV_port_name)
    yarp.Network.connect(HW_port_name, AV_port_name)

    while True:

        # Read the bottle message and convert to AudioData type
        btl = AV_port.read()
        print(btl)
        timestamp = btl.get(0).asInt64()
        print(timestamp)
        raw_audio = btl.get(1).asBlob()
        print(raw_audio)

        queue.put([timestamp, raw_audio])

    # Cleanup
    AV_port.close()
Exemple #11
0
 def test_open_and_connect_comm(self):
     p = yarp.BufferedPortBottle()
     p2 = yarp.BufferedPortBottle()
     bt_out = p.prepare()
     bt_out.addInt32(10)
     self.assertTrue(p.open("/python/out"))
     self.assertTrue(p2.open("/python/in"))
     self.assertTrue(yarp.Network.connect(p.getName(), p2.getName()))
     yarp.delay(0.5)
     p.write()
     yarp.delay(0.5)
     bt_in = p2.read()
     self.assertEqual(1, bt_in.size())
     self.assertEqual(10, bt_in.get(0).asInt32())
     p.close()
     p2.close()
 def __init__(self, input_port_name, output_port_name, display_port_name):
     yarp.RFModule.__init__(self)
     # Prepare ports
     self._input_port = yarp.Port()
     self._input_port_name = input_port_name
     self._input_port.open(self._input_port_name)
     self._output_port = yarp.BufferedPortBottle()
     self._output_port_name = output_port_name
     self._output_port.open(self._output_port_name)
     self._display_port = yarp.Port()
     self._display_port_name = display_port_name
     self._display_port.open(self._display_port_name)
     # Prepare image buffers
     # Input
     self._input_buf_image = yarp.ImageRgb()
     self._input_buf_image.resize(320, 240)
     self._input_buf_array = np.zeros((240, 320, 3), dtype=np.uint8)
     self._input_buf_image.setExternal(self._input_buf_array,
                                       self._input_buf_array.shape[1], self._input_buf_array.shape[0])
     # Output
     self._display_buf_image = yarp.ImageRgb()
     self._display_buf_image.resize(320, 240)
     self._display_buf_array = np.zeros((240, 320, 3), dtype=np.uint8)
     self._display_buf_image.setExternal(self._display_buf_array,
                                         self._display_buf_array.shape[1], self._display_buf_array.shape[0])
     self._logger = yarp.Log()
    def __init__(self, configuration):
        threading.Thread.__init__(self)
        self.name = "skinThread"
        self.config = configuration
        self.skinPart = "SKIN_PART_UNKNOWN, left_hand, SKIN_LEFT_FOREARM, SKIN_LEFT_UPPER_ARM, right_hand, head, SKIN_RIGHT_UPPER_ARM, torso, LEFT_LEG_UPPER, LEFT_LEG_LOWER, LEFT_FOOT, RIGHT_LEG_UPPER, RIGHT_LEG_LOWER, RIGHT_FOOT, SKIN_PART_ALL, SKIN_PART_SIZE".split(
            ", ")
        if self.config.status:
            try:
                if self.config.isRecording:
                    self.lastTouchside = False
                    self.exportTouch = open(
                        self.config.exportName + "_touch.py", 'w')
                    self.exportTouch.write("times = []\n")
                    self.exportTouch.write("side = []\n")

                yarp.Network.init()  # Init yarp
                self.manager = yarp.BufferedPortBottle()  # init Bottle
                self.manager.open("/skinManager")  # Open new port
                yarp.Network.connect(
                    "/skinManager/skin_events:o",
                    "/skinManager")  # connect Nao port with virtual port
            except:
                sharedIsrunningLock.acquire()
                sharedIsrunning = False
                sharedIsrunningLock.release()
Exemple #14
0
    def __init__(self, portName):
        super(yarpOutGrabber, self).__init__()
        #yarp.Network.init()

        self.port_name = portName
        self.port = yarp.BufferedPortBottle()
        self.bottle = yarp.Bottle()
Exemple #15
0
    def __init__(self,
                 namePortToRead='/matlab/write',
                 namePortToWrite='/matlab/HP'):
        """"Connexion entre :
        - /VTSFE/state:o et namePortToWrite 
        - namePortToRead et /VTSFE/latentSpace:i"""

        yarp.Network.init()
        self.pw = yarp.BufferedPortBottle()
        self.pw.open('/ae/state:o')
        self.portMatlabOutput = namePortToRead
        self.portMatlabInput = namePortToWrite
        self.pr = yarp.BufferedPortBottle()
        self.pr.open('/ae/latentSpace:i')

        yarp.Network.connect(self.portMatlabOutput, self.pr.getName())
        yarp.Network.connect(self.pw.getName(), self.portMatlabInput)
 def __init__(self):
     yarp.RFModule.__init__(self)
     self.image = np.zeros((240, 304))
     self.image_buf = np.zeros((240, 304))
     self.input_port = yarp.BufferedPortBottle()
     self.rpc_port = yarp.RpcServer()
     cv2.namedWindow("events", cv2.WINDOW_NORMAL)
     self.mutex = threading.Lock()
class motor_x(position)
    #starting a yarp network
    y.Network_init()
    
    #creating an ouput port for stm32_x position
    out_1      = y.BufferedPortBottle()
    out_1_name = "/stm32_"+ self.position "/position/out1"
    out_1.open(out_1_name) 

    #creating a input port
    in_1      = y.BufferedPortBottle()
    in_1_name = "/stm32_"+ self.position "/position/in1"
    in_1.open(in_1_name) 

    #creating an input port from ps3 controller
    in_speed      = y.BufferedPortBottle()
    in_speed_name = "/stm32_"+ self.position "/position/in1"
    in_speed.open(in_speed_name) 
Exemple #18
0
 def __init__(self, module_name, robot_name, task_name):
     port_prefix = '/' + robot_name + '/' + module_name + '/' + task_name + '/'
     self.set_ref = yarp.BufferedPortBottle()
     self.set_ref.open(port_prefix + 'set_ref:o')
     self.set_ref.addOutput(port_prefix + 'set_ref:i')
     #yarp.Network.connect(port_prefix+'set_ref:o',
     #                     port_prefix+'set_ref:i')
     self.rpc = yarp.RpcClient()
     self.rpc.open(port_prefix + 'rpc_client')
     self.rpc.addOutput(port_prefix + 'rpc')
    def __init__(self, parent=None):
        list_port = ['/processing/xsens/JointAngles:o', '/AE/reconstruct:o']

        self.input_port = []
        self.port = []

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111, projection='3d')

        data = np.zeros((1, 66))

        color = ['b', 'r']
        self.lines = []
        self.skeleton = []

        self.skeleton = Skeleton('dhm66_ISB_Xsens.urdf')

        for i, name_port in enumerate(list_port):
            self.input_port.append(name_port)
            self.port.append(yarp.BufferedPortBottle())
            self.port[i].open('/plot_skeleton' + name_port)

            yarp.Network.connect(name_port, self.port[i].getName())

        QtWidgets.QWidget.__init__(self, parent)  # Inherit from QWidget

        self.fig = Figure()

        self.pltCanv = Canvas(self.fig)
        self.pltCanv.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        self.pltCanv.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.pltCanv.setFocus()
        self.pltCanv.updateGeometry()
        self.ax = self.fig.add_subplot(111, projection='3d')

        self.ax.mouse_init()

        #=============================================
        # Main plot widget layout
        #=============================================
        self.layVMainMpl = QVBoxLayout()
        self.layVMainMpl.addWidget(self.pltCanv)
        self.setLayout(self.layVMainMpl)

        self.lines = []
        self.skeleton = []

        self.skeleton = Skeleton('dhm66_ISB_Xsens.urdf')

        self.timer = self.pltCanv.new_timer(100,
                                            [(self.update_canvas, (), {})])
        self.timer.start()
Exemple #20
0
    def configure(self, rf):
        yarp.Network.init()

        self.respondPort = yarp.Port()
        self.inputPort = yarp.BufferedPortBottle()
        self.outputPort = yarp.BufferedPortBottle()

        self.respondPort.open('/pythonRFMod')
        self.inputPort.open('/pythonRead')
        self.outputPort.open('/pythonWrite')

        self.attach(self.respondPort)

        yarp.Network.connect('/write', '/pythonRead')
        yarp.Network.connect('/pythonWrite', '/read')

        self.inputBottle = yarp.Bottle()
        self.outputBottle = yarp.Bottle()
        self.uniCom = 'None'
        print 'configured'
        return True
    def __init__(self, reader_port):

        print('\n\nInitializing predictor...')
        yarp.RFModule.__init__(self)

        # self._pattern = re.compile('(\d*) (\d*.\d*) (\w*) \((.*)\)')

        # Open YARP ports
        print('\nOpening yarp ports...')
        self._reader_port = yarp.BufferedPortBottle()
        self._reader_port.open(reader_port)
        yarp.Network.connect('/zynqGrabber/AE:o', reader_port,
                             'udp')  # AUTOMATIC CONNECTION - REMOVE IN FUTURE
        print('\nPorts opened successfully!')
Exemple #22
0
 def run(self):
     i = 0
     input_port = yarp.BufferedPortBottle()
     input_port.open(self.portname)
     input_port.useCallback(self.rec)
     st = yarp.Stamp()
     while not self.killswitch.is_set():
         input_port.getEnvelope(st)
         ts = st.getTime()
         b = self.decode_q.get()
         binp = event_driven.bottleToVBottle(b)
         data = event_driven.getData(binp)
         self.out_q.put((ts, data))
         i += 1
Exemple #23
0
    def __init__(self, name, out_port, carrier=""):
        """
        Initializing the NativeObjectPublisher
        :param name: Name of the publisher
        :param out_port: The published port name preceded by "/"
        :param carrier: For a list of carrier names, visit https://www.yarp.it/carrier_config.html. Default is "tcp"
        """
        super().__init__()
        self.__name__ = name

        self._port = yarp.BufferedPortBottle()
        self._port.open(out_port)
        self.__netconnect__ = yarp.Network.connect(out_port, out_port + ":out",
                                                   carrier)
Exemple #24
0
    def configure(self, rf):
        # Setting up rpc port

        self.portsList["rpc"] = yarp.Port()
        self.portsList["rpc"].open("/deepSpeechToText:rpc:i")
        self.attach(self.portsList["rpc"])
        yarp.Network.connect("/sentence_tokenizer/audio:o",
                             self.portsList["rpc"].getName())

        self.portsList["text_out"] = yarp.BufferedPortBottle()
        self.portsList["text_out"].open("/deepSpeechToText/text:o")

        self.portsList["tokenizer_rpc"] = yarp.BufferedPortBottle()
        self.portsList["tokenizer_rpc"].open(
            "/deepSpeechToText/tokenizer/rpc:o")
        self.tokenizer_ctrl_bottle = self.portsList["tokenizer_rpc"].prepare()
        yarp.Network.connect(self.portsList["tokenizer_rpc"].getName(),
                             "/sentence_tokenizer/rpc:i")

        # Setting up deep speech model client
        self.ds_model_file = join(self.ds_root_dir, "output_graph.pb")
        self.ds_alphabet_file = join(self.ds_root_dir, "alphabet.txt")
        self.ds_language_model = join(self.ds_root_dir, "lm.binary")
        self.ds_trie = join(self.ds_root_dir, "trie")

        self.ds_model = Model(self.ds_model_file, self.ds_N_FEATURES,
                              self.ds_N_CONTEXT, self.ds_alphabet_file,
                              self.ds_BEAM_WIDTH)

        self.ds_model.enableDecoderWithLM(self.ds_alphabet_file,
                                          self.ds_language_model, self.ds_trie,
                                          self.ds_LM_WEIGHT,
                                          self.ds_WORD_COUNT_WEIGHT,
                                          self.ds_VALID_WORD_COUNT_WEIGHT)
        print "Model loaded and ready to start"
        return True
def main():
    # ros node initialisation
    rospy.init_node('imu_recorder', disable_signals=True)

    # reading file and path name from the ros parameter server
    file_name = rospy.get_param('~file_name', 'recording')
    file_path = rospy.get_param('~file_path', '')

    # setting the file and path name for the recorder
    recorder.set_file_name(file_name, file_path)

    # subscribing to the inertial data topic
    rospy.Subscriber("/imu_data", Imu, callback)

    # setting yarp port for key pressure
    inputPortname = '/smartwatch/keyboard:i'
    inputPort = yarp.BufferedPortBottle()
    inputPort.open(inputPortname)

    # setting keyboard letters behavior
    reset = rospy.get_param('~reset_letter', 'nan')
    stop = rospy.get_param('~stop_letter', 'nan')

    if reset == "nan" or stop == "nan":
        print "\n ERROR: set the reset and stop parameter in the launch file \n"
        return

    r = rospy.Rate(100)
    while True:
        try:
            # reading yarp message
            messageBottle = inputPort.read(False)

            # handling keyboard pressure
            if messageBottle != None:
                receivedMessage = messageBottle.toString()
                if receivedMessage == reset:
                    recorder.save_reset()
                elif receivedMessage == stop:
                    recorder.set_recording(False)
                    recorder.save_file()
                    break
            r.sleep()
        except KeyboardInterrupt:
            recorder.set_recording(False)
            recorder.save_file()
            inputPort.close()
            break
Exemple #26
0
    def __init__(self, rf):
        path_model = rf.find('path_model').toString()

        self.input_port = '/activity_recognition/probabilities:o'
        self.port = yarp.BufferedPortBottle()
        self.port.open('/plot/probabilities')

        self.plotWindow = pg.GraphicsWindow(title='Probabilities')
        self.plotData = self.plotWindow.addPlot(title='Probabilities')

        self.buffer = [[]]
        self.list_curve = []

        yarp.Network.connect(self.input_port, self.port.getName())

        self.flag_init = 0
    def __init__(self, rf):
        self.input_port = '/processing/eglove/data/Forces:o'

        self.port = yarp.BufferedPortBottle()
        self.port.open('/DetectionContact')

        path_model = rf.find('path_model').toString()
        name_model = rf.find('name_model').toString()

        self.model = ModelHMM()
        self.model.load_model(path_model + '/' + name_model)
        self.list_states = self.model.get_list_states()
        self.buffer_model = []
        self.obs = []
        print(self.list_states)

        yarp.Network.connect(self.input_port, self.port.getName())
Exemple #28
0
    def __createPort(self, name, target=None, mode='unbuffered'):
        """ This method returns a port object.

        @param name     - yarp name for the port
        @param obj      - object for which the port is created
        @param buffered - if buffered is True a buffered port will be used otherwise not;
                          default is True.
        @result port
        """
        # create port
        if mode == 'buffered':
            port = yarp.BufferedPortBottle()

        elif mode == 'rpcclient':
            port = yarp.RpcClient()

        elif mode == 'rpcserver':
            port = yarp.RpcServer()

        else:
            port = yarp.Port()

        # build port name
        port_name = ['']

        # prefix handling
        if hasattr(self, 'prefix') and self.prefix:
            port_name.append(self.prefix)

        port_name.append(self.__class__.__name__)
        port_name.append(name)

        # open port
        if not port.open('/'.join(port_name)):
            raise RuntimeError, EMSG_YARP_NOT_FOUND

        # add output if given
        if target:
            port.addOutput(target)

        if hasattr(self, '_ports'):
            self._ports.append(port)

        return port
	def __init__(self, name_port, size_window):

		self.input_port = name_port
		self.port = yarp.BufferedPortBottle()
		self.port.open('/plot' + name_port)

		self.plotWindow = pg.GraphicsWindow(title=name_port)
		self.plotData = self.plotWindow.addPlot(title=name_port)

		self.buffer = [[]]
		self.list_curve = []

		self.size_window = size_window

		print(name_port)

		yarp.Network.connect(name_port, self.port.getName())

		self.flag_init = 0
Exemple #30
0
	def __init__(self, rf):
		path_model = rf.find('path_model').toString()

		self.input_port = '/activity_recognition/probabilities:o'
		self.port = yarp.BufferedPortBottle()
		self.port.open('/plot/probabilities')

		self.plotWindow = pg.GraphicsWindow(title='Probabilities')
		self.plotData = self.plotWindow.addPlot(title='Probabilities')

		self.buffer = [[]]
		self.list_curve = []

		if yarp.Network.connect(self.input_port, self.port.getName())== False:
			print('*** The activity recognition port cannot be found, closing ')
			self.close()
			return False

		self.flag_init = 0