Skip to content

Commit

Permalink
Merge pull request #124 from acoustic-warfare/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
IvarNilsson authored Aug 8, 2024
2 parents 7559164 + d23c0d0 commit f28bb44
Show file tree
Hide file tree
Showing 35 changed files with 1,937 additions and 924 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ dkms.conf
/udp/recorded
/.env
.idea/
.venv

math_toolbox/recorded_data
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mavx2 -Ofast -save-temps -fverbose-asm -ffloat-store -ffast-math -fno-rounding-math")

set(SOURCES)

# Documentation
add_custom_target(doc
COMMAND doxygen ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
Expand All @@ -19,4 +17,14 @@ add_subdirectory(src/dsp)
add_subdirectory(src/audio)
add_subdirectory(src/aw_processing_unit)
add_subdirectory(src/target_handler)
add_subdirectory(src/aw_control_unit)
add_subdirectory(src/aw_control_unit)

set(SOURCES src/main.cpp)
add_executable(beamformer ${SOURCES})

target_link_libraries(beamformer
awcu
awpu
targetHandler
gps
)
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ RUN git submodule init \
&& cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_WITH_SSL=ON \
&& cmake --build build/ --target install


RUN git clone https://github.com/Rookfighter/pso-cpp.git && \
mkdir -p pso-cpp/build && \
cd pso-cpp/build && \
cmake .. && make install

FROM deps AS build

WORKDIR /
Expand All @@ -95,9 +89,12 @@ RUN ldconfig
# Create app directory
RUN mkdir -p /usr/src/app

RUN useradd -rm -d /home/newuser -s /bin/bash -g root -G sudo -G audio -u 1000 newuser
RUN useradd -rm -d /home/newuser -s /bin/bash -g root -G sudo,audio,video -u 1000 newuser
RUN apt-get install -y mpv
USER newuser



# Set working directory
WORKDIR /usr/src/app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import math

## MAGIC NUMBERS START##
intersection_grace_radius = 1 # meters between two vectors to find a intersect
intersection_grace_radius = 0.5 # meters between two vectors to find a intersect

min_track_distance = 1
max_track_distance = 2
min_track_distance = 0.2
max_track_distance = 0.5
track_distance_factor = 1 # factor to change the kill_time

min_track_kill_time = 1 # min numger of second this is a baseline for new targets with very few hits
max_track_kill_time = 2 # max number of seconds the kill_time can acheve for a target with many hits
min_track_kill_time = 0.1 # min numger of second this is a baseline for new targets with very few hits
max_track_kill_time = 0.4 # max number of seconds the kill_time can acheve for a target with many hits
kill_time_factor = 1 # factor to change the kill_time

plt_pause_on = False
plt_pause_on = True # True/False = 3d plot/no 3d plot, no 3d plot makes the program run faster
plt_pause_factor = 0.1 # make the pauses shorter
## MAGIC NUMBERS END ##

Expand Down Expand Up @@ -67,16 +67,14 @@ def read_file(direction_1, direction_2, timestamps, file_name):
return direction_1, direction_2, timestamps


direction_1, direction_2, timestamps = read_file(direction_1, direction_2, timestamps, "tests/Targets2.txt")
direction_1, direction_2, timestamps = read_file(direction_1, direction_2, timestamps, "math_toolbox/recorded_data/Targets_3m_dator.txt")


def triangulatePoints(r1, e1, r2, e2):
n = cross(e1, e2)
# print("n", n)

t1 = dot(cross(e2, n), (r2 - r1)) / dot(n, n)
t2 = dot(cross(e1, n), (r2 - r1)) / dot(n, n)
# print("t", t1, t2)

p1 = r1 + t1 * e1
p2 = r2 + t2 * e2
Expand Down Expand Up @@ -208,7 +206,7 @@ def plot_best_target(ax, colors, max_nr_colors, best_target, best_track_id):
def plot_all_targets(ax, colors, max_nr_colors, target_list):
targets = []
for i, (track_point, time_since_last_hit, total_hits, timestamp) in enumerate(target_list):
if total_hits > 0:
if total_hits > 10:
color = colors[i % max_nr_colors]
targets.append(
ax.scatter(
Expand Down Expand Up @@ -265,16 +263,16 @@ def setup_3d_plot(ax):
p = (p1 + p2) / 2

current_time = timestamps[i]
if np.linalg.norm(p1 - p2) > intersection_grace_radius or p[2] < 0 or np.linalg.norm(p) > 20:
if np.linalg.norm(p1 - p2) > intersection_grace_radius or p[2] < 0 or np.linalg.norm(p) > 20 or p[2] < 1:
p = np.zeros(3)

if p.all() == 0:
failed_intersect_count += 1
else:
if plt_pause_on:
print((current_time - last_hit_time) * 10**-9)
# print((current_time - last_hit_time) * 10**-9)
plt.pause(
(current_time - last_hit_time) * 10**-9 * plt_pause_on * plt_pause_factor
(current_time - last_hit_time) * 10**-9 * plt_pause_on * plt_pause_factor + 0.000000001
) # Pause for a short time to update the plot
last_hit_time = current_time

Expand Down
Loading

0 comments on commit f28bb44

Please sign in to comment.