- Bicycle car frame coordinates.
- [WvTest][] unit testing framework.
- Minimum turning radius circle centers on left/right side.
+- Move internal parameters (`x`, `y`, `h`) based on speed `sp` and steer `st`.
[WvTest]: https://github.com/apenwarr/wvtest
\param sd The safety distance.
\param df Distance from rear axle center to the front of the car.
\param dr Distance from rear axle center to the back of the car.
+\param sp Speed of the car.
+\param st Steering of the car.
*/
class BicycleCar {
private:
double sd_ = 0;
double df_ = 3.105;
double dr_ = 0.655;
+ // moving
+ double sp_ = 0;
+ double st_ = 0;
public:
// car frame
double lfx(); double lfy();
*/
BicycleCar *ccr();
+ // moving
+ /*! \brief Next car position based on `sp` and `st`.
+
+ Where `sp` is speed and `st` is steering of the car.
+ */
+ void next();
+
// getters, setters
double x() { return this->x_; }
void x(double x) { this->x_ = x; }
double dr() { return this->dr_; }
void dr(double dr) { this->dr_ = dr; }
+ double sp() { return this->sp_; }
+ void sp(double sp) { this->sp_ = sp; }
+
+ double st() { return this->st_; }
+ void st(double st) { this->st_ = st; }
+
BicycleCar();
};
return bc;
}
+// moving
+void BicycleCar::next()
+{
+ if (this->st() > this->wb() / this->mtr())
+ this->st(this->wb() / this->mtr());
+ if (this->st() < -this->wb() / this->mtr())
+ this->st(-this->wb() / this->mtr());
+ this->h(this->h() + this->sp() / this->wb() * tan(this->st()));
+ this->x(this->x() + this->sp() * cos(this->h()));
+ this->y(this->y() + this->sp() * sin(this->h()));
+}
+
BicycleCar::BicycleCar()
{
}
WVPASSEQ_DOUBLE(M_PI / 2, bc->ccr()->h(), 0.00001);
WVPASSEQ_DOUBLE(11, bc->ccr()->x(), 0.00001);
WVPASSEQ_DOUBLE(1, bc->ccr()->y(), 0.00001);
+
+ bc->sp(1);
+ bc->st(0);
+ bc->next();
+ WVPASSEQ_DOUBLE(1, bc->x(), 0.00001);
+ WVPASSEQ_DOUBLE(2, bc->y(), 0.00001);
+
+ bc->st(M_PI);
+ bc->next();
+ WVPASSEQ_DOUBLE(0.2, bc->st(), 0.00001);
+ bc->st(-M_PI);
+ bc->next();
+ WVPASSEQ_DOUBLE(-0.2, bc->st(), 0.00001);
}