Ejemplo n.º 1
0
 def __init__(self, queue, host):
     Thread.__init__(self)
     context = zmq.Context.instance()
     self.queue = queue
     self.sock = make_sub_socket(for_images=True,
                                 context_=context,
                                 target=host)
Ejemplo n.º 2
0
    def __init__(self, frame, event_img, event_ready, host, silent=False):
        super(ThreadedSubCamera, self).__init__()
        self.silent = silent
        self.frame = frame
        self.event_img = event_img
        self.event_ready = event_ready

        context = zmq.Context()
        self.sock = make_sub_socket(for_images=True, context_=context, target=host)
import time

import zmq

from duckietown_slimremote.helpers import random_id, get_py_version
from duckietown_slimremote.networking import make_sub_socket, make_pub_socket, construct_action, recv_array, \
    get_ip

print(get_py_version())

context = zmq.Context()

image_sub = make_sub_socket(for_images=True)
action_pub = make_pub_socket("quacksparrow.local")

poller = zmq.Poller()
poller.register(image_sub, zmq.POLLIN)

own_id = random_id()
own_ip = get_ip()
msg = construct_action(own_id, own_ip)

time.sleep(1)  # wait for sock init

print("sending init", msg)
# init
action_pub.send_string(msg)

# during testing the following block took out the JSON header from the first image.
# In other words the hello message arrived too quickly.