donkeycar-rl-autoresearch/agent/test_sdsandbox.py

24 lines
612 B
Python

from sdsandbox import SDClient
import time
import numpy as np
HOST = '10.0.0.55'
PORT = 9091
client = SDClient(HOST, PORT)
client.init()
if client.is_running():
print(f"Connected to SDSandbox at {HOST}:{PORT}")
for _ in range(10):
steer = np.random.uniform(-1, 1)
throttle = np.random.uniform(0, 1)
client.send_controls(steer, throttle)
obs = client.get_observation()
print(f"Obs keys: {list(obs.keys())}, Steer: {steer:.2f}, Throttle: {throttle:.2f}")
time.sleep(0.1)
else:
print(f"Failed to connect to SDSandbox at {HOST}:{PORT}")
client.close()