|
@@ -1,5 +1,14 @@
|
|
|
{
|
|
|
"cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 2,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import numpy as np"
|
|
|
+ ]
|
|
|
+ },
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": 4,
|
|
@@ -20,7 +29,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 5,
|
|
|
+ "execution_count": 15,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
@@ -35,11 +44,12 @@
|
|
|
" self.is_fixed = not (cfg_exp['target_angle'] == 'random')\n",
|
|
|
" self.phi_initial = np.random.rand() * 2 * np.pi if not self.is_fixed else np.deg2rad(int(cfg_exp['target_angle']))\n",
|
|
|
" self.rho = self.floor_radius - cfg_exp['target_radius'] # constant, in meters \n",
|
|
|
+ " self.last_tgt_x, self.last_tgt_y = None, None\n",
|
|
|
" \n",
|
|
|
" def _correct_angle(self, phi):\n",
|
|
|
" return (2*np.pi - phi) + np.deg2rad(self.angle_corr)\n",
|
|
|
" \n",
|
|
|
- " def generate_islands(time_from_start):\n",
|
|
|
+ " def generate_islands(self, time_from_start):\n",
|
|
|
" def get_fixed_island_position(time_from_start):\n",
|
|
|
" # returns the angle of the island (in polar coordinates)\n",
|
|
|
" # all angles are in radians\n",
|
|
@@ -84,18 +94,19 @@
|
|
|
" # target island\n",
|
|
|
" if self.is_fixed:\n",
|
|
|
" phi = get_fixed_island_position(time_from_start)\n",
|
|
|
- " phi = _correct_angle(phi) # correct for the camera orientation\n",
|
|
|
+ " phi = self._correct_angle(phi) # correct for the camera orientation\n",
|
|
|
" x, y = self.rho * np.sin(phi), self.rho * np.cos(phi)\n",
|
|
|
" else:\n",
|
|
|
" x, y = get_new_xy([])\n",
|
|
|
- " islands = [Island(x, y, island_radius, 2, False)] # sound 2 is always target\n",
|
|
|
+ " islands = [Island(x, y, self.cfg_exp['target_radius'], 2, False)] # sound 2 is always target\n",
|
|
|
+ " self.last_tgt_x, self.last_tgt_y = x, y\n",
|
|
|
"\n",
|
|
|
" # distractors\n",
|
|
|
" sound_ids = [3 + i for i in range(self.cfg_exp['distractor_islands'])]\n",
|
|
|
- " if distractors > 0:\n",
|
|
|
+ " if self.cfg_exp['distractor_islands'] > 0:\n",
|
|
|
" for i in range(self.cfg_exp['distractor_islands']):\n",
|
|
|
" x, y = get_new_xy(islands)\n",
|
|
|
- " islands.append(Island(x, y, self.cfg_exp['target_radius'], sound_ids.pop(random.randint(0, len(sound_ids)-1)), True))\n",
|
|
|
+ " islands.append(Island(x, y, self.cfg_exp['target_radius'], sound_ids.pop(np.random.randint(0, len(sound_ids))), True))\n",
|
|
|
"\n",
|
|
|
" return islands # always a list of Islands"
|
|
|
]
|
|
@@ -124,7 +135,7 @@
|
|
|
"name": "python",
|
|
|
"nbconvert_exporter": "python",
|
|
|
"pygments_lexer": "ipython3",
|
|
|
- "version": "3.8.10"
|
|
|
+ "version": "3.8.8"
|
|
|
}
|
|
|
},
|
|
|
"nbformat": 4,
|