]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - src/entry_positions_range.cc
e0e18d29740ef8c9a58f713177776942294d9259
[hubacji1/bcar.git] / src / entry_positions_range.cc
1 /*
2  * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
3  *
4  * SPDX-License-Identifier: GPL-3.0-only
5  */
6
7 #include <iostream>
8 #include <vector>
9 #include "pslot.hh"
10
11 #define CAR_CURB_TO_CURB 10.802166641822163
12 #define CAR_FRONT_TRACK 1.511
13 #define CAR_WIDTH 1.771
14 #define CAR_WHEELBASE 2.588
15 #define CAR_DISTANCE_FROM_REAR_AXLE_TO_FRONT 3.427
16 #define CAR_LENGTH 4.084
17
18 #define SLOT_MAX_WIDTH (CAR_WIDTH + 0.5)
19 #define SLOT_STEP_WIDTH 0.01
20
21 #define PARKING_SPEED -0.001
22 #define DELTA_ANGLE_TO_SLOT 0.0001
23
24 int main(int argc, char** argv)
25 {
26         if (argc != 3) {
27                 std::cerr << "Number of direction changes needed." << std::endl;
28                 exit(1);
29         }
30         int max_cusp = atoi(argv[1]);
31         double slot_length = atof(argv[2]);
32         std::cout << std::fixed;
33         std::cerr << std::fixed;
34
35         bcar::BicycleCar c;
36         c.ctc(CAR_CURB_TO_CURB);
37         c.ft(CAR_FRONT_TRACK);
38         c.w(CAR_WIDTH);
39         c.wb(CAR_WHEELBASE);
40         c.df(CAR_DISTANCE_FROM_REAR_AXLE_TO_FRONT);
41         c.len(CAR_LENGTH);
42
43         bcar::Point zp(0.0, 0.0);
44         double zh = 0.0;
45
46         for (double w = c.w() + 4.5 * SLOT_STEP_WIDTH; w < SLOT_MAX_WIDTH;
47                         w += SLOT_STEP_WIDTH) {
48                 bcar::ParkingSlot s(zp, zh, w, slot_length);
49                 s.set_parking_speed(PARKING_SPEED);
50                 s.set_max_cusp(max_cusp);
51                 s.set_delta_angle_to_slot(DELTA_ANGLE_TO_SLOT);
52                 double d = 0;
53                 double fd = 0;
54                 unsigned int cd = 0;
55                 if (s._entries.size() > 0) {
56                         for (unsigned int i = 1; i < s._entries.size(); i++) {
57                                 double dd = std::abs(s._entries[i].front().h()
58                                         - s._entries[i - 1].front().h());
59                                 if (dd <= 0.0001) {
60                                         d += dd;
61                                 } else {
62                                         fd += dd;
63                                         cd += 1;
64                                 }
65                         }
66                         std::cout << w << " " << slot_length << " ";
67                         std::cout << max_cusp << " ";
68                         std::cout << d << " " << fd << " " << cd;
69                         std::cout << std::endl;
70                 }
71         }
72         return 0;
73 }