5 // When the file with precomputed entries is ready.
6 //#include "fiat_punto.h"
20 std::cout << std::fixed;
21 std::cerr << std::fixed;
22 assert(jvi["slot"] != Json::nullValue);
26 jvi["slot"][0][0].asDouble(), jvi["slot"][0][1].asDouble(),
27 jvi["slot"][1][0].asDouble(), jvi["slot"][1][1].asDouble(),
28 jvi["slot"][2][0].asDouble(), jvi["slot"][2][1].asDouble(),
29 jvi["slot"][3][0].asDouble(), jvi["slot"][3][1].asDouble());
32 if (s.parallel() && !s.right()) {
39 pr.reflect(s.entry());
41 //std::cerr << ip_time.scnt() << std::endl;
42 // The following uses precomputed entries and needs `"fiat_punto.h"` to
44 //auto pr = get_fiat_punto_entry(s.len(), s.w());
45 //pr = s.recompute_entry(pr);
51 std::vector<bcar::Pose> ispath;
53 while (!c.rf().on_right_side_of(s.entry())) {
58 while (c.lf().on_right_side_of(s.entry())) {
65 for (auto &n : s.drive_in_slot(c)) {
69 jvi["goal"][0] = pr.x();
70 jvi["goal"][1] = pr.y();
71 jvi["goal"][2] = pr.b();
72 jvi["goal"][3] = pr.e();
73 jvi["goal_inside"][0] = ispath.back().x();
74 jvi["goal_inside"][1] = ispath.back().y();
75 jvi["goal_inside"][2] = ispath.back().h();
77 unsigned int icnt = 0;
78 unsigned int rcnt = 0;
79 unsigned int bcnt = 0;
80 unsigned int ncnt = 0; // not better counter
81 Json::Value best_path;
90 if (pj["path"] != Json::nullValue) {
91 double gc = pj["goal_cc"].asDouble();
93 if (cost == 0.0 || gc < cost) {
94 if (gc < 0.75 * cost) {
97 best_path = pj["path"];
110 double elapsed = p.scnt();
113 for (auto p: ispath) {
114 jvo["ispath"][i][0] = p.x();
115 jvo["ispath"][i][1] = p.y();
116 jvo["ispath"][i][2] = p.h();
119 jvo["init"] = jvi["init"];
120 jvo["slot"] = jvi["slot"];
121 jvo["obst"] = jvi["obst"];
122 jvo["entry"] = jvi["goal"];
123 jvo["goal"][0] = ispath.back().x();
124 jvo["goal"][1] = ispath.back().y();
125 jvo["goal"][2] = ispath.back().h();
126 jvo["time"] = elapsed;
127 jvo["icnt"] = p.icnt();
131 jvo["path"] = best_path;
132 jvo["goal_cc"] = cost;
133 std::cout << jvo << std::endl;