]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add entry positions range executable
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 3 Jan 2022 13:44:28 +0000 (14:44 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 3 Jan 2022 13:44:28 +0000 (14:44 +0100)
CMakeLists.txt
src/entry_positions_range.cc [new file with mode: 0644]

index 6625d7ace5e3254fc1384bfa1f78b820d9ed3e3c..dc978e617f3d2e7eff999406f6aa8868c2b9d527 100644 (file)
@@ -23,6 +23,9 @@ target_link_libraries(compute_pslot_table pslot)
 add_executable(prove_parallel_slot src/prove_parallel_slot.cc)
 target_link_libraries(prove_parallel_slot pslot)
 
+add_executable(entry_positions_range src/entry_positions_range.cc)
+target_link_libraries(entry_positions_range pslot)
+
 add_executable(compare_to_vorobieva src/compare_to_vorobieva.cc)
 target_link_libraries(compare_to_vorobieva pslot)
 
diff --git a/src/entry_positions_range.cc b/src/entry_positions_range.cc
new file mode 100644 (file)
index 0000000..6bc82a3
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#include <iostream>
+#include <vector>
+#include "pslot.hh"
+
+#define CAR_CURB_TO_CURB 10.802166641822163
+#define CAR_FRONT_TRACK 1.511
+#define CAR_WIDTH 1.771
+#define CAR_WHEELBASE 2.588
+#define CAR_DISTANCE_FROM_REAR_AXLE_TO_FRONT 3.427
+#define CAR_LENGTH 4.084
+
+#define SLOT_MAX_WIDTH (CAR_WIDTH + 0.5)
+#define SLOT_STEP_WIDTH 0.01
+
+#define PARKING_SPEED -0.001
+#define DELTA_ANGLE_TO_SLOT 0.0001
+
+int main(int argc, char** argv)
+{
+       if (argc != 3) {
+               std::cerr << "Number of direction changes needed." << std::endl;
+               exit(1);
+       }
+       int max_cusp = atoi(argv[1]);
+       double slot_length = atof(argv[2]);
+       std::cout << std::fixed;
+       std::cerr << std::fixed;
+
+       bcar::BicycleCar c;
+       c.ctc(CAR_CURB_TO_CURB);
+       c.ft(CAR_FRONT_TRACK);
+       c.w(CAR_WIDTH);
+       c.wb(CAR_WHEELBASE);
+       c.df(CAR_DISTANCE_FROM_REAR_AXLE_TO_FRONT);
+       c.len(CAR_LENGTH);
+
+       bcar::Point zp(0.0, 0.0);
+       double zh = 0.0;
+
+       for (double w = c.w() + 4.5 * SLOT_STEP_WIDTH; w < SLOT_MAX_WIDTH;
+                       w += SLOT_STEP_WIDTH) {
+               bcar::ParkingSlot s(zp, zh, w, slot_length);
+               s.set_parking_speed(PARKING_SPEED);
+               s.set_max_cusp(max_cusp);
+               s.set_delta_angle_to_slot(DELTA_ANGLE_TO_SLOT);
+               auto pr = s.fe(c);
+               double d = 0;
+               double fd = 0;
+               unsigned int cd = 0;
+               if (s._entries.size() > 0) {
+                       for (unsigned int i = 1; i < s._entries.size(); i++) {
+                               double dd = std::abs(s._entries[i].front().h()
+                                       - s._entries[i - 1].front().h());
+                               if (dd <= 0.0001) {
+                                       d += dd;
+                               } else {
+                                       fd += dd;
+                                       cd += 1;
+                               }
+                       }
+                       std::cout << w << " " << slot_length << " ";
+                       std::cout << max_cusp << " ";
+                       std::cout << d << " " << fd << " " << cd;
+                       std::cout << std::endl;
+               }
+       }
+       return 0;
+}