]> rtime.felk.cvut.cz Git - hubacji1/psp.git/commitdiff
Use backward perpendicular parking
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Fri, 5 Jun 2020 16:12:28 +0000 (18:12 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 15 Jul 2020 16:00:51 +0000 (18:00 +0200)
src/psp.cc

index 12d2d113eee9e1105ed58f47ab1c51699a91ca0a..35e92ac38ea3a26c73a8e1472f52c82d62cead45 100644 (file)
@@ -102,6 +102,7 @@ void PSPlanner::guess_gc()
                 x += (this->gc().dr() + 0.01) * cos(h);
                 y += (this->gc().w() / 2 + 0.01) * sin(h + dts);
                 y += (this->gc().dr() + 0.01) * sin(h);
+#if 0
         } else {
                 // Forward parking
                 double entry_width = edist(
@@ -142,6 +143,20 @@ void PSPlanner::guess_gc()
                 //x += move2 * cos(h + dts);
                 //y += move2 * sin(h + dts);
                 //h += dts - M_PI / 2;
+#endif
+        } else {
+                // Backward parking
+                double entry_width = edist(
+                        this->ps().x1(), this->ps().y1(),
+                        this->ps().x4(), this->ps().y4()
+                );
+                x += entry_width / 2 * cos(h);
+                y += entry_width / 2 * sin(h);
+                h = atan2(
+                        this->ps().y1() - this->ps().y2(),
+                        this->ps().x1() - this->ps().x2()
+                );
+                while (h < 0) h += 2 * M_PI;
         }
         while (h > M_PI)
                 h -= 2 * M_PI;