-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
954 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef CONSTRAINEDRRT_H | ||
#define CONSTRAINEDRRT_H | ||
|
||
#include "../ccrrt/RRTManager.h" | ||
#include "../ccrrt/Constraint.h" | ||
|
||
namespace ccrrt { | ||
|
||
class ConstrainedRRT : public RRTManager | ||
{ | ||
public: | ||
|
||
ConstrainedRRT(int maxTreeSize=10000, | ||
double maxStepSize=0.1, | ||
double collisionCheckStepSize=0.1); | ||
|
||
bool collisionChecker(JointConfig& config, const JointConfig& parentConfig); | ||
|
||
void setConstraint(Constraint* constraint); | ||
|
||
protected: | ||
|
||
Trajectory _col; | ||
Constraint* _constraint; | ||
Eigen::VectorXd _cost; | ||
|
||
}; | ||
|
||
} // namespace ccrrt | ||
|
||
#endif // CONSTRAINEDRRT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
#include "../ccrrt/ConstrainedRRT.h" | ||
|
||
using namespace ccrrt; | ||
|
||
ConstrainedRRT::ConstrainedRRT(int maxTreeSize, | ||
double maxStepSize, | ||
double collisionCheckStepSize) : | ||
RRTManager(maxTreeSize, maxStepSize, collisionCheckStepSize) | ||
{ | ||
_constraint = NULL; | ||
} | ||
|
||
bool ConstrainedRRT::collisionChecker(JointConfig& config, const JointConfig& parentConfig) | ||
{ | ||
if(_constraint==NULL) | ||
return true; | ||
|
||
double dist = (parentConfig-config).norm(); | ||
_col.state_space = config.size(); | ||
_col.waypoints = ceil(dist/collisionCheckStepSize_); | ||
_col.start = parentConfig; | ||
_col.end = config; | ||
_col.xi.resize(_col.state_space*_col.waypoints); | ||
|
||
for(size_t i=0; i<_col.waypoints; ++i) | ||
{ | ||
_col.xi.block(i*_col.state_space,0,_col.state_space,1) = | ||
(config-parentConfig)*(double)(i+1)/(double)(_col.waypoints) | ||
+ parentConfig; | ||
} | ||
|
||
return _constraint->getCost(_cost, _col) != Constraint::INVALID; | ||
} | ||
|
||
void ConstrainedRRT::setConstraint(Constraint *constraint) | ||
{ | ||
_constraint = constraint; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.