X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/psp.git/blobdiff_plain/0c41df6c30dfc8a802fcb82c26ba7250343aa568..d0b695ff7c42e5deee8badcd8da1752c37089f6f:/api/psp.h diff --git a/api/psp.h b/api/psp.h index 529c04d..2294a5b 100644 --- a/api/psp.h +++ b/api/psp.h @@ -2,10 +2,13 @@ #define PSP_H #include +#include #include "bcar.h" #include "pslot.h" +#define FORWARD_PARKING 1 + /*! \brief Parking Slot Planner basic class. \param cc Current bicycle car. @@ -17,6 +20,18 @@ class PSPlanner { BicycleCar cc_; BicycleCar gc_; ParkingSlot ps_; + + unsigned int c_ = 0; // number of cusps + std::vector 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. @@ -30,12 +45,51 @@ class PSPlanner { (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 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 possible_goals( + unsigned int cnt, + double dist + ); + std::vector possible_goals() + { + return this->possible_goals(10, 0.5); + } // find entry /*! \brief Find entry to the parking slot. @@ -52,32 +106,10 @@ class PSPlanner { BicycleCar &gc() { return this->gc_; } ParkingSlot &ps() { return this->ps_; } + unsigned int c() const { return this->c_; } + std::vector &cusps() { return this->cusps_; } + PSPlanner(); }; -/*! \brief Return intersection of two line segments. - -The output is tuple `std::tuple`, where the first -value is true when there is an intersection and false otherwise. The -second and third parameters in the return tuple are coordinates of the -intersection. - -\see https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection - -\param x1 First line segment first `x` coordinate. -\param y1 First line segment first `y` coordinate. -\param x2 First line segment second `x` coordinate. -\param y2 First line segment second `y` coordinate. -\param x3 Second line segment first `x` coordinate. -\param y3 Second line segment first `y` coordinate. -\param x4 Second line segment second `x` coordinate. -\param y4 Second line segment second `y` coordinate. -*/ -std::tuple intersect( - double x1, double y1, - double x2, double y2, - double x3, double y3, - double x4, double y4 -); - #endif /* PSP_H */