mirror of
https://gitlab.ewi.tudelft.nl/ee2l1/2025-2026/A.K.03.git
synced 2025-12-12 16:00:56 +01:00
Merge branch 'Module2' into 'main'
merg See merge request ee2l1/2025-2026/A.K.03!5
This commit is contained in:
commit
4c5e27a0b3
@ -1,8 +1,8 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
@ -18,32 +18,34 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"# Import necessary libraries\n",
|
||||
"import time\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import csv\n",
|
||||
"\n",
|
||||
"# Uncomment one of the following lines depending on your setup\n",
|
||||
"\n",
|
||||
"# If you are using the real car, uncomment the next lines and comment the simulator lines\n",
|
||||
"# from serial import Serial\n",
|
||||
"# import sounddevice\n",
|
||||
"from serial import Serial\n",
|
||||
"import sounddevice\n",
|
||||
"\n",
|
||||
"# If you are using the simulator, uncomment the next lines and comment the real car lines\n",
|
||||
"from Manual.KITT_Simulator.sounddevice_simulator import sounddevice\n",
|
||||
"# from KITT_Simulator.serial_simulator import Serial\n",
|
||||
"# from KITT_Simulator.sounddevice_simulator import sounddevice\n",
|
||||
"\n",
|
||||
"# Note: After changing the import statement, you need to restart the kernel for changes to take effect."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"\n",
|
||||
"KITT relies on its sensors to drive autonomously. It is equipped with:\n",
|
||||
@ -58,8 +60,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## Distance Sensors\n",
|
||||
"\n",
|
||||
@ -96,21 +98,32 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"\n",
|
||||
"# TODO: Establish a serial connection, ask for a status report, read it out, and print it\n",
|
||||
"serial = Serial('COM4', 115200)\n",
|
||||
"serial.write(b'Sd\\n')\n",
|
||||
"status = serial.read_until(b\"\\x04\")\n",
|
||||
"status = status.decode('utf-8')\n",
|
||||
"print(f\"Car status is:\\n\\n{status}\")\n",
|
||||
"\n",
|
||||
"# TODO: Close the serial connection"
|
||||
"serial.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": "serial.close()"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"If you only need distance measurement information, you can request it separately:\n",
|
||||
"\n",
|
||||
@ -142,17 +155,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"\n",
|
||||
"# TODO: Decode the status response to a string\n",
|
||||
"def extract_dis ():\n",
|
||||
" serial = Serial('COM4', 115200)\n",
|
||||
" serial.write(b'S\\n')\n",
|
||||
" _status = serial.read_until(b'\\x04')\n",
|
||||
" _status = _status.decode('utf-8')\n",
|
||||
"\n",
|
||||
"# TODO: Split the status string into lines\n",
|
||||
"lines = \n",
|
||||
" lines = _status.splitlines()\n",
|
||||
"\n",
|
||||
" # Initialize variables to hold distance values\n",
|
||||
" dist_L = None\n",
|
||||
@ -161,23 +177,33 @@
|
||||
" # Iterate over each line to find distance data\n",
|
||||
" for line in lines:\n",
|
||||
" if \"Dist.\" in line:\n",
|
||||
" # TODO: Split the line into words\n",
|
||||
" words =\n",
|
||||
" words = line.split()\n",
|
||||
" # Extract distance values based on their positions\n",
|
||||
"\n",
|
||||
" # Assign dist_L and dist_R accordingly\n",
|
||||
" dist_L = \n",
|
||||
" dist_R = \n",
|
||||
" dist_L = words[3]\n",
|
||||
" dist_R = words[5]\n",
|
||||
" break # Exit the loop after finding the distances\n",
|
||||
"\n",
|
||||
" # Print the extracted distance values\n",
|
||||
" print(f\"Left Distance: {dist_L}\")\n",
|
||||
"print(f\"Right Distance: {dist_R}\")"
|
||||
" print(f\"Right Distance: {dist_R}\")\n",
|
||||
"\n",
|
||||
" serial.close()\n",
|
||||
"\n",
|
||||
" return dist_L, dist_R"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": "extract_dis()"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"2. **Determine how fast you can read out (and process) your distance data** by writing a script that requests the status 100 times. You can calculate the average delay for this operation (and its standard deviation); you could also present the results in a histogram. To measure delays, you will need to keep track of time:\n",
|
||||
"\n",
|
||||
@ -197,17 +223,63 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": "serial.close()"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n"
|
||||
"### Student Version ###\n",
|
||||
"times = []\n",
|
||||
"new_times = []\n",
|
||||
"total_time = 0\n",
|
||||
"summed_times = 0\n",
|
||||
"serial = Serial('COM4', 115200)\n",
|
||||
"\n",
|
||||
"for i in range(100):\n",
|
||||
" start_time = time.time()\n",
|
||||
" serial.write(b'S\\n')\n",
|
||||
" _status = serial.read_until(b'\\x04')\n",
|
||||
" _status = _status.decode('utf-8')\n",
|
||||
" current_time = time.time() - start_time\n",
|
||||
" times.append(current_time)\n",
|
||||
"\n",
|
||||
"serial.close()\n",
|
||||
"#print(times)\n",
|
||||
"\n",
|
||||
"for j in range(100):\n",
|
||||
" total_time += times[j]\n",
|
||||
"\n",
|
||||
"average = total_time / 100\n",
|
||||
"\n",
|
||||
"for k in range(100):\n",
|
||||
" new_times.append((times[k] - average) ** 2)\n",
|
||||
" summed_times += new_times[k]\n",
|
||||
"\n",
|
||||
"variance = summed_times / 100\n",
|
||||
"standard_deviation = (variance) ** 0.5\n",
|
||||
"\n",
|
||||
"print(f'The average time of a distance measurement is: {average:.3f} [s]')\n",
|
||||
"print(f'The standard deviantion of a distance measurement is: {standard_deviation:.3f} [s]')\n",
|
||||
"\n",
|
||||
"plt.hist(times)\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": "<font color=#6698FF> As the ultrasonic sensors refresh every 70 ms taking turns, every 140 ms will give new data. So we need to measure every 140 ms to get new data and not data stored in the buffer."
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Step 3: Using Distance Values to Model the Car\n",
|
||||
"\n",
|
||||
@ -254,14 +326,17 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"# TODO: Open the serial connection to KITT, set the motor speed\n",
|
||||
"serial = Serial('/dev/rfcomm3', 115200)\n",
|
||||
"serial.write(b'D150\\n')\n",
|
||||
"serial.write(b'M165\\n')\n",
|
||||
"\n",
|
||||
"# Initialize a list to store recorded data\n",
|
||||
"data = []\n",
|
||||
@ -272,22 +347,34 @@
|
||||
"\n",
|
||||
"while time.time() - start_time < recording_duration:\n",
|
||||
" # Send the status command to get the distance readings\n",
|
||||
" serial_port.write(b'S\\n')\n",
|
||||
" serial.write(b'S\\n')\n",
|
||||
" \n",
|
||||
" # Read the status response\n",
|
||||
" status = serial_port.read_until(b'\\x04').decode('utf-8')\n",
|
||||
" \n",
|
||||
" # TODO: Extract the distance values from the status response\n",
|
||||
" status = serial.read_until(b'\\x04').decode('utf-8')\n",
|
||||
" \n",
|
||||
" dist_L = None\n",
|
||||
" dist_R = None\n",
|
||||
"\n",
|
||||
" # TODO: Record current time and distances\n",
|
||||
" lines = status.splitlines()\n",
|
||||
"\n",
|
||||
" for line in lines:\n",
|
||||
" if \"Dist.\" in line:\n",
|
||||
" words = line.split()\n",
|
||||
" # Extract distance values based on their positions\n",
|
||||
"\n",
|
||||
" # Assign dist_L and dist_R accordingly\n",
|
||||
" dist_L = int(words[3])\n",
|
||||
" dist_R = int(words[5])\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" current_time = time.time() - start_time\n",
|
||||
" data.append([current_time, dist_L, dist_R])\n",
|
||||
" \n",
|
||||
" # Check if KITT is too close to the wall and stop if necessary\n",
|
||||
" if dist_L < 40 or dist_R < 40:\n",
|
||||
" serial_port.write(b'M150\\n') # Stop the car\n",
|
||||
" if dist_L < 130 or dist_R < 130:\n",
|
||||
" serial.write(b'M135\\n')\n",
|
||||
" time.sleep(0.75)\n",
|
||||
" serial.write(b'M150\\n') # Stop the car\n",
|
||||
" print(\"Stopping KITT to avoid collision.\")\n",
|
||||
" break # Exit the loop\n",
|
||||
" # Note: you can also add a small loop here and still read the stopping data\n",
|
||||
@ -295,15 +382,25 @@
|
||||
" time.sleep(0.1) # Wait before the next reading\n",
|
||||
"\n",
|
||||
"# Close the serial connection\n",
|
||||
"serial_port.close()\n",
|
||||
"serial.close()\n",
|
||||
"\n",
|
||||
"# TODO: Write the recorded data to a CSV file\n",
|
||||
"filepath = Path('./kitt_wall_data_165.csv')\n",
|
||||
"df = pd.DataFrame(data,columns = [\"Time\",\"Distance_L\",\"Distance_R\"])\n",
|
||||
"df.to_csv(filepath,index=False)\n",
|
||||
"!pwd\n",
|
||||
"# Recommeded file output: Files/Recordings/kitt_distance_data_{speed}.csv"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": "df.to_csv(Path(\"./kitt_wall_data_165.csv\"))"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"#### Processing the Recorded Data\n",
|
||||
"\n",
|
||||
@ -326,24 +423,25 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"\n",
|
||||
"motor_speed_value = 160 # Use the same motor speed as during recording\n",
|
||||
"\n",
|
||||
"# Load the recorded data from the CSV file\n",
|
||||
"csv_filename = f'Files/Recordings/kitt_distance_data_{motor_speed_value}.csv'\n",
|
||||
"csv_filename = f'./kitt_wall_data_160.csv'\n",
|
||||
"data = pd.read_csv(csv_filename)\n",
|
||||
"\n",
|
||||
"# Consider discarding the first few readings (inaccurate readings)\n",
|
||||
"data = data[2:]\n",
|
||||
"\n",
|
||||
"# TODO: Remove duplicate time stamps and merge L and R data\n",
|
||||
"# Create a new DataFrame to hold your processed data\n",
|
||||
"merged_data = []\n",
|
||||
"plotting_data = []\n",
|
||||
"\n",
|
||||
"# Iterate over the data\n",
|
||||
"for index, row in data.iterrows():\n",
|
||||
@ -352,16 +450,27 @@
|
||||
" dist_L = row['Distance_L']\n",
|
||||
" dist_R = row['Distance_R']\n",
|
||||
" \n",
|
||||
" # TODO: Decide which distance to use or how to merge them\n",
|
||||
" distance = \n",
|
||||
" distance = min(dist_L,dist_R)\n",
|
||||
"\n",
|
||||
" merged_data.append([time_stamp, distance])\n",
|
||||
" plotting_data.append([time_stamp, dist_L, dist_R])\n",
|
||||
"\n",
|
||||
"# Convert merged data to DataFrame\n",
|
||||
"merged_df = pd.DataFrame(merged_data, columns=['Time', 'Distance'])\n",
|
||||
"plotting_df = pd.DataFrame(plotting_data, columns=['Time', 'Dist_L', 'Dist_R'])\n",
|
||||
"\n",
|
||||
"# TODO: calculate velocity (change in distance over change in time)\n",
|
||||
"merged_df['Velocity'] = \n",
|
||||
"# Plotting the distance measured by the left and the right sensor\n",
|
||||
"plt.figure()\n",
|
||||
"plt.plot(plotting_df['Time'], plotting_df['Dist_L'], color='blue', label='Left sensor')\n",
|
||||
"plt.plot(plotting_df['Time'], plotting_df['Dist_R'], color='red', label='Right sensor')\n",
|
||||
"plt.xlabel('Time (s)')\n",
|
||||
"plt.ylabel('Distance (cm)')\n",
|
||||
"plt.title('Distance from the left and right sensor')\n",
|
||||
"plt.grid(True)\n",
|
||||
"plt.legend()\n",
|
||||
"plt.show()\n",
|
||||
"\n",
|
||||
"merged_df['Velocity'] = -merged_df['Distance'].diff().div(merged_df['Time'].diff())\n",
|
||||
"\n",
|
||||
"# Note: Use a negative sign because distance to the wall decreases as KITT moves forward\n",
|
||||
"\n",
|
||||
@ -387,12 +496,14 @@
|
||||
"plt.title('Velocity of KITT Over Time')\n",
|
||||
"plt.grid(True)\n",
|
||||
"plt.legend()\n",
|
||||
"plt.show()"
|
||||
"plt.show()\n",
|
||||
"\n",
|
||||
"print(merged_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"**Tips to Consider:**\n",
|
||||
"\n",
|
||||
@ -404,10 +515,10 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"# Define time for continuous measurement (smooth, no gaps)\n",
|
||||
"time_continuous = np.linspace(0, 10, 1000) # Time from 0 to 10 seconds, 1000 data points\n",
|
||||
@ -430,8 +541,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Step 5: Implementing the Distance Sensor Reading in Your KITT Class\n",
|
||||
"\n",
|
||||
@ -453,8 +564,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## The Microphones\n",
|
||||
"\n",
|
||||
@ -486,50 +597,18 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sounddevice_handle = sounddevice()\n",
|
||||
"for i in range(sounddevice_handle.get_device_count()):\n",
|
||||
" device_info = sounddevice_handle.get_device_info_by_index(i)\n",
|
||||
" print(i, device_info['name'])\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you have identified the index of the microphone array device from the list, you can initialize it by specifying the device index (`device_index`) and the desired sampling frequency (`Fs`).\n",
|
||||
"\n",
|
||||
"Here’s how you can open the audio stream using Sounddevice:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Initialize sounddevice again\n",
|
||||
"sounddevice_handle = sounddevice()\n",
|
||||
"\n",
|
||||
"# Specify the device index and sampling frequency\n",
|
||||
"device_index = 1 # Replace with the index of your microphone device\n",
|
||||
"Fs = 44100 # or 48000, depending on the field setup. Try to use 48000 when making your own recordings.\n",
|
||||
"\n",
|
||||
"# Open the audio stream with 5 channels, 16-bit audio format (paInt16), and the specified sample rate\n",
|
||||
"stream = sounddevice_handle.open(input_device_index=device_index,\n",
|
||||
" channels=5,\n",
|
||||
" format='float32',\n",
|
||||
" rate=Fs,\n",
|
||||
" input=True)"
|
||||
"for i, device in enumerate(sounddevice.query_devices()):\n",
|
||||
" print(i, device['name'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Step 2: Recording audio data\n",
|
||||
"\n",
|
||||
@ -541,48 +620,26 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"Fs = 44100 # Sampling frequency\n",
|
||||
"N = 2*Fs # 2 seconds of audio data\n",
|
||||
"samples,_ = stream.read(N)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"At this point, the microphone data is **interleaved**. This means that the first value (`data[0]`) corresponds to the first sample of microphone 0, the second value (`data[1]`) corresponds to the first sample of microphone 1, and so on. For example, `data[5]` contains the second sample of microphone 0, and the pattern continues. To visualize the interleaving of the data, refer to the table below:\n",
|
||||
"\n",
|
||||
"| data[0] | data[1] | data[2] | data[3] | data[4] | data[5] | data[6] | data[7] | ... |\n",
|
||||
"|---------|---------|---------|---------|---------|---------|---------|---------|-----|\n",
|
||||
"| mic 0 | mic 1 | mic 2 | mic 3 | mic 4 | mic 0 | mic 1 | mic 2 | ... |\n",
|
||||
"| frame 0 | frame 0 | frame 0 | frame 0 | frame 0 | frame 1 | frame 1 | frame 1 | ... |\n",
|
||||
"\n",
|
||||
"#### Deinterleaving the data\n",
|
||||
"\n",
|
||||
"To work with the data from each microphone independently, the **interleaved data** must be split into separate streams for each microphone. This process is called **deinterleaving**.\n",
|
||||
"\n",
|
||||
"Write a function to deinterleave the audio data and store the samples from each microphone in a separate numpy array:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"Fs = 48000\n",
|
||||
"duration = 5\n",
|
||||
"N = int(Fs * duration)\n",
|
||||
"\n",
|
||||
"# TODO: Reshape the data into a matrix with 5 columns (one for each microphone)"
|
||||
"sounddevice.default.device = 15 # or a substring of its name\n",
|
||||
"sounddevice.default.samplerate = Fs\n",
|
||||
"\n",
|
||||
"samples = sounddevice.rec(N, samplerate=Fs, channels=5)\n",
|
||||
"sounddevice.wait()\n",
|
||||
"print(samples.shape)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Plotting the audio data\n",
|
||||
"\n",
|
||||
@ -590,19 +647,34 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"### Student Version ###\n",
|
||||
"samples_reshaped = np.array(samples)\n",
|
||||
"fig, ax = plt.subplots(5,1,figsize=(20,30))\n",
|
||||
"\n",
|
||||
"# TODO: Plot the data for each microphone"
|
||||
"t = np.arange(0,N/Fs,1/Fs)\n",
|
||||
"ax[0].plot(t,samples_reshaped[:,0])\n",
|
||||
"ax[1].plot(t,samples_reshaped[:,1])\n",
|
||||
"ax[2].plot(t,samples_reshaped[:,2])\n",
|
||||
"ax[3].plot(t,samples_reshaped[:,3])\n",
|
||||
"ax[4].plot(t,samples_reshaped[:,4])\n",
|
||||
"for i,ax_in in enumerate(ax):\n",
|
||||
" ax_in.set_xlabel('Time (s)')\n",
|
||||
" ax_in.set_ylabel('Amplitude')\n",
|
||||
" ax_in.set_title(f'Mic {i}')\n",
|
||||
"fig.show()\n",
|
||||
"\n",
|
||||
"from scipy.io import wavfile\n",
|
||||
"wavfile.write(\"./audio_beacon_67676767_at_x345_y101.wav\", Fs, samples_reshaped.astype(np.float32))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Step 3: Testing the microphone array\n",
|
||||
"Below are some experiments you can perform to test the microphone array, and develop the code.\n",
|
||||
@ -619,8 +691,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"*Bonus Tasks - Optional*\n",
|
||||
"\n",
|
||||
@ -631,8 +703,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"### Mid-term assessment 2.2 and report\n",
|
||||
"\n",
|
||||
@ -659,8 +731,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## FAQ\n",
|
||||
"\n",
|
||||
@ -685,8 +757,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"**I see random numbers from sensors for large distances. Is my sensor damaged ?**\n",
|
||||
"\n",
|
||||
@ -694,8 +766,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"**Are the ultrasonic sensor measurements for the left and the right side done at exactly the same time ?**\n",
|
||||
"\n",
|
||||
|
||||
BIN
Manual/audio_beacon_67676767_10s.wav
Normal file
BIN
Manual/audio_beacon_67676767_10s.wav
Normal file
Binary file not shown.
BIN
Manual/audio_beacon_67676767_10s_driving.wav
Normal file
BIN
Manual/audio_beacon_67676767_10s_driving.wav
Normal file
Binary file not shown.
BIN
Manual/audio_beacon_67676767_at_x180_y333.wav
Normal file
BIN
Manual/audio_beacon_67676767_at_x180_y333.wav
Normal file
Binary file not shown.
BIN
Manual/audio_beacon_67676767_at_x345_y101.wav
Normal file
BIN
Manual/audio_beacon_67676767_at_x345_y101.wav
Normal file
Binary file not shown.
BIN
Manual/clapping.wav
Normal file
BIN
Manual/clapping.wav
Normal file
Binary file not shown.
21
Manual/kitt_wall_data_160.csv
Normal file
21
Manual/kitt_wall_data_160.csv
Normal file
@ -0,0 +1,21 @@
|
||||
Time,Distance_L,Distance_R
|
||||
0.18527626991271973,293,293
|
||||
0.4374089241027832,293,293
|
||||
0.6661174297332764,293,291
|
||||
0.8378303050994873,291,288
|
||||
1.0300233364105225,287,283
|
||||
1.2077486515045166,281,276
|
||||
1.3909521102905273,273,267
|
||||
1.5912683010101318,263,257
|
||||
1.7906908988952637,253,257
|
||||
1.9916656017303467,240,245
|
||||
2.179856777191162,226,232
|
||||
2.338029146194458,213,220
|
||||
2.5159542560577393,198,206
|
||||
2.7149744033813477,198,190
|
||||
2.9028022289276123,182,174
|
||||
3.0969913005828857,166,157
|
||||
3.2479021549224854,148,140
|
||||
3.4600577354431152,130,122
|
||||
3.6272897720336914,112,103
|
||||
3.8329083919525146,93,84
|
||||
|
14
Manual/kitt_wall_data_165.csv
Normal file
14
Manual/kitt_wall_data_165.csv
Normal file
@ -0,0 +1,14 @@
|
||||
Time,Distance_L,Distance_R
|
||||
0.14345836639404297,345,345
|
||||
0.34053707122802734,345,345
|
||||
0.5649638175964355,344,345
|
||||
0.8061964511871338,337,341
|
||||
1.0228962898254395,327,333
|
||||
1.2599327564239502,314,306
|
||||
1.526465654373169,297,288
|
||||
1.7780358791351318,257,268
|
||||
1.948960781097412,233,246
|
||||
2.1302239894866943,207,221
|
||||
2.321249485015869,179,194
|
||||
2.565399646759033,151,167
|
||||
2.794302463531494,120,136
|
||||
|
BIN
student_code/__pycache__/car.cpython-313.pyc
Normal file
BIN
student_code/__pycache__/car.cpython-313.pyc
Normal file
Binary file not shown.
0
student_code/controller.py
Normal file
0
student_code/controller.py
Normal file
Loading…
x
Reference in New Issue
Block a user