Skip to content

Commit

Permalink
Add frenet tests to test track
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmadAmine998 committed Jun 7, 2024
1 parent 1f4f3e7 commit 8d9f1db
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,26 @@ def test_download_racetrack(self):
# rename the backup track dir to its original name
track_backup_dir = find_track_dir(tmp_dir.stem)
track_backup_dir.rename(track_dir)

def test_frenet_to_cartesian(self):
track_name = "Spielberg"
track = Track.from_track_name(track_name)

# Check frenet to cartesian conversion
# using the track's xs, ys
for s, x, y in zip(track.centerline.ss, track.centerline.xs, track.centerline.ys):
x_, y_, _ = track.frenet_to_cartesian(s, 0, 0)
self.assertAlmostEqual(x, x_, places=2)
self.assertAlmostEqual(y, y_, places=2)

def test_frenet_to_cartesian_to_frenet(self):
track_name = "Spielberg"
track = Track.from_track_name(track_name)

# check frenet to cartesian conversion
s_ = 0
for s in np.linspace(0, 1, 10):
x, y, psi = track.frenet_to_cartesian(s, 0, 0)
s_, d, _ = track.cartesian_to_frenet(x, y, psi, s_guess=s_)
self.assertAlmostEqual(s, s_, places=2)
self.assertAlmostEqual(d, 0, places=2)

0 comments on commit 8d9f1db

Please sign in to comment.