#ifndef RRTS_H
#define RRTS_H
+#include <chrono>
#include <functional>
#include <random>
#include <vector>
class RRTS {
private:
unsigned int icnt_ = 0;
+ std::chrono::high_resolution_clock::time_point tstart_;
+ double scnt_ = 0;
std::vector<RRTNode> goals_;
std::vector<RRTNode> nodes_;
std::vector<RRTNode> samples_;
std::vector<RRTNode> steered_;
+ /*! \brief Update and return elapsed time.
+ */
+ double elapsed();
+
// RRT procedures
std::tuple<bool, unsigned int, unsigned int>
collide(std::vector<std::tuple<double, double>> &poly);
// getters, setters
unsigned int icnt() const { return this->icnt_; }
+ double scnt() const { return this->scnt_; }
std::vector<RRTNode> &goals() { return this->goals_; }
std::vector<RRTNode> &nodes() { return this->nodes_; }
std::vector<Obstacle> &obstacles() { return this->obstacles_; }
{
}
+double RRTS::elapsed()
+{
+ std::chrono::duration<double> dt;
+ dt = std::chrono::duration_cast<std::chrono::duration<double>>(
+ std::chrono::high_resolution_clock::now()
+ - this->tstart_
+ );
+ this->scnt_ = dt.count();
+ return this->scnt_;
+}
+
// RRT procedures
std::tuple<bool, unsigned int, unsigned int>
RRTS::collide(std::vector<std::tuple<double, double>> &poly)
bool RRTS::next()
{
+ if (this->icnt_ == 0)
+ this->tstart_ = std::chrono::high_resolution_clock::now();
bool next = true;
if (++this->icnt_ > 999)
next = false;