diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 81da841dd2cdfd..c1c35524725bc9 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -27,9 +27,7 @@ env: jobs: simulator_driving: name: simulator driving - runs-on: ${{ ((github.repository == 'commaai/openpilot') && - ((github.event_name != 'pull_request') || - (github.event.pull_request.head.repo.full_name == 'commaai/openpilot'))) && 'namespace-profile-amd64-8x16' || 'ubuntu-latest' }} + runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 diff --git a/tools/sim/bridge/metadrive/metadrive_bridge.py b/tools/sim/bridge/metadrive/metadrive_bridge.py index 7bfadc5533fa89..b8dc94cf86fc75 100644 --- a/tools/sim/bridge/metadrive/metadrive_bridge.py +++ b/tools/sim/bridge/metadrive/metadrive_bridge.py @@ -50,13 +50,12 @@ def create_map(track_size=60): class MetaDriveBridge(SimulatorBridge): TICKS_PER_FRAME = 5 - def __init__(self, dual_camera, high_quality, test_duration=math.inf, minimal_distance=0, test_run=False): + def __init__(self, dual_camera, high_quality, test_duration=math.inf, test_run=False): super().__init__(dual_camera, high_quality) self.should_render = False self.test_run = test_run self.test_duration = test_duration if self.test_run else math.inf - self.minimal_distance = minimal_distance if self.test_run else 0 def spawn_world(self, queue: Queue): sensors = { @@ -91,4 +90,4 @@ def spawn_world(self, queue: Queue): anisotropic_filtering=False ) - return MetaDriveWorld(queue, config, self.test_duration, self.minimal_distance, self.test_run, self.dual_camera) + return MetaDriveWorld(queue, config, self.test_duration, self.test_run, self.dual_camera) diff --git a/tools/sim/bridge/metadrive/metadrive_process.py b/tools/sim/bridge/metadrive/metadrive_process.py index c788b8cda2804a..2486d87ff997cb 100644 --- a/tools/sim/bridge/metadrive/metadrive_process.py +++ b/tools/sim/bridge/metadrive/metadrive_process.py @@ -19,7 +19,6 @@ C3_POSITION = Vec3(0.0, 0, 1.22) C3_HPR = Vec3(0, 0,0) -VEHICLE_STARTING_POS = [110, 4.5] metadrive_simulation_state = namedtuple("metadrive_simulation_state", ["running", "done", "done_info"]) metadrive_vehicle_state = namedtuple("metadrive_vehicle_state", ["velocity", "position", "bearing", "steering_angle"]) @@ -51,7 +50,7 @@ def arrive_destination_patch(self, *args, **kwargs): def metadrive_process(dual_camera: bool, config: dict, camera_array, wide_camera_array, image_lock, controls_recv: Connection, simulation_state_send: Connection, vehicle_state_send: Connection, - exit_event, op_engaged, test_duration, minimal_distance, test_run): + exit_event, op_engaged, test_duration, test_run): arrive_dest_done = config.pop("arrive_dest_done", True) apply_metadrive_patches(arrive_dest_done) @@ -71,7 +70,6 @@ def reset(): env.reset() env.vehicle.config["max_speed_km_h"] = 1000 lane_idx_prev, _ = get_current_lane_info(env.vehicle) - env.vehicle.set_position(VEHICLE_STARTING_POS) simulation_state = metadrive_simulation_state( running=True, @@ -100,9 +98,6 @@ def get_cam_as_rgb(cam): steer_ratio = 8 vc = [0,0] - total_distance = 0 - prev_x_pos = VEHICLE_STARTING_POS[0] - while not exit_event.is_set(): vehicle_state = metadrive_vehicle_state( velocity=vec3(x=float(env.vehicle.velocity[0]), y=float(env.vehicle.velocity[1]), z=0), @@ -112,9 +107,6 @@ def get_cam_as_rgb(cam): ) vehicle_state_send.send(vehicle_state) - total_distance += abs(env.vehicle.position[0] - prev_x_pos) - prev_x_pos = env.vehicle.position[0] - if controls_recv.poll(0): while controls_recv.poll(0): steer_angle, gas, should_reset = controls_recv.recv() @@ -145,10 +137,7 @@ def get_cam_as_rgb(cam): elif out_of_lane: done_result = (True, {"out_of_lane" : True}) elif timeout: - if total_distance < minimal_distance: - done_result = (True, {"minimal_distance" : True}) - else: - done_result = (True, {"timeout" : True}) + done_result = (True, {"timeout" : True}) simulation_state = metadrive_simulation_state( running=False, diff --git a/tools/sim/bridge/metadrive/metadrive_world.py b/tools/sim/bridge/metadrive/metadrive_world.py index 7b6c8656903584..5bb4555dc1e97d 100644 --- a/tools/sim/bridge/metadrive/metadrive_world.py +++ b/tools/sim/bridge/metadrive/metadrive_world.py @@ -14,7 +14,7 @@ class MetaDriveWorld(World): - def __init__(self, status_q, config, test_duration, minimal_distance, test_run, dual_camera=False): + def __init__(self, status_q, config, test_duration, test_run, dual_camera=False): super().__init__(dual_camera) self.status_q = status_q self.camera_array = Array(ctypes.c_uint8, W*H*3) @@ -41,7 +41,7 @@ def __init__(self, status_q, config, test_duration, minimal_distance, test_run, functools.partial(metadrive_process, dual_camera, config, self.camera_array, self.wide_camera_array, self.image_lock, self.controls_recv, self.simulation_state_send, - self.vehicle_state_send, self.exit_event, self.op_engaged, test_duration, minimal_distance, self.test_run)) + self.vehicle_state_send, self.exit_event, self.op_engaged, test_duration, self.test_run)) self.metadrive_process.start() self.status_q.put(QueueMessage(QueueMessageType.START_STATUS, "starting")) @@ -105,7 +105,7 @@ def read_sensors(self, state: SimulatorState): if x_dist >= dist_threshold or y_dist >= dist_threshold: # position not the same during staying still, > threshold is considered moving self.distance_moved += x_dist + y_dist - time_check_threshold = 7.5 + time_check_threshold = 30 current_time = time.monotonic() since_last_check = current_time - self.last_check_timestamp if since_last_check >= time_check_threshold: diff --git a/tools/sim/tests/test_metadrive_bridge.py b/tools/sim/tests/test_metadrive_bridge.py index bed0601b7a56b5..8849e901cbbc8f 100644 --- a/tools/sim/tests/test_metadrive_bridge.py +++ b/tools/sim/tests/test_metadrive_bridge.py @@ -11,9 +11,11 @@ @pytest.mark.filterwarnings("ignore::pyopencl.CompilerWarning") # Unimportant warning of non-empty compile log class TestMetaDriveBridge(TestSimBridgeBase): @pytest.fixture(autouse=True) - def setup_create_bridge(self): - self.test_duration = 15 - self.minimal_distance = 10 + def setup_create_bridge(self, test_duration): + # run bridge test for at least 60s, since not-moving check runs every 30s + if test_duration < 60: + test_duration = 60 + self.test_duration = test_duration def create_bridge(self): - return MetaDriveBridge(False, False, self.test_duration, self.minimal_distance, True) + return MetaDriveBridge(False, False, self.test_duration, True)