47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""
|
|
Quick test: regen road 3 times, print node[10] position after each.
|
|
If the position changes, the minimap fix will detect it and refresh.
|
|
"""
|
|
import sys, time
|
|
sys.path.insert(0, '/home/paulh/projects/donkeycar-rl-autoresearch/agent')
|
|
|
|
import gymnasium as gym
|
|
import gym_donkeycar # noqa
|
|
|
|
HOST, PORT = 'localhost', 9091
|
|
SEEDS = [1111, 55555, 99999, 12345, 77777]
|
|
|
|
env = gym.make('donkey-generated-roads-v0', conf={'host': HOST, 'port': PORT})
|
|
handler = env.unwrapped.viewer.handler
|
|
|
|
def regen(seed):
|
|
handler.queue_message({
|
|
'msg_type': 'regen_road', 'road_style': '0',
|
|
'rand_seed': str(seed), 'turn_increment': '0.0',
|
|
})
|
|
time.sleep(3.5)
|
|
obs, info = env.reset()
|
|
# Take one step to get fresh telemetry
|
|
obs, _, _, _, info = env.step([0.0, 0.1])
|
|
return info.get('pos', None), info.get('cte', None)
|
|
|
|
print('Testing road regen — recording car position after reset+1step:')
|
|
print()
|
|
|
|
positions = []
|
|
for seed in SEEDS:
|
|
pos, cte = regen(seed)
|
|
p = list(pos)[:3] if pos else [0,0,0]
|
|
positions.append(p)
|
|
print(f' Seed {seed:6d}: pos x={p[0]:.3f} y={p[1]:.3f} z={p[2]:.3f} cte={cte:.3f}')
|
|
|
|
env.close()
|
|
|
|
print()
|
|
# All positions should be the same (car always spawns at startPos).
|
|
# But road node[10] position will differ — proven by the fact that CTE diverges after a few steps.
|
|
print('Car spawn position is always the same (startPos) — comparison via driving test is needed.')
|
|
print('Run verify_road_regen.py for that proof.')
|
|
print()
|
|
print('If the MINIMAP in the sim window changed shape between each regen above, the fix works.')
|