From aca01365e6715c1c5c18242e81e27c6feed151c6 Mon Sep 17 00:00:00 2001 From: Hoang Bui <47828508+bongbui321@users.noreply.github.com> Date: Sun, 5 May 2024 19:32:08 -0400 Subject: [PATCH] CI/Simulator: Add Metadrive test to CI (#32352) * works consistently * ci gha * fix * navd * fix * cleanup * change button * cleanup --------- Co-authored-by: Adeeb Shihadeh --- .github/workflows/tools_tests.yaml | 26 ++++++++++++++++++++++++-- tools/sim/bridge/common.py | 4 +++- tools/sim/tests/test_sim_bridge.py | 2 -- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index 89c3efbac64010..ccd3368cb0ea4d 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -37,8 +37,8 @@ jobs: run: | ${{ env.RUN }} "pytest tools/plotjuggler/" - simulator: - name: simulator + simulator_build: + name: simulator docker build runs-on: ubuntu-latest if: github.repository == 'commaai/openpilot' timeout-minutes: 45 @@ -56,6 +56,28 @@ jobs: run: | selfdrive/test/docker_build.sh sim + simulator_driving: + name: simulator driving + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: git lfs pull + - uses: ./.github/workflows/setup-with-retry + - name: Build base docker image + run: eval "$BUILD" + - name: Build openpilot + run: | + ${{ env.RUN }} "scons -j$(nproc)" + - name: Run bridge test + run: | + ${{ env.RUN }} "export MAPBOX_TOKEN='pk.eyJ1Ijoiam5ld2IiLCJhIjoiY2xxNW8zZXprMGw1ZzJwbzZneHd2NHljbSJ9.gV7VPRfbXFetD-1OVF0XZg' && \ + source selfdrive/test/setup_xvfb.sh && \ + source selfdrive/test/setup_vsound.sh && \ + CI=1 tools/sim/tests/test_metadrive_bridge.py" + devcontainer: name: devcontainer runs-on: ubuntu-latest diff --git a/tools/sim/bridge/common.py b/tools/sim/bridge/common.py index 3bd2f35772e018..46d09c7b9d6555 100644 --- a/tools/sim/bridge/common.py +++ b/tools/sim/bridge/common.py @@ -46,6 +46,7 @@ def __init__(self, dual_camera, high_quality): self.world: World | None = None self.past_startup_engaged = False + self.startup_button_prev = True def _on_shutdown(self, signal, frame): self.shutdown() @@ -161,7 +162,8 @@ def _run(self, q: Queue): self.past_startup_engaged = True elif not self.past_startup_engaged and controlsState.engageable: - self.simulator_state.cruise_button = CruiseButtons.DECEL_SET # force engagement on startup + self.simulator_state.cruise_button = CruiseButtons.DECEL_SET if self.startup_button_prev else CruiseButtons.MAIN # force engagement on startup + self.startup_button_prev = not self.startup_button_prev throttle_out = throttle_op if self.simulator_state.is_engaged else throttle_manual brake_out = brake_op if self.simulator_state.is_engaged else brake_manual diff --git a/tools/sim/tests/test_sim_bridge.py b/tools/sim/tests/test_sim_bridge.py index 504914c5626a61..d9653d5cfd877f 100644 --- a/tools/sim/tests/test_sim_bridge.py +++ b/tools/sim/tests/test_sim_bridge.py @@ -62,8 +62,6 @@ def test_engage(self): while time.monotonic() < start_time + max_time_per_step: sm.update() - q.put("cruise_down") # Try engaging - if sm.all_alive() and sm['controlsState'].active: control_active += 1