]> rtime.felk.cvut.cz Git - hubacji1/psp.git/blobdiff - api/psp.h
Use forward parking macro
[hubacji1/psp.git] / api / psp.h
index ed86cb934e1470cc4f05e6e66a0a681f95b2e71e..2294a5b3f4175539062ebee59cd01b86ecc634f4 100644 (file)
--- a/api/psp.h
+++ b/api/psp.h
@@ -1,9 +1,14 @@
 #ifndef PSP_H
 #define PSP_H
 
+#include <tuple>
+#include <vector>
+
 #include "bcar.h"
 #include "pslot.h"
 
+#define FORWARD_PARKING 1
+
 /*! \brief Parking Slot Planner basic class.
 
 \param cc Current bicycle car.
 */
 class PSPlanner {
         private:
-                BicycleCar *cc_ = nullptr;
-                BicycleCar *gc_ = new BicycleCar();
-                ParkingSlot *ps_ = new ParkingSlot();
+                BicycleCar cc_;
+                BicycleCar gc_;
+                ParkingSlot ps_;
+
+                unsigned int c_ = 0; // number of cusps
+                std::vector<BicycleCar> cusps_;
+
+                // find entry to slot
+                void fe_parallel();
+                void fe_perpendicular();
+                // find entry to slot by reverse approach
+                void fer_parallel();
+                void fer_perpendicular();
+                // set goal car
+                void gc_to_4();
         public:
+                /*! \brief Return `true` if there is collision.
+
+                If the parking slot `ps` collide with current car `cc`,
+                return `true`.
+
+                This method depends on `intersection` function that
+                returns `true` or `false` if two line segments collide.
+                Each line segment of current car `cc` (borders) is
+                checked to each line segment of parking slot `ps`
+                (parking slot lines).
+                */
+                bool collide();
+                /*! \brief Return parking direction
+
+                Return `true` if the direction of the parking in the
+                slot is forward.
+                */
+                bool forward();
+                /*! \brief Guess goal car
+
+                Set the goal car guessed from the parking slot.
+                */
+                void guess_gc();
+                /*! \brief Return last maneuver to the parking slot.
+
+                Return path from entry point towards parking slot, such
+                that ``cc`` is inside the parking slot at the end.
+                */
+                std::vector<BicycleCar> last_maneuver();
+                /*! \brief Has current car `cc` left?
+
+                Return `true` if the current car `cc` left the parking
+                slot `ps`;
+                */
+                bool left();
+                /*! \brief Is the goal car `gc` parked?
+
+                Return `true` if the goal car `gc` is inside the
+                parking slot `ps`.
+                */
+                bool parked();
+                /*! \brief Return possible starts of parking maneuver
+
+                When any `BicycleCar` of possible inits is reached, then
+                parking maneuver is a peace of cake.
+
+                \param cnt Number of inits.
+                \param dist Distance between inits.
+                */
+                std::vector<BicycleCar> possible_goals(
+                        unsigned int cnt,
+                        double dist
+                );
+                std::vector<BicycleCar> possible_goals()
+                {
+                        return this->possible_goals(10, 0.5);
+                }
+
+                // find entry
+                /*! \brief Find entry to the parking slot.
+                */
+                void fe();
+                /*! \brief Find entry to slot by reverse approach.
+
+                See `Vorobieva2015` for more information.
+                */
+                void fer();
+
                 // getters, setters
-                BicycleCar *cc() { return this->cc_; }
-                BicycleCar *gc() { return this->gc_; }
-                ParkingSlot *ps() { return this->ps_; }
+                BicycleCar &cc() { return this->cc_; }
+                BicycleCar &gc() { return this->gc_; }
+                ParkingSlot &ps() { return this->ps_; }
+
+                unsigned int c() const { return this->c_; }
+                std::vector<BicycleCar> &cusps() { return this->cusps_; }
 
                 PSPlanner();
 };