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)
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)