Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RRT Connect #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions include/RRT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ namespace rrt
double stepLength;
std::vector<Utils::Point<T> > pathPoints;
int maxIterations;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > tree;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > tree;
unsigned int biasParameter;

public:

RRT(){};
RRT(Utils::Point<T> start,Utils::Point<T> end)
{
//srand(time(NULL));
//srand(time(NULL));
startPoint=start;
endPoint=end;
}

virtual bool plan();
virtual std::vector<Utils::Point<T> > getPointsOnPath();

Expand Down Expand Up @@ -59,13 +59,51 @@ namespace rrt
void generatePath(Utils::Point<T> first,Utils::Point<T> last);
double dist(Utils::Point<T> a,Utils::Point<T> b);
};

template <class T>
class RRTConnect: public RRT<T>{

public:
bool plan();
std::vector<Utils::Point<T> > getPointsOnPath();

void setEndPoints(Utils::Point<T> start, Utils::Point<T> end);
void setCheckPointFunction(bool (*f)(Utils::Point<T>));
void setStepLength(double value);
void setOrigin(Utils::Point<T> origin);
void setHalfDimensions(double x,double y);
void setBiasParameter(unsigned int);
void setMaxIterations(int);
private:
double halfDimensionX;
double halfDimensionY;
Utils::Point<T> origin;
Utils::Point<T> connectA;
Utils::Point<T> connectB;
Utils::Point<T> startPoint;
Utils::Point<T> endPoint;
double stepLength;
std::vector<Utils::Point<T> > pathPoints;
int maxIterations;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > treeA;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > treeB;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > mainTree;
std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > supportTree;

unsigned int biasParameter;
bool (*userCheck)(Utils::Point<T>);
bool checkPoint(Utils::Point<T> pt);
Utils::Point<T> generatePoint(std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > >);
Utils::Point<T> generateBiasedPoint(Utils::Point<T> ,std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > >);
Utils::Point<T> findClosestNode(Utils::Point<T>,std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > tree);
void growTree(Utils::Point<T>);
Utils::Point<T> getParent(Utils::Point<T>,std::vector< std::pair< Utils::Point<T>, Utils::Point<T> > > tree);
bool treeComplete();
void generatePath(Utils::Point<T> first,Utils::Point<T> last);
double dist(Utils::Point<T> a,Utils::Point<T> b);
};
}

//************* ToDo *************
// Implement derived classes for variants of RRT
// Optimize the generate path and other
// Tweak with the parameters to check their effects on runtime and path
// Implement Pruning function to keep a check on size of tree


#endif
#endif
Loading