]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add steer in slot method
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 19 Jul 2021 07:57:52 +0000 (09:57 +0200)
committerJiri Vlasak <jiri.vlasak.2@cvut.cz>
Tue, 20 Jul 2021 14:49:17 +0000 (16:49 +0200)
incl/pslot.hh
src/pslot.cc

index b7d3956cac05d7b9fa986a564ca37a2ddaaf11c8..1562631eb842d74b924909259a084501464a8926 100644 (file)
@@ -89,6 +89,15 @@ public:
         */
        std::vector<BicycleCar> drive_in_slot(BicycleCar c, unsigned int& max);
 
+       /*! \brief Steer car `c` into the parking slot `this`.
+        *
+        * `steer_in_slot` returns the complete path as the list of `Pose`s, not
+        * just cusp `BicycleCar`s as `drive_to_slot`.
+        *
+        * \param c Starting bicycle car.
+        */
+       std::vector<Pose> steer_in_slot(BicycleCar c);
+
        /*! \brief Find entry.
         *
         * \param c For which `BicycleCar` should entry be found?
index a10b17cb74bda952917cafb416299b50f5b3cf53..fb42ab0d6f728d9648e38f909d6cec5c215c85cb 100644 (file)
@@ -174,6 +174,23 @@ ParkingSlot::drive_in_slot(BicycleCar c, unsigned int& max)
        return std::vector<BicycleCar>();
 }
 
+std::vector<Pose>
+ParkingSlot::steer_in_slot(BicycleCar c)
+{
+       std::vector<Pose> path;
+       while (!this->parked(c)) {
+               path.push_back(c);
+               c.next();
+               if (this->collide(c)) {
+                       c.sp(c.sp() * -1.0);
+                       c.next();
+                       c.st(c.st() * -1.0);
+               }
+       }
+       path.push_back(c);
+       return path;
+}
+
 PoseRange
 ParkingSlot::fe(BicycleCar c, unsigned int& max)
 {