- Workaround to not working `fe()` for perpendicular parking slot.
- Return maneuver as vector of BicycleCars.
- `FORWARD_PARKING` macro.
+- Shrink to perfect length when too big parking slot.
### Fixed
- Possible goals for right parallel parking slot.
{
return this->possible_goals(10, 0.5);
}
+ /*! \brief Shrink parking slot to perfect length.
+
+ Based on goal car dimensions, shrink `p1` and `p2`
+ towards the `p3` and `p4`. (Because backward parallel
+ parking).
+
+ NOTE: This function works for parallel parking only.
+ */
+ void shrink_to_perfect_len();
// find entry
/*! \brief Find entry to the parking slot.
return pi;
}
+void PSPlanner::shrink_to_perfect_len()
+{
+ if (!this->ps().parallel())
+ return;
+ double perfect_len = this->gc().perfect_parking_slot_len();
+ if (edist(
+ this->ps().x1(), this->ps().y1(),
+ this->ps().x4(), this->ps().y4()
+ ) < perfect_len)
+ return;
+ double h = this->ps().heading();
+ h -= M_PI;
+ while (h < 0) h += 2 * M_PI;
+ double ch = perfect_len * cos(h);
+ double sh = perfect_len * sin(h);
+ this->ps().border(
+ this->ps().x4() + ch, this->ps().y4() + sh,
+ this->ps().x3() + ch, this->ps().y3() + sh,
+ this->ps().x3(), this->ps().y3(),
+ this->ps().x4(), this->ps().y4()
+ );
+}
+
// find entry
void PSPlanner::fe()
{
void PSPlanner::fe_parallel()
{
+ this->shrink_to_perfect_len();
BicycleCar bco = BicycleCar(this->gc());
this->cc() = BicycleCar();
this->cc().sp(-0.01);