Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driving a course in Metadrive test #30964

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
good?
  • Loading branch information
bongbui321 committed Jan 11, 2024
commit 0c512998d3bb6fe2d905c74f1d23acc12ebeaa29
34 changes: 33 additions & 1 deletion tools/sim/tests/test_sim_bridge.py
Original file line number Diff line number Diff line change
@@ -72,6 +72,39 @@ def test_engage(self):
break

self.assertEqual(min_counts_control_active, control_active, f"Simulator did not engage a minimal of {min_counts_control_active} steps was {control_active}")

def test_drive_course(self):
p_manager = subprocess.Popen("./launch_openpilot.sh", cwd=SIM_DIR)
self.processes.append(p_manager)

sm = messaging.SubMaster(['controlsState', 'onroadEvents', 'managerState'])
q = Queue()
bridge = self.create_bridge()
bridge.started = Value('b', False)
p_bridge = bridge.run(q, retries=10)
self.processes.append(p_bridge)

max_time_per_step = 60

start_waiting = time.monotonic()
while not bridge.started and time.monotonic() < start_waiting + max_time_per_step:
time.sleep(0.1)
self.assertEqual(p_bridge.exitcode, None, f"Bridge process should be running, but exited with code {p_bridge.exitcode}")

start_time = time.monotonic()
user_disengage_once = False
disengage_events = ('stockAeb', 'fcw', 'ldw')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't tell you what you need to know. the point of the bounty is to determine whether openpilot stayed in its lane, drove a reasonable, etc. and finished the course


while time.monotonic() < start_time + max_time_per_step:
sm.update()

onroadEventNames = [e.name for e in sm['onroadEvents']]

if any(e in onroadEventNames for e in disengage_events):
user_disengage_once = True
break

self.assertFalse(user_disengage_once, "Failed because user has to disengage")

def tearDown(self):
print("Test shutting down. CommIssues are acceptable")
@@ -84,6 +117,5 @@ def tearDown(self):
else:
p.join(15)


if __name__ == "__main__":
unittest.main()