From 93402123b9e2a3772f3ce5c7b9ad18d9a5d1dedd Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Wed, 8 Jul 2020 16:48:55 +0200 Subject: [PATCH] Make rrtnode bicycle car independent I mean in the sense of subclassing. --- api/rrts.h | 40 +++++++++++++++++++++++++++++++++++++++- src/rrts.cc | 7 ++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/api/rrts.h b/api/rrts.h index 8f53d6d..dad93f4 100644 --- a/api/rrts.h +++ b/api/rrts.h @@ -30,12 +30,26 @@ class RRTNodeType { \param c Cumulative cost from RRT data structure root. \param p Pointer to parent RRT node. \param t Type of the RRT node (RRTNodeType). +// -- from BicycleCar +\param x Horizontal coordinate of rear axle center. +\param y Vertical coordinate of rear axle center. +\param h Heading of the car in the interval [-pi,+pi] radians. +\param sp Speed of the car. +\param st Steering of the car. */ -class RRTNode : public BicycleCar { +class RRTNode { private: double c_ = 0; RRTNode *p_ = nullptr; unsigned int t_ = 0; + // -- from BicycleCar + // coordinates + double x_ = 0; + double y_ = 0; + double h_ = 0; + // moving + double sp_ = 0; + double st_ = 0; public: // getters, setters double c() const { return this->c_; } @@ -48,6 +62,30 @@ class RRTNode : public BicycleCar { void set_t(unsigned int flag) { this->t_ |= flag; } void clear_t(unsigned int flag) { this->t_ &= ~flag; } + // -- from BicycleCar + // getters, setters + double x() const { return this->x_; } + void x(double x) { this->x_ = x; } + + double y() const { return this->y_; } + void y(double y) { this->y_ = y; } + + double h() const { return this->h_; } + void h(double h) + { + while (h < -M_PI) + h += 2 * M_PI; + while (h > +M_PI) + h -= 2 * M_PI; + this->h_ = h; + } + + double sp() const { return this->sp_; } + void sp(double sp) { this->sp_ = sp; } + + double st() const { return this->st_; } + void st(double st) { this->st_ = st; } + RRTNode(); RRTNode(const BicycleCar &bc); bool operator==(const RRTNode& n); diff --git a/src/rrts.cc b/src/rrts.cc index ce0c322..214d1e9 100644 --- a/src/rrts.cc +++ b/src/rrts.cc @@ -11,8 +11,13 @@ RRTNode::RRTNode() { } -RRTNode::RRTNode(const BicycleCar &bc) : BicycleCar(bc) +RRTNode::RRTNode(const BicycleCar &bc) { + this->x(bc.x()); + this->y(bc.y()); + this->h(bc.h()); + this->sp(bc.sp()); + this->st(bc.st()); } bool RRTNode::operator==(const RRTNode& n) -- 2.39.2