-
Notifications
You must be signed in to change notification settings - Fork 21
Added support for baked collision checking #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a17d587
initial implementation of baked checker support
cdellin 6db365b
Merge branch 'master' into feature/baked_checkers
cdellin 5806a50
remove accidental debug message
cdellin 4ccb53a
Merge branch 'master' into feature/baked_checkers
cdellin 9d11508
Merge branch 'master' into feature/baked_checkers
cdellin 00e53f3
accommodate new or_fcl baking interface
cdellin d99d6e7
Merge branch 'master' into feature/baked_checkers
cdellin f61f9f9
Merge branch 'master' into feature/baked_checkers
cdellin 6c3d478
Merge branch 'master' into feature/baked_checkers
cdellin 8d6ca4e
Merge branch 'master' into feature/baked_checkers
mkoval 9efdd85
Removed ill-fated stop() function.
3712445
Merge branch 'feature/baked_checkers' of https://github.com/personalr…
c475b3b
Don't collision-check invalid states.
6df1d0a
Revert "Removed ill-fated stop() function." pending re-implementation…
cdellin ba7539e
insert missing baking call erroneously removed in merge d99d6e779a9e6…
cdellin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -158,13 +158,49 @@ void ContinuousJointsProjectionEvaluator::project(const ompl::base::State *state | |
|
||
or_ompl::OrStateValidityChecker::OrStateValidityChecker( | ||
const ompl::base::SpaceInformationPtr &si, | ||
OpenRAVE::RobotBasePtr robot, std::vector<int> const &indices): | ||
OpenRAVE::RobotBasePtr robot, std::vector<int> const &indices, | ||
bool do_baked): | ||
ompl::base::StateValidityChecker(si), | ||
m_stateSpace(si->getStateSpace().get()), | ||
m_env(robot->GetEnv()), m_robot(robot), m_indices(indices) { | ||
m_env(robot->GetEnv()), m_robot(robot), m_indices(indices), | ||
m_do_baked(do_baked) | ||
{ | ||
if (m_do_baked) | ||
{ | ||
m_baked_checker = m_env->GetCollisionChecker(); | ||
std::stringstream sinput("BakeGetType"), soutput; | ||
try | ||
{ | ||
if (!m_baked_checker->SendCommand(soutput, sinput)) | ||
throw std::runtime_error("collision checker doesn't support baked checks!"); | ||
} | ||
catch (const OpenRAVE::openrave_exception & exc) | ||
{ | ||
throw std::runtime_error("collision checker doesn't support baked checks!"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace these |
||
} | ||
m_baked_kinbody_type = soutput.str(); | ||
} | ||
|
||
resetStatistics(); | ||
} | ||
|
||
void or_ompl::OrStateValidityChecker::start() { | ||
if (m_do_baked) | ||
{ | ||
// start baking | ||
std::stringstream sinput("BakeBegin BakeEnd"), soutput; | ||
m_baked_checker->SendCommand(soutput, sinput); // BakeBegin | ||
m_baked_kinbody = OpenRAVE::RaveCreateKinBody(m_env, m_baked_kinbody_type); | ||
m_env->CheckCollision(m_robot); | ||
m_robot->CheckSelfCollision(); | ||
m_baked_checker->SendCommand(soutput, sinput); // BakeEnd | ||
} | ||
} | ||
|
||
void or_ompl::OrStateValidityChecker::stop() { | ||
m_baked_kinbody.reset(); | ||
} | ||
|
||
bool or_ompl::OrStateValidityChecker::computeFk(const ompl::base::State *state, uint32_t checklimits) const { | ||
std::vector<double> values; | ||
m_stateSpace->copyToReals(values, state); | ||
|
@@ -184,23 +220,30 @@ bool or_ompl::OrStateValidityChecker::isValid(const ompl::base::State *state) co | |
boost::chrono::steady_clock::time_point const tic | ||
= boost::chrono::steady_clock::now(); | ||
|
||
bool const collided = !computeFk(state, OpenRAVE::KinBody::CLA_Nothing) | ||
|| m_env->CheckCollision(m_robot) | ||
|| m_robot->CheckSelfCollision(); | ||
bool collided = !computeFk(state, OpenRAVE::KinBody::CLA_Nothing); | ||
|
||
boost::chrono::steady_clock::time_point const toc | ||
= boost::chrono::steady_clock::now(); | ||
m_totalCollisionTime += boost::chrono::duration_cast< | ||
boost::chrono::duration<double> >(toc - tic).count(); | ||
m_numCollisionChecks++; | ||
if (!collided) | ||
{ | ||
if (m_do_baked) | ||
collided = collided || m_baked_checker->CheckStandaloneSelfCollision(m_baked_kinbody); | ||
else | ||
collided = collided || m_env->CheckCollision(m_robot) || m_robot->CheckSelfCollision(); | ||
|
||
boost::chrono::steady_clock::time_point const toc | ||
= boost::chrono::steady_clock::now(); | ||
m_totalCollisionTime += boost::chrono::duration_cast< | ||
boost::chrono::duration<double> >(toc - tic).count(); | ||
m_numCollisionChecks++; | ||
} | ||
|
||
return !collided; | ||
} | ||
|
||
or_ompl::RealVectorOrStateValidityChecker::RealVectorOrStateValidityChecker( | ||
const ompl::base::SpaceInformationPtr &si, | ||
OpenRAVE::RobotBasePtr robot, std::vector<int> const &indices): | ||
or_ompl::OrStateValidityChecker(si,robot,indices), | ||
OpenRAVE::RobotBasePtr robot, std::vector<int> const &indices, | ||
bool do_baked): | ||
or_ompl::OrStateValidityChecker(si,robot,indices,do_baked), | ||
m_num_dof(si->getStateDimension()) { | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needlessly bakes the collision checker twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is delicate -- what if the user has changed the environment between calls to
InitPlan
andPlanPath
? For example, what if they want to use different padding/models for validating starts/goals than for doing the actual planning (not sure if anyone actually does this, but they could). I currently get around this by baking in each call to a function, since I can rely on the environment lock.