#include "rrts.h"
#include "reeds_shepp.h"
-
+#include <iostream>
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
bool RRTS::goal_found(RRTNode &f)
{
bool found = false;
- for (auto &g: this->goals()) {
- double cost = this->cost_build(f, g);
- double edist = sqrt(
- pow(f.x() - g.x(), 2)
- + pow(f.y() - g.y(), 2)
- );
- double adist = std::abs(f.h() - g.h());
- if (edist < 0.05 && adist < M_PI / 32) {
- found = true;
- if (g.p() == nullptr || cc(f) + cost < cc(g)) {
- g.p(&f);
- g.c(cost);
- }
+ auto &g = this->goals().front();
+ double cost = this->cost_build(f, g);
+ double edist = sqrt(
+ pow(f.x() - g.x(), 2)
+ + pow(f.y() - g.y(), 2)
+ );
+ double adist = std::abs(f.h() - g.h());
+ if (edist < 0.05 && adist < M_PI / 32) {
+ found = true;
+ if (g.p() == nullptr || cc(f) + cost < cc(g)) {
+ g.p(&f);
+ g.c(cost);
}
}
return found;