Ejemplo n.º 1
0
    def __init__(self, host):
        self.host = host

        self.id = random_id()
        self.ping_msg = construct_action(self.id)
        self.robot_sock = make_push_socket(host)
        self.robot_sock.send_string(self.ping_msg)

        self.cam = SubCameraMaster(host)
Ejemplo n.º 2
0
    def __init__(self, host, silent=False):
        self.host = host
        self.silent = silent

        # Create a somewhat random ID for this connection.
        # The randomness isn't super important since there
        # will only ever be 1-2 clients connected to the same
        # server
        self.id = random_id()

        # Construct a "hello world" messag
        self.ping_msg = construct_action(self.id)

        # Initialize the PUSH socket
        self.robot_sock = make_push_socket(host)

        self.cam = SubCameraMaster(host, silent=self.silent)

        # We have to wait for the thread to launch
        self.cam.wait_until_ready()

        # say hi to the robot
        self._ping()
import time
import numpy as np
from duckietown_slimremote.helpers import random_id, timer
from duckietown_slimremote.networking import get_ip, construct_action, make_push_socket

robot_sock = make_push_socket("quacksparrow.local")

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

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

timings = []
start = time.time()

while True:
    action = np.random.uniform(-1, 1, 2)
    msg = construct_action(own_id, own_ip, action)
    robot_sock.send_string(msg)
    timings, start = timer(timings, start, prefix="action")
    time.sleep(0.01)  # not necessary anymore

# msg = construct_action(own_id, own_ip, (0.5,-0.5))
# robot_sock.send_string(msg)
Ejemplo n.º 4
0
import time
import matplotlib

matplotlib.use('TkAgg')  # needed for tkinter GUI
import matplotlib.pyplot as plt
from duckietown_slimremote.helpers import random_id, timer
from duckietown_slimremote.networking import get_ip, construct_action, make_push_socket
from duckietown_slimremote.pc.camera import SubCameraMaster, cam_window_init, cam_window_update, \
    cam_windows_init_opencv, cam_windows_update_opencv

host = "quacksparrow.local"

robot_sock = make_push_socket(host)
cam = SubCameraMaster(host)

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

print("sending init", msg)
robot_sock.send_string(msg)

cam_windows_init_opencv()

while True:
    img = cam.get_img_blocking()
    cam_windows_update_opencv(img)