return atan2(this->lfy() - this->lry(), this->lfx() - this->lrx());
}
+void
+ParkingSlot::set_parking_speed(double s)
+{
+ this->parking_speed_ = s;
+}
+
+void
+ParkingSlot::set_max_cusp(unsigned int m)
+{
+ this->max_cusp_ = m;
+}
+
+void
+ParkingSlot::set_delta_angle_to_slot(double d)
+{
+ this->delta_angle_to_slot_ = d;
+}
+
bool
ParkingSlot::parallel() const
{
}
std::vector<BicycleCar>
-ParkingSlot::drive_in_slot(BicycleCar c, unsigned int& max)
+ParkingSlot::drive_in_slot(BicycleCar c)
{
assert(this->parallel());
assert(this->right());
assert(c.len() < this->len());
assert(c.w() < this->w());
std::vector<BicycleCar> path;
- path.reserve(max + 2);
+ path.reserve(this->max_cusp_ + 2);
path.push_back(c);
unsigned int cusp = 0;
- while (cusp < max + 1) {
+ while (cusp < this->max_cusp_ + 1) {
if (this->parked(c)) {
- if (cusp < max) {
- max = cusp;
+ if (cusp < this->max_cusp_) {
+ this->max_cusp_ = cusp;
}
path.push_back(c);
return path;
}
PoseRange
-ParkingSlot::fe(BicycleCar c, unsigned int& max)
+ParkingSlot::fe(BicycleCar c)
{
assert(this->parallel());
assert(this->right());
c.x(this->lrx() + clen * cos(c.h()) + cw * cos(c.h() + M_PI / 2.0));
c.y(this->lry() + clen * sin(c.h()) + cw * sin(c.h() + M_PI / 2.0));
c.set_max_steer();
- c.sp(-0.001);
+ c.sp(this->parking_speed_);
auto const rc = c.rf();
this->curb_.intersects_with(rc, c.len());
double max_to_slot;
std::vector<BicycleCar> starts;
double a_to_slot = 0.0;
while (a_to_slot < max_to_slot) {
- a_to_slot += 0.0001;
- c.rotate(rc, 0.0001);
+ a_to_slot += this->delta_angle_to_slot_;
+ c.rotate(rc, this->delta_angle_to_slot_);
starts.push_back(c);
}
std::vector<std::vector<BicycleCar>> entries;
for (auto s: starts) {
- auto r = this->drive_in_slot(s, max);
+ auto r = this->drive_in_slot(s);
if (r.size() > 0) {
entries.push_back(r);
}