From 71e0bdd3741f494ae9b66d4dd0af3b899e0e3369 Mon Sep 17 00:00:00 2001 From: Edvin Date: Wed, 7 May 2025 10:21:12 +0200 Subject: Fixed some issues with bt reading data before LIDAR is done --- LIDAR/LIDAR.cpp | 30 +++++++++++++++++------------- bt.py | 4 ---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/LIDAR/LIDAR.cpp b/LIDAR/LIDAR.cpp index 7b0b6f0..9a60bac 100644 --- a/LIDAR/LIDAR.cpp +++ b/LIDAR/LIDAR.cpp @@ -115,7 +115,7 @@ int main(int argc, const char * argv[]) { std::ifstream buf_file_i; int distances[360]; - int a, b; + // int a, b; printf("Ultra simple LIDAR data grabber for SLAMTEC LIDAR.\n" "Version: %s\n", SL_LIDAR_SDK_VERSION); @@ -296,18 +296,22 @@ int main(int argc, const char * argv[]) { } buf_file_o.close(); - buf_file_i.open("distances_buf.txt"); - outfile.open("distances.txt"); - - a = 0; - b = 0; - while (buf_file_i >> a >> b) { - outfile << a << " " << b << "\n"; - printf("Angle: %i, Dist: %i\n", a, b); - } - - buf_file_i.close(); - outfile.close(); + + // Instead of moving all values to file, rename buffer file + // buf_file_i.open("distances_buf.txt"); + // outfile.open("distances.txt"); + + // a = 0; + // b = 0; + // while (buf_file_i >> a >> b) { + // outfile << a << " " << b << "\n"; + // printf("Angle: %i, Dist: %i\n", a, b); + //} + std::rename("distances_buf.txt", "distances.txt"); + + + // buf_file_i.close(); + // outfile.close(); } if (ctrl_c_pressed){ diff --git a/bt.py b/bt.py index a341f22..8ebacdf 100755 --- a/bt.py +++ b/bt.py @@ -82,12 +82,8 @@ while read != "1000": f.close() for i in range(359): - # print(f"({i}, {distances[i]})") recv_sock.send(f"{distances[i]}, ".encode()) - # message = message + f"{distances[i]}, " recv_sock.send(f"{distances[359]}\n".encode()) - # message = message + f"{distances[360]}\n" - # recv_sock.send(message.encode()) print("Shutting down...") server_sock.close() -- cgit v1.2.3