Learn practical skills, build real-world projects, and advance your career

Display telemetry data for different laps

if 'google.colab' in str(get_ipython()):
  from google.colab import drive
  path = '/content/drive/MyDrive/SA'
  path = '../data'
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
  import rosbag
except ModuleNotFoundError:
  !pip3 install rosbag --extra-index-url https://rospypi.github.io/simple/
  import rosbag

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import json
import os
from scipy.spatial import distance
import matplotlib.animation as animation
from matplotlib import rc
import PIL
from PIL import Image
from matplotlib.pyplot import cm
from datetime import datetime as dt
from matplotlib.dates import date2num
Failed to load Python extension for LZ4 support. LZ4 compression will not be available.

Plot track layout from json file

1. plot the track layout from json file
2. return the position of the yellow/blue cones and the center line
def plot_track_layout(json_file):

  track_path = os.path.join(path, json_file)

  cone_y_x, cone_y_y = [], [] # yellow cones
  cone_b_x, cone_b_y = [], [] # blue cones
  center_x, center_y = [], [] # center points between yellow and blue cones

  with open(track_path) as f:
      track = json.load(f)

      for id in range(len(track['yellow_cones'])):
      cone_y = {'x' : cone_y_x, 'y' : cone_y_y}
      cone_b = {'x' : cone_b_x, 'y' : cone_b_y}
      center = {'x' : center_x, 'y' : center_y}

      plt.plot(cone_y_x, cone_y_y, color='y')
      plt.plot(cone_b_x, cone_b_y, color='b')
      plt.plot(center_x, center_y, color='r')

  return cone_y, cone_b, center