{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Exploratory Data Analysis\n\nLyft 3D Object Detection Dataset","metadata":{}},{"cell_type":"markdown","source":"# Install Lyft Dataset SDK","metadata":{}},{"cell_type":"code","source":"!pip install lyft_dataset_sdk","metadata":{"execution":{"iopub.status.busy":"2021-11-09T11:47:35.364149Z","iopub.execute_input":"2021-11-09T11:47:35.364453Z","iopub.status.idle":"2021-11-09T11:47:46.668096Z","shell.execute_reply.started":"2021-11-09T11:47:35.364375Z","shell.execute_reply":"2021-11-09T11:47:46.667242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Make Paths Compatible\nimport os\nos.system('rm -f data && ln -s /kaggle/input/3d-object-detection-for-autonomous-vehicles/train_data data')\nos.system('rm  -f images && ln -s /kaggle/input/3d-object-detection-for-autonomous-vehicles/train_images images')\nos.system('rm  -f maps && ln -s /kaggle/input/3d-object-detection-for-autonomous-vehicles/train_maps maps')\nos.system('rm  -f lidar && ln -s /kaggle/input/3d-object-detection-for-autonomous-vehicles/train_lidar lidar')","metadata":{"execution":{"iopub.status.busy":"2021-11-09T11:47:46.669924Z","iopub.execute_input":"2021-11-09T11:47:46.670184Z","iopub.status.idle":"2021-11-09T11:47:46.723307Z","shell.execute_reply.started":"2021-11-09T11:47:46.670153Z","shell.execute_reply":"2021-11-09T11:47:46.722064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the SDK\n%matplotlib inline\nfrom lyft_dataset_sdk.lyftdataset import LyftDataset\n\nlevel5data = LyftDataset(data_path = './', json_path = './data', verbose = True)","metadata":{"execution":{"iopub.status.busy":"2021-11-09T11:47:46.725058Z","iopub.execute_input":"2021-11-09T11:47:46.725433Z","iopub.status.idle":"2021-11-09T11:48:23.03375Z","shell.execute_reply.started":"2021-11-09T11:47:46.72538Z","shell.execute_reply":"2021-11-09T11:48:23.032665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# SDK Functions for Data Exploration","metadata":{}},{"cell_type":"code","source":"level5data.list_scenes()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:39.493522Z","iopub.execute_input":"2021-11-08T12:38:39.494024Z","iopub.status.idle":"2021-11-08T12:38:39.5722Z","shell.execute_reply.started":"2021-11-08T12:38:39.493978Z","shell.execute_reply":"2021-11-08T12:38:39.571395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example_scene = level5data.scene[0]\nexample_scene","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:39.573991Z","iopub.execute_input":"2021-11-08T12:38:39.574244Z","iopub.status.idle":"2021-11-08T12:38:39.58193Z","shell.execute_reply.started":"2021-11-08T12:38:39.574204Z","shell.execute_reply":"2021-11-08T12:38:39.581207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_token = example_scene[\"first_sample_token\"]\nlevel5data.render_sample(sample_token)","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:39.583538Z","iopub.execute_input":"2021-11-08T12:38:39.583779Z","iopub.status.idle":"2021-11-08T12:38:53.686457Z","shell.execute_reply.started":"2021-11-08T12:38:39.58375Z","shell.execute_reply":"2021-11-08T12:38:53.685364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample = level5data.get('sample', sample_token)\nsample","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:53.688216Z","iopub.execute_input":"2021-11-08T12:38:53.688787Z","iopub.status.idle":"2021-11-08T12:38:53.695783Z","shell.execute_reply.started":"2021-11-08T12:38:53.688743Z","shell.execute_reply":"2021-11-08T12:38:53.6951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.list_sample(sample[\"token\"])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:53.697263Z","iopub.execute_input":"2021-11-08T12:38:53.697693Z","iopub.status.idle":"2021-11-08T12:38:53.720984Z","shell.execute_reply.started":"2021-11-08T12:38:53.697656Z","shell.execute_reply":"2021-11-08T12:38:53.720203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.render_pointcloud_in_image(sample_token = sample[\"token\"],\n                                      dot_size = 1,\n                                      camera_channel = 'CAM_BACK')","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:53.722649Z","iopub.execute_input":"2021-11-08T12:38:53.722922Z","iopub.status.idle":"2021-11-08T12:38:54.849274Z","shell.execute_reply.started":"2021-11-08T12:38:53.722888Z","shell.execute_reply":"2021-11-08T12:38:54.848488Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample[\"data\"]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:54.850608Z","iopub.execute_input":"2021-11-08T12:38:54.851481Z","iopub.status.idle":"2021-11-08T12:38:54.858064Z","shell.execute_reply.started":"2021-11-08T12:38:54.851437Z","shell.execute_reply":"2021-11-08T12:38:54.857141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensor_channel = 'LIDAR_TOP'\nsample_data = level5data.get('sample_data', sample['data'][sensor_channel])\nsample_data","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:54.859502Z","iopub.execute_input":"2021-11-08T12:38:54.860251Z","iopub.status.idle":"2021-11-08T12:38:54.871223Z","shell.execute_reply.started":"2021-11-08T12:38:54.860205Z","shell.execute_reply":"2021-11-08T12:38:54.870415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.render_sample_data(sample_data['token'])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:54.872844Z","iopub.execute_input":"2021-11-08T12:38:54.873357Z","iopub.status.idle":"2021-11-08T12:38:58.284813Z","shell.execute_reply.started":"2021-11-08T12:38:54.873311Z","shell.execute_reply":"2021-11-08T12:38:58.283994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensor_channel = 'CAM_BACK'\nsample_data = level5data.get('sample_data', sample['data'][sensor_channel])\nsample_data","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:58.286334Z","iopub.execute_input":"2021-11-08T12:38:58.28717Z","iopub.status.idle":"2021-11-08T12:38:58.2938Z","shell.execute_reply.started":"2021-11-08T12:38:58.287125Z","shell.execute_reply":"2021-11-08T12:38:58.292908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.render_sample_data(sample_data['token'])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:58.297055Z","iopub.execute_input":"2021-11-08T12:38:58.29733Z","iopub.status.idle":"2021-11-08T12:38:59.187208Z","shell.execute_reply.started":"2021-11-08T12:38:58.2973Z","shell.execute_reply":"2021-11-08T12:38:59.186123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"annotation_token = sample['anns'][4]\nannotation = sample_data.get('sample_annotation', annotation_token)\nannotation","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:59.188719Z","iopub.execute_input":"2021-11-08T12:38:59.189666Z","iopub.status.idle":"2021-11-08T12:38:59.195171Z","shell.execute_reply.started":"2021-11-08T12:38:59.189627Z","shell.execute_reply":"2021-11-08T12:38:59.194398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.render_annotation(annotation_token)","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:38:59.196568Z","iopub.execute_input":"2021-11-08T12:38:59.197227Z","iopub.status.idle":"2021-11-08T12:39:01.836286Z","shell.execute_reply.started":"2021-11-08T12:38:59.19717Z","shell.execute_reply":"2021-11-08T12:39:01.835163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"instance = level5data.instance[0]\ninstance","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:01.837577Z","iopub.execute_input":"2021-11-08T12:39:01.838218Z","iopub.status.idle":"2021-11-08T12:39:01.845154Z","shell.execute_reply.started":"2021-11-08T12:39:01.838152Z","shell.execute_reply":"2021-11-08T12:39:01.844247Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"instance_token = instance['token']\nlevel5data.render_instance(instance_token)","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:01.846444Z","iopub.execute_input":"2021-11-08T12:39:01.846698Z","iopub.status.idle":"2021-11-08T12:39:03.637463Z","shell.execute_reply.started":"2021-11-08T12:39:01.846669Z","shell.execute_reply":"2021-11-08T12:39:03.636582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"First annotated sample of this instance:\")\nlevel5data.render_annotation(instance['first_annotation_token'])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:03.638847Z","iopub.execute_input":"2021-11-08T12:39:03.639135Z","iopub.status.idle":"2021-11-08T12:39:05.293934Z","shell.execute_reply.started":"2021-11-08T12:39:03.639101Z","shell.execute_reply":"2021-11-08T12:39:05.293322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Last annotated sample of this instance:\")\nlevel5data.render_annotation(instance[\"last_annotation_token\"])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:05.295126Z","iopub.execute_input":"2021-11-08T12:39:05.295502Z","iopub.status.idle":"2021-11-08T12:39:06.954355Z","shell.execute_reply.started":"2021-11-08T12:39:05.295464Z","shell.execute_reply":"2021-11-08T12:39:06.953297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.list_categories()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:06.95587Z","iopub.execute_input":"2021-11-08T12:39:06.95616Z","iopub.status.idle":"2021-11-08T12:39:08.419569Z","shell.execute_reply.started":"2021-11-08T12:39:06.956125Z","shell.execute_reply":"2021-11-08T12:39:08.418583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.category[0]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:08.421061Z","iopub.execute_input":"2021-11-08T12:39:08.421407Z","iopub.status.idle":"2021-11-08T12:39:08.426719Z","shell.execute_reply.started":"2021-11-08T12:39:08.421361Z","shell.execute_reply":"2021-11-08T12:39:08.426166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.list_attributes()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:08.427516Z","iopub.execute_input":"2021-11-08T12:39:08.427718Z","iopub.status.idle":"2021-11-08T12:39:09.302629Z","shell.execute_reply.started":"2021-11-08T12:39:08.427692Z","shell.execute_reply":"2021-11-08T12:39:09.301078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for instance in level5data.instance:\n    first_token = instance['first_annotation_token']\n    last_token = instance['last_annotation_token']\n    nbr_samples = instance['nbr_annotations']\n    current_token = first_token\n    \n    i = 0\n    found_change = False\n    while current_token != last_token:\n        current_ann = level5data.get('sample_annotation', current_token)\n        current_attr = level5data.get('attribute', current_ann['attribute_tokens'][0])['name']\n        \n        if i == 0:\n            pass\n        elif current_attr != last_attr:\n            print(f\"Changed from {last_attr} to {current_attr} at timestamp {i} out of {nbr_samples}\")\n            found_change = True\n            \n        next_token = current_ann[\"next\"]\n        current_token = next_token\n        last_attr = current_attr\n        i += 1","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:09.30389Z","iopub.execute_input":"2021-11-08T12:39:09.304231Z","iopub.status.idle":"2021-11-08T12:39:11.667989Z","shell.execute_reply.started":"2021-11-08T12:39:09.30419Z","shell.execute_reply":"2021-11-08T12:39:11.665725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.sensor","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.669551Z","iopub.execute_input":"2021-11-08T12:39:11.670203Z","iopub.status.idle":"2021-11-08T12:39:11.679169Z","shell.execute_reply.started":"2021-11-08T12:39:11.670148Z","shell.execute_reply":"2021-11-08T12:39:11.678248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.sample_data[10]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.680292Z","iopub.execute_input":"2021-11-08T12:39:11.680516Z","iopub.status.idle":"2021-11-08T12:39:11.691108Z","shell.execute_reply.started":"2021-11-08T12:39:11.680489Z","shell.execute_reply":"2021-11-08T12:39:11.690431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.calibrated_sensor[10]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.692813Z","iopub.execute_input":"2021-11-08T12:39:11.693037Z","iopub.status.idle":"2021-11-08T12:39:11.708058Z","shell.execute_reply.started":"2021-11-08T12:39:11.693009Z","shell.execute_reply":"2021-11-08T12:39:11.707407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.ego_pose[10]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.709363Z","iopub.execute_input":"2021-11-08T12:39:11.709613Z","iopub.status.idle":"2021-11-08T12:39:11.72055Z","shell.execute_reply.started":"2021-11-08T12:39:11.709585Z","shell.execute_reply":"2021-11-08T12:39:11.719651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of logs loaded in database: {len(level5data.log)}\")","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.721744Z","iopub.execute_input":"2021-11-08T12:39:11.722071Z","iopub.status.idle":"2021-11-08T12:39:11.732734Z","shell.execute_reply.started":"2021-11-08T12:39:11.72203Z","shell.execute_reply":"2021-11-08T12:39:11.731757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.log[0]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.734092Z","iopub.execute_input":"2021-11-08T12:39:11.734436Z","iopub.status.idle":"2021-11-08T12:39:11.744639Z","shell.execute_reply.started":"2021-11-08T12:39:11.734392Z","shell.execute_reply":"2021-11-08T12:39:11.743906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"There are {len(level5data.map)} maps masks in the loaded dataset\")","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.745623Z","iopub.execute_input":"2021-11-08T12:39:11.746323Z","iopub.status.idle":"2021-11-08T12:39:11.758025Z","shell.execute_reply.started":"2021-11-08T12:39:11.746286Z","shell.execute_reply":"2021-11-08T12:39:11.757429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.map[0]","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.759289Z","iopub.execute_input":"2021-11-08T12:39:11.760027Z","iopub.status.idle":"2021-11-08T12:39:11.773579Z","shell.execute_reply.started":"2021-11-08T12:39:11.759993Z","shell.execute_reply":"2021-11-08T12:39:11.772688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensor_channel = 'LIDAR_TOP'\nsample_data = level5data.get('sample_data', sample['data'][sensor_channel])\nlevel5data.render_sample_data(sample_data['token'])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:11.774722Z","iopub.execute_input":"2021-11-08T12:39:11.775535Z","iopub.status.idle":"2021-11-08T12:39:15.208972Z","shell.execute_reply.started":"2021-11-08T12:39:11.775501Z","shell.execute_reply":"2021-11-08T12:39:15.208372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensor_channel = 'CAM_FRONT'\nsample_data = level5data.get('sample_data', sample['data'][sensor_channel])\nlevel5data.render_sample_data(sample_data['token'])","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:15.210039Z","iopub.execute_input":"2021-11-08T12:39:15.210363Z","iopub.status.idle":"2021-11-08T12:39:16.028582Z","shell.execute_reply.started":"2021-11-08T12:39:15.210311Z","shell.execute_reply":"2021-11-08T12:39:16.027547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"level5data.render_sample_data(sample['data']['LIDAR_TOP'], nsweeps=5)","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:39:16.029911Z","iopub.execute_input":"2021-11-08T12:39:16.030749Z","iopub.status.idle":"2021-11-08T12:39:19.497513Z","shell.execute_reply.started":"2021-11-08T12:39:16.030708Z","shell.execute_reply":"2021-11-08T12:39:19.496648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Videos","metadata":{}},{"cell_type":"code","source":"from matplotlib import animation, rc\nimport matplotlib.pyplot as plt\nfrom IPython.core.display import HTML","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:51:54.13673Z","iopub.execute_input":"2021-11-08T12:51:54.137279Z","iopub.status.idle":"2021-11-08T12:51:54.14154Z","shell.execute_reply.started":"2021-11-08T12:51:54.137228Z","shell.execute_reply":"2021-11-08T12:51:54.140694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cams = [\"CAM_FRONT\", \"CAM_FRONT_RIGHT\", \"CAM_FRONT_LEFT\",\n        \"CAM_BACK\", \"CAM_BACK_RIGHT\", \"CAM_BACK_LEFT\"]\n\ndef generate_next_token(scene):\n    scene = level5data.scene[scene]\n    sample_token = scene['first_sample_token']\n    sample_record = level5data.get('sample', sample_token)\n    \n    while sample_record[\"next\"]:\n        sample_token = sample_record[\"next\"]\n        sample_record = level5data.get(\"sample\", sample_token)\n        \n        yield sample_token\n        \ndef animate_images(scene, frames, pointsensor_channel = \"LIDAR_TOP\", interval = 1):\n    generator = generate_next_token(scene)\n\n    fig, axs = plt.subplots(\n        2, len(cams), figsize=(3*len(cams), 6), \n        sharex=True, sharey=True, gridspec_kw = {'wspace': 0, 'hspace': 0.1}\n    )\n    \n    plt.close(fig)\n\n    def animate_fn(i):\n        for _ in range(interval):\n            sample_token = next(generator)\n            \n        for c, camera_channel in enumerate(cams):    \n            sample_record = level5data.get(\"sample\", sample_token)\n\n            pointsensor_token = sample_record[\"data\"][pointsensor_channel]\n            camera_token = sample_record[\"data\"][camera_channel]\n            \n            axs[0, c].clear()\n            axs[1, c].clear()\n            \n            level5data.render_sample_data(camera_token, with_anns=False, ax=axs[0, c])\n            level5data.render_sample_data(camera_token, with_anns=True, ax=axs[1, c])\n            \n            axs[0, c].set_title(\"\")\n            axs[1, c].set_title(\"\")\n\n    anim = animation.FuncAnimation(fig, animate_fn, frames=frames, interval=interval)\n    return anim","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:54:00.727831Z","iopub.execute_input":"2021-11-08T12:54:00.728465Z","iopub.status.idle":"2021-11-08T12:54:00.740702Z","shell.execute_reply.started":"2021-11-08T12:54:00.728412Z","shell.execute_reply":"2021-11-08T12:54:00.739646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"anim = animate_images(scene=3, frames=100, interval=1)\nHTML(anim.to_jshtml(fps=8))","metadata":{"execution":{"iopub.status.busy":"2021-11-08T12:54:01.42942Z","iopub.execute_input":"2021-11-08T12:54:01.429701Z","iopub.status.idle":"2021-11-08T12:58:47.605951Z","shell.execute_reply.started":"2021-11-08T12:54:01.429671Z","shell.execute_reply":"2021-11-08T12:58:47.605144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"anim = animate_images(scene=4, frames=100, interval=1)\nHTML(anim.to_jshtml(fps=8))","metadata":{"execution":{"iopub.status.busy":"2021-11-08T13:00:38.931795Z","iopub.execute_input":"2021-11-08T13:00:38.932118Z","iopub.status.idle":"2021-11-08T13:06:49.882117Z","shell.execute_reply.started":"2021-11-08T13:00:38.932084Z","shell.execute_reply":"2021-11-08T13:06:49.881436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def animate_lidar(scene, frames, pointsensor_channel = \"LIDAR_TOP\", interval = 1):\n    generator = generate_next_token(scene)\n    \n    fig, axs = plt.subplots(2, 1, figsize = (16, 8))\n    plt.close(fig)\n    \n    def animate_function(i):\n        for _ in range(interval):\n            sample_token = next(generator)\n            \n        axs[0].clear()\n        axs[1].clear()\n        \n        sample_record = level5data.get(\"sample\", sample_token)\n        pointsensor_token = sample_record[\"data\"][pointsensor_channel]\n        \n        level5data.render_sample_data(pointsensor_token, with_anns=False, ax=axs[0])\n        level5data.render_sample_data(pointsensor_token, with_anns=True, ax=axs[1])\n        \n    anim = animation.FuncAnimation(fig, animate_function, frames=frames, interval=interval)\n    return anim","metadata":{"execution":{"iopub.status.busy":"2021-11-08T13:08:30.290085Z","iopub.execute_input":"2021-11-08T13:08:30.290414Z","iopub.status.idle":"2021-11-08T13:08:30.299217Z","shell.execute_reply.started":"2021-11-08T13:08:30.290378Z","shell.execute_reply":"2021-11-08T13:08:30.297833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"anim = animate_lidar(scene=5, frames=100, interval=1)\nHTML(anim.to_jshtml(fps=8))","metadata":{"execution":{"iopub.status.busy":"2021-11-08T13:08:30.510157Z","iopub.execute_input":"2021-11-08T13:08:30.510887Z","iopub.status.idle":"2021-11-08T13:13:35.987412Z","shell.execute_reply.started":"2021-11-08T13:08:30.510848Z","shell.execute_reply":"2021-11-08T13:13:35.985944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"anim = animate_lidar(scene=10, frames=100, interval=1)\nHTML(anim.to_jshtml(fps=8))","metadata":{"execution":{"iopub.status.busy":"2021-11-08T13:13:35.989274Z","iopub.execute_input":"2021-11-08T13:13:35.989539Z","iopub.status.idle":"2021-11-08T13:18:32.84209Z","shell.execute_reply.started":"2021-11-08T13:13:35.989505Z","shell.execute_reply":"2021-11-08T13:18:32.840967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}